mirror of
https://github.com/vale981/ray
synced 2025-03-09 04:46:38 -04:00
Support non ascii characters in the source code (#4047)
This commit is contained in:
parent
de17443dc2
commit
d2d66c576e
2 changed files with 13 additions and 1 deletions
|
@ -123,7 +123,9 @@ class FunctionDescriptor(object):
|
||||||
try:
|
try:
|
||||||
# If we are running a script or are in IPython, include the source
|
# If we are running a script or are in IPython, include the source
|
||||||
# code in the hash.
|
# 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_hasher.update(source)
|
||||||
function_source_hash = function_source_hasher.digest()
|
function_source_hash = function_source_hasher.digest()
|
||||||
except (IOError, OSError, TypeError):
|
except (IOError, OSError, TypeError):
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
# coding: utf-8
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
from __future__ import division
|
from __future__ import division
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
@ -2767,3 +2768,12 @@ def test_raylet_is_robust_to_random_messages(shutdown_only):
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
assert ray.get(f.remote()) == 1
|
assert ray.get(f.remote()) == 1
|
||||||
|
|
||||||
|
|
||||||
|
def test_non_ascii_comment(ray_start):
|
||||||
|
@ray.remote
|
||||||
|
def f():
|
||||||
|
# 日本語 Japanese comment
|
||||||
|
return 1
|
||||||
|
|
||||||
|
assert ray.get(f.remote()) == 1
|
||||||
|
|
Loading…
Add table
Reference in a new issue