Issue1521374

classification
Title: second import of broken module succeeds
Type: Severity: normal
Components: None Versions:
Milestone:
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: cgroves
Priority: normal Keywords: patch

Created on 2006-07-12.18:19:58 by cgroves, last changed 2006-07-26.02:56:18 by cgroves.

Files
File name Uploaded Description Edit Remove
doubleImport.patch cgroves, 2006-07-12.18:19:58
badmodule.py cgroves, 2006-07-12.18:20:15
Messages
msg2525 (view) Author: Charlie Groves (cgroves) Date: 2006-07-12.18:19:58
If I have a module that throws an exception on import,
the first time I try to import it I get an ImportError.
The second time I try to import it, the import succeeds.

milo:~/dev/jython groves$ jytip
Jython 2.2a1 on java1.5.0_06 (JIT: null)
Type "copyright", "credits" or "license" for more
information.
>>> try:
... import badmodule
... except:
... pass
...
>>> import badmodule
>>> print badmodule
<module 'badmodule' from
'/Users/groves/dev/jython/badmodule.py'>

milo:~/dev/jython groves$ python
Python 2.4.3 (#1, Apr 7 2006, 10:54:33)
[GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin
Type "help", "copyright", "credits" or "license" for
more information.
>>> try:
... import badmodule
... except:
... pass
...
>>> import badmodule
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/Users/groves/dev/jython/badmodule.py", line 1,
in ?
import nonexistentmodule
ImportError: No module named nonexistentmodule

The patch surrounds the actual import code with a try
catch, and if an exception is thrown it removes the
module from the modules list and rethrows the
exception.  I think all import code eventually
flows through here to actually run the import so I
think it fixes everything, but someone with more
knowledge of the Jython import system should probably
take a look at this.
msg2526 (view) Author: Charlie Groves (cgroves) Date: 2006-07-26.02:56:18
Logged In: YES 
user_id=1174327

applied in r2859
History
Date User Action Args
2006-07-12 18:19:58cgrovescreate