[Python-Dev] Fix import errors to have data (original) (raw)
Jim Fulton jim at zope.com
Tue Jul 27 19:09:03 CEST 2004
- Previous message: [Python-Dev] Fix import errors to have data
- Next message: [Python-Dev] Fix import errors to have data
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Neal Norwitz wrote:
On Tue, Jul 27, 2004 at 12:39:22PM -0400, Jim Fulton wrote:
Tim Peters wrote:
[Jim Fulton]
No, it won't. For example, suppose foo imports B. B tries to import C, but fails. B is now broken, but it is still importable. Actually, both foo and B can be imported without errors, even though they are broken. 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. No. I'm proposing a way for a Python developer to detect the presence or absence of a module. Hm, perhaps it would be better to provide an API (if there isn't one already) to test whether a module is present. Another possibility could be to add a ChainedImportError (or SubImportError?) which would derive from ImportError. The module which imports a broken module would get the normal ImportError. If the module doesn't catch the exception, it would get converted to this new type of ImportError. I don't know how easy this would be to implement, but I think it would solve Jim's problem and perhaps be easier to deal with?
An even simpler aproach would be to have a ModuleNotFound error that extends ImportError and gets raised if the module can't be found.
Jim
-- Jim Fulton mailto:jim at zope.com Python Powered! CTO (540) 361-1714 http://www.python.org Zope Corporation http://www.zope.com http://www.zope.org
- Previous message: [Python-Dev] Fix import errors to have data
- Next message: [Python-Dev] Fix import errors to have data
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]