[Python-Dev] import succeeds on second try?
Ka-Ping Yee
ping@lfw.org
Sat, 10 Feb 2001 18:30:46 -0800 (PST)
On Sat, 10 Feb 2001, Guido van Rossum wrote:
>
> That's standard stuff; happens all the time.
Hrmm... it makes me feel icky.
> 1. The module gets compiled to bytecode, and the compiled bytecode
> gets written to the .pyc file, before any attempt to execute is.
>
> 2. The spam module gets entered into sys.modules at the *start* of its
> execution, for a number of reasons having to do with mutually
> recursive modules.
>
> 3. The execution fails on the "import eggs" but that doesn't undo the
> sys.modules assignment.
>
> 4. The second import of spam finds an incomplete module in
> sys.modyles, but doesn't know that, so returns it.
Is there a reason not to insert step 3.5?
3.5. If the import fails, remove the incomplete module from sys.modules.
-- ?!ng