Go Back   Velocity Reviews > Newsgroups > Python
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

Python - Re: imputil.py, is this a bug ?

 
Thread Tools Search this Thread
Old 11-07-2009, 09:55 AM   #1
Default Re: imputil.py, is this a bug ?


Gabriel Genellina wrote:
> En Fri, 06 Nov 2009 18:33:37 -0300, Stef Mientki
> <> escribió:
>
>> I get an error compiling with pyjamas, in the standard module
>> imputil, _import_top_module

>
> Note that imputil is undocumented in 2.5, deprecated in 2.6 and
> definitively gone in 3.0
>
>> AttributeError: 'unicode' object has no attribute 'import_top'
>>
>> 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
>>
>> It seems that elements of sys.path can be of the type unicode
>> 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 )

>
> Yes, seems to be a bug. But given the current status of imputil, it's
> not likely to be fixed; certainly not in 2.5 which only gets security
> fixes now.
>
> I cannot test it at this moment, but I'd use the unicode item directly
> (that is, self.fs_imp.import_from_dir(item, name)). Or perhaps
> item.encode(sys.getdefaultfilesystemencoding()). str(item)
> definitively won't work with directory names containing non-ascii
> characters.
>
> Why are you using imputil in the first place?
>

thanks Gabriel,
well PyJamas is using (a copy) of it and I bumped into problems using
PyJamas.
I'll send this message to the PyJamas developers,
because this stuff is far beyond my knowledge.

cheers,
Stef


Stef Mientki
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46