You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i use this in twisted, when sql contain chinese, i exec sql like this:
"select * from test where name = '\xe4\xbd\xa0\xe5\xa5\xbd'"
when table test don't have column [name], an error occur:
ProgrammingError(u'column "name" does not exist\nLINE 1: select * from test where name = '\u4f60\u597d'\n
but in twisted:
def safe_str(o):
"""
Returns a string representation of an object, or a string containing a
traceback, if that object's str raised an exception.
@param o: Any object.
@rtype: C{str}
"""
if _PY3 and isinstance(o, bytes):
# If o is bytes and seems to holds a utf-8 encoded string,
# convert it to str.
try:
return o.decode('utf-8')
except:
pass
try:
return str(o)
except:
return _safeFormat(str, o)
last error is
i must check error.message when an error occur, so i have change code like this:
The text was updated successfully, but these errors were encountered:
i use this in twisted, when sql contain chinese, i exec sql like this:
"select * from test where name = '\xe4\xbd\xa0\xe5\xa5\xbd'"
when table test don't have column [name], an error occur:
ProgrammingError(u'column "name" does not exist\nLINE 1: select * from test where name = '\u4f60\u597d'\n
but in twisted:
def safe_str(o):
"""
Returns a string representation of an object, or a string containing a
traceback, if that object's str raised an exception.
i must check error.message when an error occur, so i have change code like this:
The text was updated successfully, but these errors were encountered: