Fix segmentation fault when calling ray.put on a dictionary with object keys (#548)

* fix segfault when serializing dict key

* fix style

* fix test

* Fix linting.
This commit is contained in:
Eric Liang
2017-05-15 01:09:13 -07:00
committed by Philipp Moritz
parent 3c5375345f
commit e2e9e4ce6f
5 changed files with 26 additions and 10 deletions
+10 -3
View File
@@ -89,8 +89,14 @@ COMPLEX_OBJECTS = [
class Foo(object):
def __init__(self):
pass
def __init__(self, value=0):
self.value = value
def __hash__(self):
return hash(self.value)
def __eq__(self, other):
return other.value == self.value
class Bar(object):
@@ -139,7 +145,8 @@ TUPLE_OBJECTS = [(obj,) for obj in BASE_OBJECTS]
DICT_OBJECTS = ([{obj: obj} for obj in PRIMITIVE_OBJECTS
if (obj.__hash__ is not None and
type(obj).__module__ != "numpy")] +
[{0: obj} for obj in BASE_OBJECTS])
[{0: obj} for obj in BASE_OBJECTS] +
[{Foo(123): Foo(456)}])
RAY_TEST_OBJECTS = BASE_OBJECTS + LIST_OBJECTS + TUPLE_OBJECTS + DICT_OBJECTS