This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Tim Mitchell2
Recipients Tim Mitchell2, methane
Date 2019-03-28.03:42:38
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1553744559.32.0.207343635807.issue36457@roundup.psfhosted.org>
In-reply-to
Content
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 :)
History
Date User Action Args
2019-03-28 03:42:39Tim Mitchell2setrecipients: + Tim Mitchell2, methane
2019-03-28 03:42:39Tim Mitchell2setmessageid: <1553744559.32.0.207343635807.issue36457@roundup.psfhosted.org>
2019-03-28 03:42:39Tim Mitchell2linkissue36457 messages
2019-03-28 03:42:39Tim Mitchell2create