[Python-bugs-list] [ python-Bugs-409651 ] fnmatch doesn't escape '\' between [...]

noreply@sourceforge.net noreply@sourceforge.net
Sun, 18 Mar 2001 21:07:01 -0800


Bugs item #409651, was updated on 2001-03-18 21:07
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=409651&group_id=5470

Category: Python Library
Group: None
Status: Open
Priority: 5
Submitted By: Donovan Baarda (abo)
Assigned to: Nobody/Anonymous (nobody)
Summary: fnmatch doesn't escape '\' between [...]

Initial Comment:
The translate() function inside fnmatch doesn't 
escape '\' chars between '[' and ']' brackets when 
converting unix filename wildcards to a regular 
expression.

This means the '\' character behaves strangely when 
inside '['...']' or '[^'...']'. Depending on the 
character that follows, it can be interpreted in a 
wild variety of ways, including escaping the 
closing ']' and failing the re.compile. This was 
encountered when using fnmatch on windoze where 
os.sep='\'. Note that the docs say os.sep is not 
treated specially by fnmatch.

The fix required is to escape '\' in 'stuff' inside 
translate(). This is easiest done using stuff.replace
('\','\\'). A patch is attached...

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

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