mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-05 09:42:33 +01:00
Make type checks in ircutils.safeArgument compatible with Python 3.
This commit is contained in:
parent
66e4243a14
commit
fa8950b4a4
@ -38,6 +38,7 @@ work in an IRC-case-insensitive fashion), and numerous other things.
|
|||||||
from __future__ import division
|
from __future__ import division
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
import sys
|
||||||
import time
|
import time
|
||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
@ -460,9 +461,10 @@ def isValidArgument(s):
|
|||||||
|
|
||||||
def safeArgument(s):
|
def safeArgument(s):
|
||||||
"""If s is unsafe for IRC, returns a safe version."""
|
"""If s is unsafe for IRC, returns a safe version."""
|
||||||
if isinstance(s, unicode):
|
if sys.version_info[0] < 3 and isinstance(s, unicode):
|
||||||
s = s.encode('utf-8')
|
s = s.encode('utf-8')
|
||||||
elif not isinstance(s, basestring):
|
elif (sys.version_info[0] < 3 and not isinstance(s, basestring)) or \
|
||||||
|
(sys.version_info[0] >= 3 and not isinstance(s, str)):
|
||||||
debug('Got a non-string in safeArgument: %r', s)
|
debug('Got a non-string in safeArgument: %r', s)
|
||||||
s = str(s)
|
s = str(s)
|
||||||
if isValidArgument(s):
|
if isValidArgument(s):
|
||||||
|
Loading…
Reference in New Issue
Block a user