Brett Cannon added the comment:

So I think Nick has the inheritance inverted and I would have Finder inherit 
from everything to stay backwards-compatible and to ease future deprecation 
(which could potentially happen starting in Python 3.3), although my approach 
weakens the usefulness of the ABCs to the point that Nick is probably right in 
the end. =)

Ideally you would have MetaPathFinder which has find_module(fullname, path). 
Nnotice there is no default value for path since meta path finders always have 
something passed in for 'path', even if it's None.

The other ABC would be PathImporter which defines find_loader(fullname). Notice 
how 'path' is no longer defined as it isn't used by PathFinder when calling a 
path importer.

importlib.abc.Finder would then inherit from both MetaPathFinder and 
PathImporter. This is because if someone wants to be compatible with both 
Python 3.2 and 3.3 without any trickery, they will want to simply inherit from 
Finder for either a meta path finder or a path importer. Otherwise in Python 
3.2 you would have to do some conditional work or define a fake e.g. 
MetaPathFinder ABC in order to inherit from the new ABCs.

Finder would have find_module(fullname, path=None) defined but returning None 
by default. It would also inherit from PathImporter, but this is where it gets 
tricky since importlib decides whether to call find_loader() based on whether 
find_loader() is defined, which means PathImporter couldn't require it to 
instantiated. Otherwise some hack will be needed in Finder for it to claim that 
find_loader() is defined but while still failing a hasattr() check (which I 
can't think of how to do; maybe some insane metaclass which temporarily sets 
find_loader() so abstractmethod doesn't complain but then isn't defined in the 
end so __getattr__ still raises an AttributeError?).

IOW I don't see an ideal situation here and we will probably want to do what 
Nick suggested.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue15502>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to