Guido van Rossum wrote: >> Then you're proposing a way for a highly knowledgable user to >> anticipate, and partially worm around, that Python leaves behind >> insane module objects in sys.modules. Wouldn't it be better to >> change Python to stop leaving insane module objects in sys.modules >> to begin with? That's harder, but seems to me it would do a lot >> more good for a lot more people. > > +1 OK - the problem as I see it is that a given module that exists, but raises ImportError, only raises ImportError *once*, whereas it really should raise ImportError every time i.e. currently doing the following: # a.py raise ImportError # b.py try: import a except ImportError: import a print 'OK' prints when it really should raise ImportError. Additionally, a module could have messed with sys.modules directly, so just putting None in for the broken module wouldn't be sufficient (you could possibly get the broken module via another name). Perhaps the import machinery could keep a (weak?) mapping from module *object* to the ImportError it raised. If the module that would be returned by the import is in the mapping, raise the corresponding ImportError instead. The appropriate line, etc in the module would thus be shown each time the module was imported. I believe this would work properly for reload() as well. Tim Delaney
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4