This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Subtle bug in os.path.realpath on Cygwin
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: anadelonbrin, edemaine, loewis, sjoerd
Priority: normal Keywords:

Created on 2003-07-09 12:38 by edemaine, last changed 2022-04-10 16:09 by admin. This issue is now closed.

Messages (4)
msg16982 - (view) Author: Erik Demaine (edemaine) Date: 2003-07-09 12:38
Cygwin allows mounting directories within other mount
points.  This can cause os.path.realpath to expand some
symlinks that it shouldn't.  For example:

$ cd /
$ mkdir X
$ mkdir X/Y
$ ln -s X Z
$ mount C:/ /Z/Y
$ ls Z/Y
[...contents of C:\...]
$ ls X/Y
[empty directory]

$ python -c "import os; print os.path.realpath('Z/Y')"
/X/Y
[bad because /X/Y is empty yet the original Z/Y has files]

In Cygwin, the correct answer would be either 'C:\\' or
'/cygdrive/c/'.

Conceivably this problem can happen in UNIces other
than Cygwin.  It would be rather annoying to fix,
because it would require looking at the mount table. 
But I thought I would mention it anyway...
msg16983 - (view) Author: Sjoerd Mullender (sjoerd) * (Python committer) Date: 2003-07-09 13:33
Logged In: YES 
user_id=43607

I'd think this is rather a Cygwin bug than a Python bug.

Before the mount, /X/Y and /Z/Y refer to the same directory,
and on Unix they have the same device/inode combination. 
And that combination is the all-important factor when doing
a mount on that directory.
If you do this on Unix (I used an NFS mount instead of the
mount shown in the report), both /X/Y and /Z/Y contain the
mounted directory.
msg16984 - (view) Author: Tony Meyer (anadelonbrin) Date: 2005-01-30 23:57
Logged In: YES 
user_id=552329

I agree with Sjoerd - this is a Cygwin bug, not a Python one.
msg16985 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2005-03-03 09:52
Logged In: YES 
user_id=21627

Closing as suggested.
History
Date User Action Args
2022-04-10 16:09:53adminsetgithub: 38825
2003-07-09 12:38:08edemainecreate