diff options
author | Georg Brandl <georg@python.org> | 2007-03-07 08:31:51 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2007-03-07 08:31:51 (GMT) |
commit | 71ff64674375b355c9449f8b511b49756d880e48 (patch) | |
tree | 5e38f0cbe2602c4fe59a935e830ef432ee51c785 /Lib/glob.py | |
parent | 172e7257f65e5d37974aacf0c467e76a321ddf2c (diff) | |
download | cpython-71ff64674375b355c9449f8b511b49756d880e48.zip cpython-71ff64674375b355c9449f8b511b49756d880e48.tar.gz cpython-71ff64674375b355c9449f8b511b49756d880e48.tar.bz2 |
Patch #1001604: glob.glob() now returns unicode filenames if it was
given a unicode argument and os.listdir() returns unicode filenames.
Diffstat (limited to 'Lib/glob.py')
-rw-r--r-- | Lib/glob.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Lib/glob.py b/Lib/glob.py index 95656cc..a92b11f 100644 --- a/Lib/glob.py +++ b/Lib/glob.py @@ -1,8 +1,9 @@ """Filename globbing utility.""" +import sys import os -import fnmatch import re +import fnmatch __all__ = ["glob", "iglob"] @@ -48,13 +49,15 @@ def iglob(pathname): def glob1(dirname, pattern): if not dirname: dirname = os.curdir + if isinstance(pattern, unicode) and not isinstance(dirname, unicode): + dirname = unicode(dirname, sys.getfilesystemencoding()) try: names = os.listdir(dirname) except os.error: return [] - if pattern[0]!='.': - names=filter(lambda x: x[0]!='.',names) - return fnmatch.filter(names,pattern) + if pattern[0] != '.': + names = filter(lambda x: x[0] != '.', names) + return fnmatch.filter(names, pattern) def glob0(dirname, basename): if basename == '': |