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

SourceForge.net noreply at sourceforge.net
Fri Aug 20 17:39:50 CEST 2004


Bugs item #940578, was opened at 2004-04-23 11:07
Message generated for change (Comment added) made by jlgijsbers
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: Johannes Gijsbers (jlgijsbers)
Date: 2004-08-20 17:39

Message:
Logged In: YES 
user_id=469548

I think that question was directed at me (Raymond assigned
the bug to me).  Well, I didn't... yet. I've added a comment
to #941486.

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

Comment By: Cherniavsky Beni (cben)
Date: 2004-08-20 13:35

Message:
Logged In: YES 
user_id=36166

What do you mean?  Patch 941486 is there a long time
already.  Commit it (choose between the minimal fix and the
more proper introduction of `os.path.lexists()`) and it'll
be fixed.
Then you could add patch 943206 if you like ;-).
And I've refreshed both to apply cleanly against current trunk.


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

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

Message:
Logged In: YES 
user_id=80475

Did you already fix this one?

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

Comment By: Cherniavsky Beni (cben)
Date: 2004-04-24 22: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