Skip to content

Commit

Permalink
Fixed netref.class_factory id_pack usage per #339 and added test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
comrumino committed Jul 15, 2019
1 parent cbbbcab commit 386d340
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rpyc/core/netref.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions tests/test_custom_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down Expand Up @@ -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()

0 comments on commit 386d340

Please # to comment.