Issue645615

classification
Title: cannot import through symbolic links
Type: behaviour Severity: normal
Components: Core Versions:
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: fwierzbicki Nosy List: fwierzbicki, leouserz, lmjohns3
Priority: high Keywords:

Created on 2002-11-29.10:15:50 by lmjohns3, last changed 2009-07-16.00:42:39 by fwierzbicki.

Messages
msg794 (view) Author: Leif Johnson (lmjohns3) Date: 2002-11-29.10:15:50
I am working on an i686 GNU/Linux system with Sun's JDK
1.4.1, Python 2.2.2, and Jython 2.1.

I have written a Jython package that I wish to test
before installing. The file structure is generally as
follows :

work/
+ __init__.py
+ mysubpackage/
|  + __init__.py
|  ` mysubmodule.py
+ otherdir1/
` otherdir2/

(Sorry for the bad ASCII art ; I hope you can read the
structure anyway.) I want to import the package rooted
at "work" under the name "mypackage". The mypackage
init script essentially just imports the underlying
subpackage ; that is, work/__init__.py contains "from
mysubpackage import *". Using CPython I can do the
following :

$ cd work
$ ln -s . mypackage
$ python
Python 2.2.2 (#1, Nov 21 2002, 08:18:14) 
[GCC 2.95.4 20011002 (Debian prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for
more information.
>>> import mypackage
>>>

But if I try the same with jython, here is what I get :

$ cd work
$ ln -s . mypackage
$ jython
Jython 2.1 on java1.4.1 (JIT: null)
Type "copyright", "credits" or "license" for more
information.
>>> import mypackage
Traceback (innermost last):
  File "<console>", line 1, in ?
ImportError: no module named mypackage
>>>

If, instead, I physically copy all the appropriate
source files to a physical directory called
"mypackage", then the import works fine with both
standard Python and Jython.

I hope this helps!
msg795 (view) Author: Deleted User leouserz (leouserz) Date: 2007-01-15.18:10:28
yup, it appears that its this method:
 public static boolean caseok(File file, String filename, int namelen) {


in "imp".  What is happening is that file is being changed to the canonical file.  The end result is that the caseok does not return true.  Altering it so that it does alows the link to work.  Im not sure what the right logic is here, there doesn't appear to be good way to decide if something is a link or not.  At least there is a code location to target now...
msg796 (view) Author: Deleted User leouserz (leouserz) Date: 2007-01-15.18:25:32
caseok looks like it showed up in r1635, and it was added according to the comments:
'Support for case sensitive imports on case-ignoring filesystem
(like windows).'
msg4893 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2009-07-10.01:06:02
Incompatibility with CPython, we should really take a look at this for
2.5.1.  Also it's ridiculously old.
msg4910 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2009-07-16.00:42:39
Fixed in r6536
History
Date User Action Args
2009-07-16 00:42:39fwierzbickisetstatus: open -> closed
resolution: accepted -> fixed
messages: + msg4910
2009-07-10 02:26:06fwierzbickisetassignee: fwierzbicki
2009-07-10 01:06:33fwierzbickisettype: behaviour
2009-07-10 01:06:18fwierzbickisetresolution: accepted
2009-07-10 01:06:02fwierzbickisetpriority: low -> high
messages: + msg4893
2009-03-03 17:56:16fwierzbickisetnosy: + fwierzbicki
2002-11-29 10:15:50lmjohns3create