Issue1973

classification
Title: "from . import *" does not work
Type: Severity: critical
Components: Versions: Jython 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: zyasoft Nosy List: Arfrever, fwierzbicki, tkanerva, zyasoft
Priority: normal Keywords: patch

Created on 2012-09-29.23:51:02 by Arfrever, last changed 2014-06-02.01:32:22 by Arfrever.

Files
File name Uploaded Description Edit Remove
relstarimport.patch tkanerva, 2014-03-07.11:13:18 Proposed patch for relative star import issue
Messages
msg7467 (view) Author: Arfrever Frehtes Taifersar Arahesis (Arfrever) Date: 2012-09-29.23:51:01
This syntax works in CPython >=2.6.

$ cd /tmp
$ mkdir test
$ touch test/__init__.py
$ echo "from . import *" > test/x.py
$ python2.7 -c 'import test.x'
$ jython2.7 -c 'import test.x'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "test/x.py", line 1
SyntaxError: 'import *' not allowed with 'from .'
$
msg7468 (view) Author: Arfrever Frehtes Taifersar Arahesis (Arfrever) Date: 2012-09-29.23:58:58
(And "from .module import *" also needs to be supported.)
msg8247 (view) Author: topi kanerva (tkanerva) Date: 2014-03-07.11:13:17
the fix is fairly simple though: I just removed the check that results in SyntaxError exception being thrown, and the remaining code path takes care of the import (I checked that I got the right results when trying to use that relative import)

evidently that check was added to mirror python 2.5's behaviour. Later, in 2.6, this restriction was lifted and Guido does not remember why it was there originally.
msg8290 (view) Author: Jim Baker (zyasoft) Date: 2014-04-16.19:17:20
Fixed in r7205
msg8291 (view) Author: Arfrever Frehtes Taifersar Arahesis (Arfrever) Date: 2014-04-17.20:07:14
http://hg.python.org/jython/rev/83a4f55711aa
msg8318 (view) Author: Jim Baker (zyasoft) Date: 2014-05-04.19:40:16
Per discussion on #jython just now
msg8591 (view) Author: Arfrever Frehtes Taifersar Arahesis (Arfrever) Date: 2014-06-02.01:32:22
(Issue #2158 describes other bugs in handling of relative, star imports.)
History
Date User Action Args
2014-06-02 01:32:22Arfreversetmessages: + msg8591
2014-05-04 19:40:17zyasoftsetstatus: pending -> closed
messages: + msg8318
2014-04-17 20:07:14Arfreversetmessages: + msg8291
2014-04-16 19:17:20zyasoftsetstatus: open -> pending
resolution: accepted -> fixed
messages: + msg8290
2014-04-03 18:27:33zyasoftsetassignee: fwierzbicki -> zyasoft
resolution: accepted
nosy: + zyasoft
2014-03-07 11:13:18tkanervasetfiles: + relstarimport.patch
keywords: + patch
messages: + msg8247
severity: normal -> critical
nosy: + tkanerva
2013-02-26 18:34:25fwierzbickisetpriority: normal
assignee: fwierzbicki
nosy: + fwierzbicki
versions: + Jython 2.7
2012-09-29 23:58:58Arfreversetmessages: + msg7468
2012-09-29 23:51:02Arfrevercreate