diff --git a/python/ray/actor.py b/python/ray/actor.py index 51c36484f..e742201b3 100644 --- a/python/ray/actor.py +++ b/python/ray/actor.py @@ -779,6 +779,13 @@ class ActorHandle(object): def make_actor(cls, num_cpus, num_gpus, resources, actor_method_cpus, checkpoint_interval, max_reconstructions): + # Give an error if cls is an old-style class. + if not issubclass(cls, object): + raise TypeError( + "The @ray.remote decorator cannot be applied to old-style " + "classes. In Python 2, you must declare the class with " + "'class ClassName(object):' instead of 'class ClassName:'.") + if checkpoint_interval is None: checkpoint_interval = -1 if max_reconstructions is None: diff --git a/test/actor_test.py b/test/actor_test.py index d92506f90..da5c54091 100644 --- a/test/actor_test.py +++ b/test/actor_test.py @@ -98,6 +98,16 @@ def test_actor_init_error_propagated(ray_start_regular): ray.get(actor.foo.remote()) +@pytest.mark.skipif( + sys.version_info >= (3, 0), reason="This test requires Python 2.") +def test_old_style_error(ray_start_regular): + with pytest.raises(TypeError): + + @ray.remote + class Actor: + pass + + def test_keyword_args(ray_start_regular): @ray.remote class Actor(object):