import bug?

A

alain

Hi all,

Running python 2.5, i experience a strange behaviour with the
following code:import imputil

def handle_pye(fullpath, fileinfo, name):
# Print a debugging message
print 'Importing "%s" from "%s"' % (name,fullpath)
data = open(fullpath).read()
return 0, compile(data,fullpath,'exec'),{}

im = imputil.ImportManager()
im.add_suffix('.pye',handle_pye)
im.install() # THIS SEEMS TO DO WEIRD THINGS TO SUBSEQUENT
IMPORTS !!!!

import functools

I then get the following traceback:
Traceback (most recent call last):
File "D:\deleteme\New1.py", line 12, in <module>
import functools
File "C:\Python25\lib\imputil.py", line 103, in _import_hook
top_module = self._import_top_module(parts[0])
File "C:\Python25\lib\imputil.py", line 190, in _import_top_module
module = self.fs_imp.import_from_dir(item, name)
File "C:\Python25\lib\imputil.py", line 545, in import_from_dir
return self._process_result(result, fqname)
File "C:\Python25\lib\imputil.py", line 304, in _process_result
exec code in module.__dict__
File "C:\Python25\lib\functools.py", line 10, in <module>
from _functools import partial
File "C:\Python25\lib\imputil.py", line 106, in _import_hook
raise ImportError, 'No module named ' + fqname
ImportError: No module named _functools


The mere fact of installing a custom importer seems to break the
import functionality.

Alain
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
474,262
Messages
2,571,045
Members
48,769
Latest member
Clifft

Latest Threads

Top