imputil.py, is this a bug ?

Stef Mientki stef.mientki at gmail.com
Fri Nov 6 22:33:37 CET 2009


hello,

I get an error compiling with pyjamas, in the standard module imputil, 
_import_top_module

Traceback (most recent call last):
  File 
"D:\Data_Python_25\PyLab_Works\pylab_works_programs\PyJamas_Test\Vraag_Test1.py", 
line 22, in <module>
    from Vragenlijsten import Get_Vragenlijst
  File "P:\Python\Lib\site-packages\pyjd\imputil.py", line 109, in 
_import_hook
    top_module = self._import_top_module(parts[0])
  File "P:\Python\Lib\site-packages\pyjd\imputil.py", line 217, in 
_import_top_module
    module = item.import_top(name)
AttributeError: 'unicode' object has no attribute 'import_top'

It seems that elements of sys.path can be of the type unicode

    def _import_top_module(self, name):
        # scan sys.path looking for a location in the filesystem that 
contains
        # the module, or an Importer object that can import the module.
        for item in sys.path:
            if isinstance(item, _StringType):
                module = self.fs_imp.import_from_dir(item, name)
            else:
                module = item.import_top(name)
            if module:
                return module
        return None

so by adding the next 2 lines, everything works ok.
            elif isinstance ( item, basestring ) :
                module = self.fs_imp.import_from_dir ( str(item), name)

is this a bug ?
(I'm using Python 2.5.2 on Windows )

thanks,
Stef Mientki



More information about the Python-list mailing list