irmen / Pyro5

Pyro 5 - Python remote objects
https://pyro5.readthedocs.io
MIT License
303 stars 36 forks source link

User Class Conversion Functions Problem #56

Closed boom0192 closed 2 years ago

boom0192 commented 2 years ago

There is a bug in the register_class_to_dict and register_dict_to_class functionality. I don’t know if the problem is with Pyro5 or serpent. When I registered a base class, followed by the subclasses, it didn’t work properly. Only the base class dict_to_class function got called. When I registered the base class after the subclasses, it worked properly.

irmen commented 2 years ago

Yeah I think this is expected behavior. Pyro checks for all types registered if the object is an instance of that type, and if it is, it will use the specialized serialization function. An instance of a subclass of type X is also an instance of X, so if Pyro sees X first it will just use that. So, the solution is to not register complex class hierarchies. Or depend on your ordering trick.