Support non ascii characters in the source code (#4047)

This commit is contained in:
Yu Kobayashi
2019-02-16 12:45:44 +09:00
committed by Hao Chen
parent de17443dc2
commit d2d66c576e
2 changed files with 13 additions and 1 deletions
+3 -1
View File
@@ -123,7 +123,9 @@ class FunctionDescriptor(object):
try:
# If we are running a script or are in IPython, include the source
# code in the hash.
source = inspect.getsource(function).encode("ascii")
source = inspect.getsource(function)
if sys.version_info[0] >= 3:
source = source.encode()
function_source_hasher.update(source)
function_source_hash = function_source_hasher.digest()
except (IOError, OSError, TypeError):