[issue24530] `import..as` fails where `import` does not

2015-06-29 Thread Dustin J. Mitchell

New submission from Dustin J. Mitchell:

Reproduction:

# main.py
import foo.bar

# foo/__init__.py
# (empty)

# foo/bar/__init__.py
import foo.bar.bing as bing

# foo/bar/bing.py
# (empty)

Result:

dustin@euclid ~/tmp $ python3.3 main.py 
Traceback (most recent call last):
  File main.py, line 1, in module
import foo.bar
  File /home/dustin/tmp/foo/bar/__init__.py, line 1, in module
import foo.bar.bing as bing
AttributeError: 'module' object has no attribute 'bar'

dustin@euclid ~/tmp $ python2.7 main.py 
Traceback (most recent call last):
  File main.py, line 1, in module
import foo.bar
  File /home/dustin/tmp/foo/bar/__init__.py, line 1, in module
import foo.bar.bing as bing
AttributeError: 'module' object has no attribute 'bar'

If you remove the `as bing` from `foo/bar/__init__.py`, all is well.  
Similarly, `from foo.bar import bing` works fine, as does `from foo.bar import 
bing as bing`.

I don't see anything in 
https://docs.python.org/3/reference/simple_stmts.html#import that suggests this 
is expected behavior.

--
components: Interpreter Core
messages: 245941
nosy: djmitche
priority: normal
severity: normal
status: open
title: `import..as` fails where `import` does not
type: behavior
versions: Python 2.7, Python 3.3

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



[issue24530] `import..as` fails where `import` does not

2015-06-29 Thread R. David Murray

R. David Murray added the comment:

I'm pretty sure this has already been reported, but I have no idea how to 
search for the issue :)  If I remember correctly there's a doc patch, so I 
suppose it hasn't been applied.  But I could be misremembering.

--
nosy: +brett.cannon, eric.snow, r.david.murray

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



[issue24530] `import..as` fails where `import` does not

2015-06-29 Thread Martin Panter

Martin Panter added the comment:

Maybe Issue 23203, proposing to fix the compiled bytecode.

--
nosy: +vadmium
resolution:  - duplicate
stage:  - resolved
status: open - closed
superseder:  - Aliasing import of sub-{module,package} from the package raises 
AttributeError on import.

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



[issue24530] `import..as` fails where `import` does not

2015-06-29 Thread R. David Murray

R. David Murray added the comment:

Ah, yes, that is the issue I was thinking of.  So, bug, not doc issue :)

--

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