Different kinds of Import Errors

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Tue Dec 4 13:40:20 EST 2007


On 1 dic, 02:41, Graham Dumpleton <Graham.Dumple... at gmail.com> wrote:
> On Dec 1, 12:24 am, Thomas Guettler <h... at tbz-pariv.de> wrote:
>
> > Sorry, but this does not work. If there is an ImportError
> > during importing the existing module, it won't get inserted
> > into sys.modules. I just tried it with a small example.
>
> Curious, as at least for Python 2.3 it behaves as I described with the
> simple examples I tested. I do vaguely remember behaviour related to
> this changing though, so possible that newer version works
> differently.

Yes. It was changed on 2.4. From http://www.python.org/doc/2.4/whatsnew/node12.html:

"Encountering a failure while importing a module no longer leaves a
partially-initialized module object in sys.modules. The incomplete
module object left behind would fool further imports of the same
module into succeeding, leading to confusing errors. (Fixed by Tim
Peters.)"

--
Gabriel Genellina



More information about the Python-list mailing list