Is this is bug or something change in Python 2.3

Samir Patel spatel at landrum-brown.com
Tue Sep 30 15:54:41 CEST 2003


I am calling __import__. It works fine with python 2.1 to 2.2.3, but does not 
work for python 2.3 and 2.3.1. 

I have 2 files x.py in current directory and mytest.py file in subfolder 
'subdir' as follows:

bash-2.05b# ls -lR
.:
total 5
drwxrwxrwx    2 root     root          112 Sep 30 08:19 subdir
-rw-rw-rw-    1 root     root          107 Sep 30 08:19 x.py

./subdir:
total 8
-rw-r--r--    1 root     root           28 Sep 30 08:13 mytest.py
-rw-r--r--    1 root     root          135 Sep 30 08:19 mytest.pyc



bash-2.05b# cat x.py
import os
os.chdir (os.getcwd() + '/subdir')
itemText = 'mytest'
moodule = __import__(itemText, globals())



bash-2.05b# cat subdir/mytest.py
import os
print os.getcwd()
bash-2.05b#



bash-2.05b# /usr/bin/python2.2 x.py
/tmp/test/subdir


bash-2.05b# /usr/bin/python2.1 x.py
/tmp/test/subdir


bash-2.05b# /usr/bin/python2.3.1 x.py
Traceback (most recent call last):
  File "/tmp/test/x.py", line 4, in ?
    moodule = __import__(itemText, globals())
ImportError: No module named mytest

-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.tgz
Type: application/x-tgz
Size: 425 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20030930/d94abc0a/attachment.bin>


More information about the Python-list mailing list