]> granicus.if.org Git - python/commitdiff
glob('anything*/') would fail because isdir is in os.path, not os.
authorNeal Norwitz <nnorwitz@gmail.com>
Sun, 9 Apr 2006 03:35:43 +0000 (03:35 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Sun, 9 Apr 2006 03:35:43 +0000 (03:35 +0000)
Lib/glob.py
Lib/test/test_glob.py
Misc/NEWS

index ecc6d2593106dcc73366d3c56700d2c3c2920888..95656cc1a6dd3657de543d6ec5c479b2d4e10370 100644 (file)
@@ -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)):
index 8a6ef7fada370d5442447ff52e7bb15bbb86efa5..5ce09f9d10d3390f25d15dba7f5542b398e38653 100644 (file)
@@ -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
index 266b6c9d70134645c25eba47af86902b01005d35..b7f46ba1343744b4b439be38d71dcca287859421 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -20,6 +20,8 @@ Extension Modules
 Library
 -------
 
+- Fix exception when doing glob.glob('anything*/')
+
 Build
 -----