[Python-Dev] regrtest.py mystery

Tim Peters tim.one@home.com
Mon, 17 Dec 2001 14:38:48 -0500


Without diving into the unloading pit, the endless problems with -r on
non-Unix boxes would go away if a module that failed to import didn't leave
behind a damaged module object in sys.modules ("damaged" == it may not
fulfill some or any of the module's contracts, and it's impossible to guess
which ones it won't, or to guess how the unfufilled ones may fail).

I'm tempted to add a pile of Windows-specific modules that import each other
in incestuous ways, so everyone can enjoy this chronic pain <wink>.

"A fix" seems to amount to treating

import M

as if it were

try:
    import M
except:
    if M in sys.modules:
        del sys.modules[M]
    raise

How would that hurt?