From 386d340661d4ac01d949c36c84073a36bf3cfa79 Mon Sep 17 00:00:00 2001 From: James Stronz Date: Mon, 15 Jul 2019 00:32:20 -0500 Subject: [PATCH] Fixed netref.class_factory id_pack usage per #339 and added test cases --- rpyc/core/netref.py | 4 ++-- tests/test_custom_service.py | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/rpyc/core/netref.py b/rpyc/core/netref.py index a5e13c38..39fb905d 100644 --- a/rpyc/core/netref.py +++ b/rpyc/core/netref.py @@ -231,7 +231,7 @@ def __instancecheck__(self, other): else: return syncreq(self, consts.HANDLE_INSTANCECHECK, other.____id_pack__) else: - return isinstance(other, self) + return isinstance(other, self.__class__) def _make_method(name, doc): @@ -295,7 +295,7 @@ def class_factory(id_pack, methods): else: _module = sys.modules.get(name_pack) if _module: - if id_pack[0] != 0: + if id_pack[2] == 0: ns["__class__"] = _module else: ns["__class__"] = getattr(_module, "__class__", None) diff --git a/tests/test_custom_service.py b/tests/test_custom_service.py index 847a026d..a2277a48 100644 --- a/tests/test_custom_service.py +++ b/tests/test_custom_service.py @@ -43,6 +43,9 @@ def foobar(self): def exposed_getmeta(self): return MyClass() + def exposed_instance(self, inst, cls): + return isinstance(inst, cls) + class TestCustomService(unittest.TestCase): config = {} @@ -84,6 +87,10 @@ def test_metaclasses(self): x = self.conn.root.getmeta() print(x) + def test_instancecheck_list(self): + remote_list = self.conn.root.getlist() + self.assertTrue(self.conn.root.instance(remote_list, list)) + if __name__ == "__main__": unittest.main()