2.3a1: importhooks oddity

Brad Hards bhards at bigpond.net.au
Thu Jan 2 03:28:29 EST 2003


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thu, 2 Jan 2003 13:55, Hans Nowak wrote:
> (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?
Probably not a feature. The other two are still possible.

Here is the code running on Linux:

bradh at squirt Python-2.3a1 $ ./python test-importhooks-2.py
2.3a1 (#1, Jan  2 2003, 19:17:08)
[GCC 2.95.3 20010315 (release)]
Wahey!
Traceback (most recent call last):
  File "test-importhooks-2.py", line 12, in ?
    import nothing  # needless to say, doesn't exist
ImportError: No module named nothing

One thing you might like to try: adding a flush() to make sure that the 
routine really Isn't being called.
Try this version of f() instead:

def f(path):
    print "Wahey!", path
    sys.stdout.flush()
    raise ImportError

HTH

Brad

- -- 
http://linux.conf.au. 22-25Jan2003. Perth, Aust. I'm registered. Are you?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE+E/guW6pHgIdAuOMRAn73AKC3MsQQxMgDZWpBUMuUjh4GHZiBVACgusNc
2L/tffaHsUOWsIwYcWgrODY=
=V91X
-----END PGP SIGNATURE-----






More information about the Python-list mailing list