[ python-Bugs-940578 ] glob.glob inconsistent about broken symlinks

SourceForge.net noreply at sourceforge.net
Thu Aug 19 19:45:19 CEST 2004


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

Category: Python Library
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Cherniavsky Beni (cben)
>Assigned to: Johannes Gijsbers (jlgijsbers)
Summary: glob.glob inconsistent about broken symlinks

Initial Comment:
`glob.glob()` uses `os.listdir()`, which includes
borken symlinks in the listing if the pattern contains
shell metacharacters but 
uses `os.path.exists()` which is False for broken
symlinks if the pattern is a fixed name.  Thus:

>>> os.symlink('broken', 'sym1')
>>> os.symlink('broken', 'sym2')
>>> import glob
>>> glob.glob('sym*')
['sym1', 'sym2']
>>> glob.glob('sym1')
[]
>>> glob.glob('sym2')
[]


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

>Comment By: Raymond Hettinger (rhettinger)
Date: 2004-08-19 12:45

Message:
Logged In: YES 
user_id=80475

Did you already fix this one?

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

Comment By: Cherniavsky Beni (cben)
Date: 2004-04-24 15:32

Message:
Logged In: YES 
user_id=36166

This bug exists in all versions of the module since its
creation up to 2.4.

The correct behaviour (judging by the shell's behaviour -
that's the model for the module, isn't it), is to always
include  broken symlinks in the results.

Several fixes for this bug are provided by patch 941486
(http://python.org/sf/941486).  
[They all include the testcase attached here.]

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

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


More information about the Python-bugs-list mailing list