[issue27543] from module import function creates package reference to the module

2016-07-18 Thread R. David Murray
R. David Murray added the comment: Note that conceptually this is closely related to issue 27515. In both cases the conceptual problem (the thing that trips up user expectations) is that what import does to the namespaces differs depending on whether the base module exists in sys.modules or

[issue27543] from module import function creates package reference to the module

2016-07-17 Thread Brett Cannon
Brett Cannon added the comment: So the problem is that you doing `from .a import test` and not `from . import a; test = a.test`. Whenever you do `from X import Y`, import actually imports X. Since X wasn't in sys.modules, it performs a proper import which means it sets the attribute on the

[issue27543] from module import function creates package reference to the module

2016-07-17 Thread R. David Murray
R. David Murray added the comment: The same example can be constructed for python3 by modifying the imports. I think what is happening here is that if a has not yet been imported, then when 'from .a import test' is done, the import machinery loads a and then defines 'a' in the local

[issue27543] from module import function creates package reference to the module

2016-07-17 Thread Brett Cannon
Brett Cannon added the comment: I'm not at a computer where I can verify what you're seeing, Marc,but I should mention that at least for Python 3 your imports are wrong as you should be doing relative imports, e.g. `from . import b as a`, otherwise the imports won't work unless you're

[issue27543] from module import function creates package reference to the module

2016-07-17 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- nosy: +brett.cannon, eric.snow, ncoghlan ___ Python tracker ___

[issue27543] from module import function creates package reference to the module

2016-07-17 Thread Marc
New submission from Marc: Hello, I've found an issue in python 2.7 and 3.4 and I don't if this is a bug or a feature that acts strange to me. The import of a module or method from a module creates a reference in the package to that module only the first time, which could lead to unexpected