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 brett.cannon
Recipients barry, brett.cannon, eric.smith, eric.snow, georg.brandl, ncoghlan
Date 2012-07-31.19:51:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1343764300.78.0.600412700354.issue15502@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2012-07-31 19:51:41brett.cannonsetrecipients: + brett.cannon, barry, georg.brandl, ncoghlan, eric.smith, eric.snow
2012-07-31 19:51:40brett.cannonsetmessageid: <1343764300.78.0.600412700354.issue15502@psf.upfronthosting.co.za>
2012-07-31 19:51:40brett.cannonlinkissue15502 messages
2012-07-31 19:51:36brett.cannoncreate