mirror of
https://github.com/python/cpython.git
synced 2025-09-10 02:36:56 +00:00
glob('anything*/') would fail because isdir is in os.path, not os.
This commit is contained in:
parent
e0bb597d03
commit
a31bf18c48
3 changed files with 11 additions and 1 deletions
|
@ -60,7 +60,7 @@ def glob0(dirname, basename):
|
||||||
if basename == '':
|
if basename == '':
|
||||||
# `os.path.split()` returns an empty basename for paths ending with a
|
# `os.path.split()` returns an empty basename for paths ending with a
|
||||||
# directory separator. 'q*x/' should match only directories.
|
# directory separator. 'q*x/' should match only directories.
|
||||||
if os.isdir(dirname):
|
if os.path.isdir(dirname):
|
||||||
return [basename]
|
return [basename]
|
||||||
else:
|
else:
|
||||||
if os.path.lexists(os.path.join(dirname, basename)):
|
if os.path.lexists(os.path.join(dirname, basename)):
|
||||||
|
|
|
@ -80,6 +80,14 @@ class GlobTests(unittest.TestCase):
|
||||||
eq(self.glob('?a?', '*F'), map(self.norm, [os.path.join('aaa', 'zzzF'),
|
eq(self.glob('?a?', '*F'), map(self.norm, [os.path.join('aaa', 'zzzF'),
|
||||||
os.path.join('aab', 'F')]))
|
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):
|
def test_glob_broken_symlinks(self):
|
||||||
if hasattr(os, 'symlink'):
|
if hasattr(os, 'symlink'):
|
||||||
eq = self.assertSequencesEqual_noorder
|
eq = self.assertSequencesEqual_noorder
|
||||||
|
|
|
@ -20,6 +20,8 @@ Extension Modules
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Fix exception when doing glob.glob('anything*/')
|
||||||
|
|
||||||
Build
|
Build
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue