classification
Title: Use 'is not None' where appropriate in importlib
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: brett.cannon Nosy List: brett.cannon, daniel.urban, eric.araujo, eric.snow, ncoghlan, petri.lehtinen, python-dev
Priority: low Keywords: easy

Created on 2011-07-20 23:34 by ncoghlan, last changed 2012-04-18 01:43 by brett.cannon. This issue is now closed.

Messages (2)
msg140770 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2011-07-20 23:34
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.
msg158584 - (view) Author: Roundup Robot (python-dev) Date: 2012-04-18 01:42
New changeset c1399cf7bd6a by Brett Cannon in branch 'default':
Issue #12599: Be more strict in accepting None vs. a false-like object
http://hg.python.org/cpython/rev/c1399cf7bd6a
History
Date User Action Args
2012-04-18 01:43:15brett.cannonsetstatus: open -> closed
resolution: fixed
stage: test needed -> resolved
2012-04-18 01:42:16python-devsetnosy: + python-dev
messages: + msg158584
2012-04-18 00:16:29eric.snowsetnosy: + eric.snow
2012-04-17 23:20:08brett.cannonsetkeywords: + easy
priority: normal -> low
components: + Library (Lib)
versions: - Python 3.2
2011-07-22 21:18:36eric.araujosetnosy: + eric.araujo
2011-07-22 17:55:37petri.lehtinensetnosy: + petri.lehtinen
2011-07-22 17:33:16daniel.urbansetnosy: + daniel.urban
2011-07-20 23:34:26ncoghlancreate