Message339008
The new functools.singledispatchmethod (issue32380) class interacts poorly with subclasses.
There is no way for a sub-class to override or extend the dispatch registry.
E.g.
class BaseVistor:
@singledispatchmethod
def visit(self, obj):
raise ValueError('Explict vistor implementation missing)
class AVisitor(BaseVisitor):
# problem: here we can only register against base class method
@BaseVistor.visit.reister(int)
def visit_int(self, obj):
print ('integer')
The AVistor class has now changed the dispatch registry for BaseVistor class which is bad.
To fix this the dispatch registry needs to be copied for each subclass and an alternate register mechanism provided for subclasses to register against a subclass method.
See attached file and pypi methoddispatch for details :) |
|
Date |
User |
Action |
Args |
2019-03-28 03:42:39 | Tim Mitchell2 | set | recipients:
+ Tim Mitchell2, methane |
2019-03-28 03:42:39 | Tim Mitchell2 | set | messageid: <1553744559.32.0.207343635807.issue36457@roundup.psfhosted.org> |
2019-03-28 03:42:39 | Tim Mitchell2 | link | issue36457 messages |
2019-03-28 03:42:39 | Tim Mitchell2 | create | |
|