Message2525
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. |
|
Date |
User |
Action |
Args |
2008-02-20 17:18:33 | admin | link | issue1521374 messages |
2008-02-20 17:18:33 | admin | create | |
|