Python 2 encoding enhancements - Issue 2230

This commit is contained in:
Thomas Nagy 2019-04-15 21:17:46 +02:00
parent 9f2ce1b776
commit 5e90de89d8
No known key found for this signature in database
GPG Key ID: 49B4C67C05277AAA
2 changed files with 10 additions and 1 deletions

View File

@ -237,7 +237,10 @@ class formatter(logging.Formatter):
if rec.levelno >= logging.INFO:
# the goal of this is to format without the leading "Logs, hour" prefix
if rec.args:
return msg % rec.args
try:
return msg % rec.args
except UnicodeDecodeError:
return msg.encode('utf-8') % rec.args
return msg
rec.msg = msg

View File

@ -604,6 +604,12 @@ def h_list(lst):
"""
return md5(repr(lst).encode()).digest()
if sys.hexversion < 0x3000000:
def h_list_python2(lst):
return md5(repr(lst)).digest()
h_list_python2.__doc__ = h_list.__doc__
h_list = h_list_python2
def h_fun(fun):
"""
Hash functions