Issue1672800

classification
Title: Fix for __import__('module', None)
Type: Severity: normal
Components: None Versions:
Milestone:
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: Nosy List: cgroves, pjenvey
Priority: normal Keywords: patch

Created on 2007-03-03.03:06:25 by pjenvey, last changed 2007-03-09.17:23:38 by cgroves.

Files
File name Uploaded Description Edit Remove
2.3-branch_r3134-imp_fix.diff pjenvey, 2007-03-03.03:06:25 patch made against branches/2.3, r3134
Messages
msg2675 (view) Author: Philip Jenvey (pjenvey) Date: 2007-03-03.03:06:25
Attempting to pass a None globals object to __import__ raises an error.

This is commonly done when you only want to specify one of the last arguments (like fromlist), and don't bother specifying globals (or locals), e.g.:

__import__('mypackage.mymodule', None, None, ['mymodule'])

Tests are also attached. Without the fix, the following is raised by the new test:

======================================================================
ERROR: testImpWrapperNoContext (__main__.ImportHooksTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/beans/home/pjenvey/src/java/jython-2.3/dist/Lib/unittest.py", line 229, in __call__
  File "test_importhooks.py", line 208, in testImpWrapperNoContext
  File "test_importhooks.py", line 201, in doTestImpWrapper
AttributeError: __getitem__
msg2676 (view) Author: Charlie Groves (cgroves) Date: 2007-03-09.17:23:38
committed in r3136 on trunk.
History
Date User Action Args
2007-03-03 03:06:25pjenveycreate