[ python-Bugs-930024 ] os.path.realpath can't handle symlink loops

SourceForge.net noreply at sourceforge.net
Mon Aug 2 12:20:12 CEST 2004


Bugs item #930024, was opened at 2004-04-05 22:59
Message generated for change (Comment added) made by loewis
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=930024&group_id=5470

Category: Python Library
Group: Python 2.4
>Status: Open
Resolution: Fixed
>Priority: 7
Submitted By: A.M. Kuchling (akuchling)
Assigned to: Nobody/Anonymous (nobody)
Summary: os.path.realpath can't handle symlink loops

Initial Comment:
Create a symlink pointing to itself:

ln -s infinite infinite

Run os.path.realpath() on it, and it recurses
infinitely (until the stack limit is hit):

>>> import os
>>> os.path.realpath('/home/amk/infinite')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.3/posixpath.py", line 416, in
realpath
    return realpath(newpath)

os.path.realpath() should be fixed; /home/amk/infinite
is a perfectly good path, though it can't be followed.


----------------------------------------------------------------------

>Comment By: Martin v. Löwis (loewis)
Date: 2004-08-02 12:20

Message:
Logged In: YES 
user_id=21627

The code that has been committed is incorrect if the link to
be resolved is relative.  _resolve_link uses abspath to
determine whether the link is absolute. This function
returns an absolute path (possibly using getcwd); the
function that should have been used is isabs().

----------------------------------------------------------------------

Comment By: Brett Cannon (bcannon)
Date: 2004-07-11 00:59

Message:
Logged In: YES 
user_id=357491

Applied as rev. 1.67 in 2.4a2 and rev. 1.62.6.2 in 2.3.5 with only minor 
cleanup.

----------------------------------------------------------------------

Comment By: A.M. Kuchling (akuchling)
Date: 2004-06-05 20:58

Message:
Logged In: YES 
user_id=11375

Patch attached; review requested.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=930024&group_id=5470


More information about the Python-bugs-list mailing list