diff options
Diffstat (limited to 'Lib/glob.py')
-rw-r--r-- | Lib/glob.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/Lib/glob.py b/Lib/glob.py index 95656cc..75d7bf9 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,16 @@ 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() or + sys.getdefaultencoding()) 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 == '': |