Issue1495

classification
Title: Problem with relative imports from __init__.py
Type: Severity: normal
Components: Core Versions: 2.5.1
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: akruis, bpedman, noamr, zyasoft
Priority: Keywords:

Created on 2009-10-26.17:57:22 by noamr, last changed 2010-08-24.13:16:39 by zyasoft.

Messages
msg5264 (view) Author: Noam Yorav-Raphael (noamr) Date: 2009-10-26.17:57:21
Hello,

To reproduce this bug, create 3 files (and the directories to hold them):

package/__init__.py (empty)
package/subpackage1/__init__.py:
  print 'subpackage1 imported.'
  print 'importing subpackage2'
  from .. import subpackage2
package/subpackage2/__init__.py:
  print 'subpackage2 imported.'

Then, run:
> python -c 'import package.subpackage1'
subpackage1 imported.
importing subpackage2
subpackage2 imported.

> jython -c 'import package.subpackage1'
subpackage1 imported.
importing subpackage2
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "package/subpackage1/__init__.py", line 3, in <module>
    from .. import subpackage2
ImportError: cannot import name subpackage2

Thanks,
Noam
msg5265 (view) Author: Brandon (bpedman) Date: 2009-10-26.18:15:03
I am seeing this as well
msg6011 (view) Author: Anselm Kruis (akruis) Date: 2010-08-24.07:44:12
Please see #1648 for a patch.
msg6015 (view) Author: Jim Baker (zyasoft) Date: 2010-08-24.13:16:39
Superseded by #1648 and fixed in r7102
History
Date User Action Args
2010-08-24 13:16:39zyasoftsetstatus: open -> closed
resolution: fixed
messages: + msg6015
nosy: + zyasoft
2010-08-24 07:44:12akruissetnosy: + akruis
messages: + msg6011
2009-10-26 18:15:03bpedmansetnosy: + bpedman
messages: + msg5265
2009-10-26 17:57:22noamrcreate