[Import-sig] Another imputil problem

Thomas Heller thomas.heller@ion-tof.com
Fri, 9 Feb 2001 21:12:37 +0100


Dear import-sig, I encountered two cases where imputil behaves
different than 'normal python'.

xml/__init__.py contains the following code fragment:

try:
    import _xmlplus
except ImportError:
    pass
else:
    try:
        v = _xmlplus.version_info
    except AttributeError:
        # _xmlplue is too old; ignore it
        pass
    else:
        if v >= _MINIMUM_XMLPLUS_VERSION:
            import sys
            sys.modules[__name__] = _xmlplus
        else:
            del v

when you have PyXML installed and execute
>>>import xml; print xml
you get
  <module '_xmlplus' from 'c:\python20\_xmlplus\__init__.pyc'>

If you try
>>>import imputil; imputil._test_revamp()
>>>import xml; print xml
you get
  <module 'xml' from 'c:\python20\lib\xml\__init__.pyc'>
and
>>>del sys; import sys; print sys.modules['xml']
prints
  <module '_xmlplus' from 'c:\python20\_xmlplus\__init__.pyc'>

IMO this should be fixed. I can try to prepare a patch for this.

Thomas