ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> python-list
python-list
Re: imputil.py, is this a bug ?
by Gabriel Genellina other posts by this author
Nov 6 2009 6:22PM messages near this date
imputil.py, is this a bug ? | Re: imputil.py, is this a bug ?
En Fri, 06 Nov 2009 18:33:37 -0300, Stef Mientki <stef.mientki@[...].com>   
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?

-- 
Gabriel Genellina

-- 
http://mail.python.org/mailman/listinfo/python-list
Thread:
Stef Mientki
Gabriel Genellina
Lkcl
Terry Reedy
Stef Mientki
Terry Reedy

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved