Eric V. Smith wrote:
On 6/8/2012 6:41 PM, Ethan Furman wrote:
Dan Stromberg wrote:
On Fri, Jun 8, 2012 at 3:16 PM, Ethan Furman wrote:
Dan Stromberg wrote:
Did the import semantics change in cpython 3.3a4?
I used to be able to import treap.py even though I had a treap
directory in my cwd. With 3.3a4, I have to rename the treap
directory to see treap.py.
Check out PEP 420 -- Implicit Namespace Packages
[http://www.python.org/dev/peps/pep-0420/]
Am I misinterpreting this? It seems like according to the PEP, I
should have still been able to import treap.py despite having a
treap/. But I couldn't; I had to rename treap/ to treap-dir/ first.
During import processing, the import machinery will continue to
iterate over each directory in the parent path as it does in Python
3.2. While looking for a module or package named "foo", for each
directory in the parent path:
* If <directory>/foo/__init__.py is found, a regular package is
imported and returned.
* If not, but <directory>/foo.{py,pyc,so,pyd} is found, a module
is imported and returned. The exact list of extension varies
by platform and whether the -O flag is specified. The list
here is representative.
* If not, but <directory>/foo is found and is a directory, it is
recorded and the scan continues with the next directory in the
parent path.
* Otherwise the scan continues with the next directory in the
parent path.
I do not understand PEP 420 well enough to say if this is intentional or
a bug -- thoughts?
I missed the beginning of this discussion and I need some more details.
What directories are on sys.path, where do treap.py and treap/ appear in
them, and is there an __init__.py in treap? At first blush it sounds
like it should continue working.
If you (Dan?) could re-create this in a small example and open a bug,
that would be great.
Eric.
--
http://mail.python.org/mailman/listinfo/python-list