From: Neal Norwitz Date: Sun, 9 Apr 2006 03:35:43 +0000 (+0000) Subject: glob('anything*/') would fail because isdir is in os.path, not os. X-Git-Tag: v2.5a2~388 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a31bf18c48654640b7020e8900928f9db862a1a5;p=thirdparty%2FPython%2Fcpython.git glob('anything*/') would fail because isdir is in os.path, not os. --- diff --git a/Lib/glob.py b/Lib/glob.py index ecc6d2593106..95656cc1a6dd 100644 --- a/Lib/glob.py +++ b/Lib/glob.py @@ -60,7 +60,7 @@ def glob0(dirname, basename): if basename == '': # `os.path.split()` returns an empty basename for paths ending with a # directory separator. 'q*x/' should match only directories. - if os.isdir(dirname): + if os.path.isdir(dirname): return [basename] else: if os.path.lexists(os.path.join(dirname, basename)): diff --git a/Lib/test/test_glob.py b/Lib/test/test_glob.py index 8a6ef7fada37..5ce09f9d10d3 100644 --- a/Lib/test/test_glob.py +++ b/Lib/test/test_glob.py @@ -80,6 +80,14 @@ class GlobTests(unittest.TestCase): eq(self.glob('?a?', '*F'), map(self.norm, [os.path.join('aaa', 'zzzF'), os.path.join('aab', 'F')])) + def test_glob_directory_with_trailing_slash(self): + # We are verifying that when there is wildcard pattern which + # ends with os.sep doesn't blow up. + res = glob.glob(self.tempdir + '*' + os.sep) + self.assertEqual(len(res), 1) + # either of these results are reasonable + self.assertTrue(res[0] in [self.tempdir, self.tempdir + os.sep]) + def test_glob_broken_symlinks(self): if hasattr(os, 'symlink'): eq = self.assertSequencesEqual_noorder diff --git a/Misc/NEWS b/Misc/NEWS index 266b6c9d7013..b7f46ba13437 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -20,6 +20,8 @@ Extension Modules Library ------- +- Fix exception when doing glob.glob('anything*/') + Build -----