[issue15434] __import__() problem in 3.3

2012-07-23 Thread Stefan Krah

New submission from Stefan Krah stefan-use...@bytereef.org:

Using b127046831e2, I'm experiencing an import problem during the NumPy build.

I've reduced it to this scenario, which works in 3.2 but not in 3.3.
Note that in NumPy's setup.py, the equivalent of /home/stefan/tmp is 
the first entry in sys.path. I'm not sure if this isolated example is 
terribly useful:


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

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

$ cat distutils/command/xyz.py
$
$ python3.2 distutils/command/__init__.py
$
$ /home/stefan/usr/bin/python3.3 distutils/command/__init__.py
Traceback (most recent call last):
  File distutils/command/__init__.py, line 3, in module
__import__('distutils.command',globals(),locals(),distutils_all)
ImportError: No module named 'distutils.command.xyz'
$

--
components: Interpreter Core
messages: 166218
nosy: brett.cannon, pitrou, skrah
priority: high
severity: normal
status: open
title: __import__() problem in 3.3
type: behavior
versions: Python 3.3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15434
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15434] __import__() problem in 3.3

2012-07-23 Thread Stefan Krah

Stefan Krah stefan-use...@bytereef.org added the comment:

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'

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15434
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15434] __import__() problem in 3.3

2012-07-23 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com:


--
nosy: +Arfrever

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15434
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15434] __import__() problem in 3.3

2012-07-23 Thread Brett Cannon

Changes by Brett Cannon br...@python.org:


--
nosy: +eric.araujo

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15434
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15434] __import__() problem in 3.3

2012-07-23 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

Could you explain what is it you’re trying to achieve?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15434
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15434] __import__() problem in 3.3

2012-07-23 Thread Stefan Krah

Stefan Krah stefan-use...@bytereef.org added the comment:

This is not a distutils issue. I want to know why this does not
throw an exception ...

python3.2 distutils/command/__init__.py


... while this raises ImportError:

~/usr/bin/python3.3 distutils/command/__init__.py



For the path structure please see my previous message.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15434
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15434] __import__() problem in 3.3

2012-07-23 Thread Brett Cannon

Brett Cannon br...@python.org added the comment:

It might be a runpy thing as Nick has been tweaking that lately to deal with 
pkgutil issues.

And this is of course ignoring the fact that __import__ should never be called 
directly over importlib.import_module().

--
nosy: +ncoghlan

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15434
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15434] __import__() problem in 3.3

2012-07-23 Thread Chris Jerdonek

Changes by Chris Jerdonek chris.jerdo...@gmail.com:


--
nosy: +cjerdonek

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15434
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15434] __import__() problem in 3.3

2012-07-23 Thread Stefan Krah

Stefan Krah stefan-use...@bytereef.org added the comment:

Argh. __init__.py was missing in the top directory. For some reason
Python 3.2 does not throw the error. Also, 3.3 does not raise in the
case of the a/b directory structure:

$ tree a
a
`-- b
|-- __init__.py
`-- xyz.py

$ ~/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']


With the added __init__.py, also the (fake) distutils package is OK:


$ tree distutils/
distutils/
|-- __init__.py
`-- command
|-- __init__.py
`-- xyz.py


$ ~/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']




Brett, if this all looks good to you, this issue can be closed. The
original NumPy build error must be due to something else.

Perhaps 3.3 should raise in the a/b case, too?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15434
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15434] __import__() problem in 3.3

2012-07-23 Thread Brett Cannon

Brett Cannon br...@python.org added the comment:

The a/b case is legitimate in Python 3.3; namespace packages are delineated by 
not defining an __init__.py file. Closing as invalid.

--
resolution:  - invalid
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15434
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com