2.3a1: importhooks oddity
Hans Nowak
wurmy at earthlink.net
Wed Jan 1 21:55:26 EST 2003
Howdy y'all,
I downloaded both the Windows installer and the source code for Python 2.3a1.
While playing with the new import hooks, I noticed something peculiar. Consider
this piece of code:
import sys
print sys.version
def f(path):
print "Wahey!", path
raise ImportError
sys.path_hooks.append(f)
import nothing # needless to say, doesn't exist
I built my own version with Cygwin, using a simple configure & make install,
nothing fancy. When I run the code, I get the following output:
$ python test-importhooks-2.py
2.3a1 (#1, Jan 1 2003, 21:44:23)
[GCC 2.95.3-5 (cygwin special)]
Wahey!
Traceback (most recent call last):
File "test-importhooks-2.py", line 13, in ?
import nothing # needless to say, doesn't exist
ImportError: No module named nothing
This is what I expected. However, when I run this with the Windows version, I
get this output:
(P:\test\2.3) $ python test-importhooks-2.py
2.3a1 (#38, Dec 31 2002, 17:53:59) [MSC v.1200 32 bit (Intel)]
Traceback (most recent call last):
File "test-importhooks-2.py", line 13, in ?
import nothing # needless to say, doesn't exist
ImportError: No module named nothing
In other words, function f doesn't seem to be called.
Is this a bug, a feature, or am I doing something wrong?
--
Hans (base64.decodestring('d3VybXlAZWFydGhsaW5rLm5ldA=='))
# decode for email address ;-)
The Pythonic Quarter:: http://www.awaretek.com/nowak/
Kaa:: http://www.awaretek.com/nowak/kaa.html
More information about the Python-list
mailing list