mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-14 22:49:23 +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
|
||||
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
import random
|
||||
import string
|
||||
@ -460,9 +461,10 @@ def isValidArgument(s):
|
||||
|
||||
def safeArgument(s):
|
||||
"""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')
|
||||
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)
|
||||
s = str(s)
|
||||
if isValidArgument(s):
|
||||
|
Loading…
Reference in New Issue
Block a user