Message5353
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:
jythondir/abc/__init__.py
(empty)
jythondir/abc/socket.py
from __future__ import absolute_import
import socket as m
print m
jythondir/abc/def.py
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'> |
|
Date |
User |
Action |
Args |
2009-12-06 13:18:14 | tanketz | set | recipients:
+ tanketz |
2009-12-06 13:18:14 | tanketz | set | messageid: <1260105494.43.0.714324090411.issue1516@psf.upfronthosting.co.za> |
2009-12-06 13:18:14 | tanketz | link | issue1516 messages |
2009-12-06 13:18:13 | tanketz | create | |
|