[issue16618] Different glob() results for strings and bytes

Serhiy Storchaka report at bugs.python.org
Sun Dec 16 20:13:53 CET 2012


Serhiy Storchaka added the comment:

Patches updated. Unrelated changes removed.

----------
Added file: http://bugs.python.org/file28335/glob_dotfiles_2.patch
Added file: http://bugs.python.org/file28336/glob_tests-2.7_2.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16618>
_______________________________________
-------------- next part --------------
diff -r 2d2d4807a3ed Lib/glob.py
--- a/Lib/glob.py	Sun Dec 16 16:40:22 2012 +0100
+++ b/Lib/glob.py	Sun Dec 16 21:10:24 2012 +0200
@@ -57,8 +57,8 @@
         names = os.listdir(dirname)
     except os.error:
         return []
-    if pattern[0] != '.':
-        names = [x for x in names if x[0] != '.']
+    if not _ishidden(pattern):
+        names = [x for x in names if not _ishidden(x)]
     return fnmatch.filter(names, pattern)
 
 def glob0(dirname, basename):
@@ -82,3 +82,6 @@
     else:
         match = magic_check.search(s)
     return match is not None
+
+def _ishidden(path):
+    return path[0] in ('.', b'.'[0])


More information about the Python-bugs-list mailing list