Title: absolute imports treated as relative
Type: behaviour Severity: minor
Components: Core Versions: 2.5.1
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: fwierzbicki Nosy List: akruis, fwierzbicki, tanketz, zyasoft
Priority: Keywords:

Created on 2009-12-06.13:18:14 by tanketz, last changed 2010-08-24.13:16:19 by zyasoft.

msg5353 (view) Author: Dan Getz (tanketz) Date: 2009-12-06.13:18:13
In at least one situation, absolute imports will be treated as relative
imports. Short example that fails with both the standard and standalone
2.5.1 installations:


from __future__ import absolute_import
import socket as m
print m

from abc import socket

By my understanding of PEP 328, module abc.socket ought to import the
library module socket as m.

in "jythondir", running module abc.def has different results for CPython
2.5.1 and Jython 2.5.1:
$ python2.5 -m abc.def
<module 'socket' from '/usr/lib/python2.5/socket.pyc'>
$ ./jython -m abc.def
<module 'abc.socket' from 'abc/socket$py.class'>
$ java -jar jython.jar -m abc.def
<module 'abc.socket' from 'abc/socket$py.class'>

Note that if abc.socket is run as a module instead of imported from
another, CPython and Jython act the same (thus Jython treats the import
in abc.socket differently, without changing any code in that module.)
$ python2.5 -m abc.socket
<module 'socket' from '/usr/lib/python2.5/socket.pyc'>
$ ./jython -m abc.socket
<module 'socket' from 'jythondir/Lib/socket$py.class'>
$ java -jar jython.jar -m abc.socket
<module 'socket' from 'jythondir/Lib/socket$py.class'>
msg6010 (view) Author: Anselm Kruis (akruis) Date: 2010-08-24.07:43:07
Please see #1648 for a patch.
msg6014 (view) Author: Jim Baker (zyasoft) Date: 2010-08-24.13:16:19
Superseded by #1648 and fixed in r7102
Date User Action Args
2010-08-24 13:16:19zyasoftsetstatus: open -> closed
resolution: fixed
messages: + msg6014
nosy: + zyasoft
2010-08-24 07:43:07akruissetnosy: + akruis
messages: + msg6010
2009-12-06 16:45:51fwierzbickisetassignee: fwierzbicki
nosy: + fwierzbicki
2009-12-06 13:18:14tanketzcreate