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 brett.cannon
Date 2013-02-03.16:47:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1359910046.95.0.667824237181.issue17115@psf.upfronthosting.co.za>
In-reply-to
Content
There is no reason __loader__ can't be set to None like __package__. That means having xml.parsers.expat.(model|errors) set the attribute to None by default (and thus removing the exemption for those modules from test_importlib.test_api.StartupTests), updating the decorators in importlib.util to set __loader__ when it is None, and make importlib.find_loader() treat None the same as if the attribute isn't set (e.g. unifying the raising of ValueError in both cases).

This will bring __loader__ back in alignment with __package__.

In all honesty I would like to tweak imp.new_module()/PyModule_Create() to set both __package__ and __loader__ to None by default, but I don't know how much code out there relies on the absence of these attributes and not on them being set to None (although fixing all of that code is simply transitioning from hasattr(module, '__loader__') to getattr(module, '__loader__', None)). Luckily PEP 302 was updated a couple versions back to state the loaders **must** set these attributes, so hopefully as time goes on this will be less of a worry.
History
Date User Action Args
2013-02-03 16:47:26brett.cannonsetrecipients: + brett.cannon
2013-02-03 16:47:26brett.cannonsetmessageid: <1359910046.95.0.667824237181.issue17115@psf.upfronthosting.co.za>
2013-02-03 16:47:26brett.cannonlinkissue17115 messages
2013-02-03 16:47:26brett.cannoncreate