[Python-3000] Minor problem with ABCMeta?
Nick Coghlan
ncoghlan at gmail.com
Mon Sep 1 12:05:58 CEST 2008
Andrew McNamara wrote:
> The __subclasscheck__ method of ABCMeta contains the following code:
>
> # Check if it's a subclass of a registered class (recursive)
> for rcls in cls._abc_registry:
> if issubclass(subclass, rcls):
> cls._abc_registry.add(subclass)
> return True
>
> It looks to me like this code will result in an unnecessary call to
> cls._abc_registry.add() in the case that "subclass" is already in
> cls._abc_registry. It looks like the code should be preceded with
> something like:
>
> if subclass in cls._abc_registry:
> return True
Actually, it looks to me like the subclass is getting added to the wrong
set - it should be going into the _abc_cache, not the _abc_registry.
Tracker item with the 2-line patch here if someone would care to give it
the necessary post-beta review:
http://bugs.python.org/issue3747
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
---------------------------------------------------------------
http://www.boredomandlaziness.org
More information about the Python-3000
mailing list