This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author skrah
Recipients brett.cannon, pitrou, skrah
Date 2012-07-23.11:02:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1343041332.67.0.879140505618.issue15434@psf.upfronthosting.co.za>
In-reply-to
Content
It looks like distutils/command from the stdlib is searched first
despite the fact that the first path entry is '/home/stefan/tmp'.

If distutils/command is replaced with a/b, the import works:

$ pwd
/home/stefan/tmp
$ 
$ ls a/b/
__init__.py  xyz.py
$ ls distutils/command/
__init__.py  xyz.py
$ 
$ cat a/b/__init__.py 

import sys
sys.path.insert(0, '/home/stefan/tmp')
print(sys.path)

distutils_all = ['xyz']
__import__('a.b',globals(),locals(),distutils_all)


$ cat distutils/command/__init__.py 

import sys
sys.path.insert(0, '/home/stefan/tmp')
print(sys.path)

distutils_all = ['xyz']
__import__('distutils.command',globals(),locals(),distutils_all)



$ /home/stefan/usr/bin/python3.3 a/b/__init__.py 
['/home/stefan/tmp', '/home/stefan/tmp/a/b', '/home/stefan/usr/lib/python33.zip', '/home/stefan/usr/lib/python3.3', '/home/stefan/usr/lib/python3.3/plat-linux', '/home/stefan/usr/lib/python3.3/lib-dynload', '/home/stefan/.local/lib/python3.3/site-packages', '/home/stefan/usr/lib/python3.3/site-packages']
['/home/stefan/tmp', '/home/stefan/tmp', '/home/stefan/tmp/a/b', '/home/stefan/usr/lib/python33.zip', '/home/stefan/usr/lib/python3.3', '/home/stefan/usr/lib/python3.3/plat-linux', '/home/stefan/usr/lib/python3.3/lib-dynload', '/home/stefan/.local/lib/python3.3/site-packages', '/home/stefan/usr/lib/python3.3/site-packages']



$ /home/stefan/usr/bin/python3.3 distutils/command/__init__.py 
['/home/stefan/tmp', '/home/stefan/tmp/distutils/command', '/home/stefan/usr/lib/python33.zip', '/home/stefan/usr/lib/python3.3', '/home/stefan/usr/lib/python3.3/plat-linux', '/home/stefan/usr/lib/python3.3/lib-dynload', '/home/stefan/.local/lib/python3.3/site-packages', '/home/stefan/usr/lib/python3.3/site-packages']
Traceback (most recent call last):
  File "distutils/command/__init__.py", line 7, in <module>
    __import__('distutils.command',globals(),locals(),distutils_all)
ImportError: No module named 'distutils.command.xyz'
History
Date User Action Args
2012-07-23 11:02:12skrahsetrecipients: + skrah, brett.cannon, pitrou
2012-07-23 11:02:12skrahsetmessageid: <1343041332.67.0.879140505618.issue15434@psf.upfronthosting.co.za>
2012-07-23 11:02:12skrahlinkissue15434 messages
2012-07-23 11:02:11skrahcreate