[New-bugs-announce] [issue12599] Use 'is not None' where appropriate in importlib
report at bugs.python.org
Thu Jul 21 01:34:26 CEST 2011
New submission from Nick Coghlan <ncoghlan at gmail.com>:
Problems noted by PJE on import-sig:
For example, PathFinder's find_module treats an empty path the same as sys.path, and will also fail if for some reason the bool() of a PEP 302 finder or loader object is False. Also, module_for_loader() will create a new module object, if you have a False module subclass in sys.modules.
These distinctions could be more problematic than they appear, as it's possible to inadvertently make your loader or your module subclass capable of being False (for example, if you subclassed a sequence type or implemented a __len__), and this could lead to some very subtle bugs, albeit very rare ones as well. ;-)
The import test cases should include some examples of such pathological objects, with importlib then updated appropriately.
nosy: brett.cannon, ncoghlan
stage: test needed
title: Use 'is not None' where appropriate in importlib
versions: Python 3.2, Python 3.3
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce