[Python-Dev] Fix import errors to have data

Tim Peters tim.peters at gmail.com
Tue Jul 27 19:25:02 CEST 2004


[Charles Cazabon]
> This is a bit I've never been quite sure of.  If a module knows it imports
> something not available everywhere, and can handle that bit missing, shouldn't
> it already wrap its import of that module in a try: ... except ImportError:
> block?

Sure!  Jim wants to distinguish "absenceness" from "brokenness" for
some reason.  It's not clear to my why (in response to Guido, he
mentioned only the "broken module in sys.modules" problem, but when I
suggested we address that directly he just repeated "you still
wouldn't be able to tell the difference
between an absent module and a broken one").

> To me, it would seem more sensible (and would address the Windows brittleness
> Tim mentions) if the above did /not/ leave pty in sys.modules -- i.e. the
> import failed either completely, or not at all.  The above is a "partial
> failure" which seems (to me) to be the root cause of the confusion.  Instead,
> it should fail completely, and then the pty module can (if it wants) try to
> import termios and handle it gracefully at that level if necessary.

Leaving insane module objects behind is harmful, and I'd like to
repair that.  But you still wouldn't be able to tell the difference
between an absent module and a broken one <wink>.


More information about the Python-Dev mailing list