Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
c4dcde6e
Commit
c4dcde6e
authored
Dec 16, 2012
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #16696: fix comparison between bytes and string. Also, improve glob tests.
parent
c18d7005
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
6 deletions
+29
-6
Lib/glob.py
Lib/glob.py
+1
-1
Lib/test/test_glob.py
Lib/test/test_glob.py
+28
-5
No files found.
Lib/glob.py
View file @
c4dcde6e
...
...
@@ -63,7 +63,7 @@ def glob1(dirname, pattern):
return
fnmatch
.
filter
(
names
,
pattern
)
def
glob0
(
dirname
,
basename
):
if
basename
==
''
:
if
not
basename
:
# `os.path.split()` returns an empty basename for paths ending with a
# directory separator. 'q*x/' should match only directories.
if
os
.
path
.
isdir
(
dirname
):
...
...
Lib/test/test_glob.py
View file @
c4dcde6e
...
...
@@ -97,12 +97,35 @@ class GlobTests(unittest.TestCase):
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
)
# Patterns ending with a slash shouldn't match non-dirs
res
=
glob
.
glob
(
os
.
path
.
join
(
self
.
tempdir
,
'Z*Z'
)
+
os
.
sep
)
self
.
assertEqual
(
res
,
[])
res
=
glob
.
glob
(
os
.
path
.
join
(
self
.
tempdir
,
'ZZZ'
)
+
os
.
sep
)
self
.
assertEqual
(
res
,
[])
# When there is wildcard pattern which ends with os.sep, glob()
# doesn't blow up.
res
=
glob
.
glob
(
os
.
path
.
join
(
self
.
tempdir
,
'aa*'
)
+
os
.
sep
)
self
.
assertEqual
(
len
(
res
),
2
)
# either of these results are reasonable
self
.
assertIn
(
res
[
0
],
[
self
.
tempdir
,
self
.
tempdir
+
os
.
sep
])
self
.
assertIn
(
set
(
res
),
[
{
self
.
norm
(
'aaa'
),
self
.
norm
(
'aab'
)},
{
self
.
norm
(
'aaa'
)
+
os
.
sep
,
self
.
norm
(
'aab'
)
+
os
.
sep
},
])
def
test_glob_bytes_directory_with_trailing_slash
(
self
):
# Same as test_glob_directory_with_trailing_slash, but with a
# bytes argument.
res
=
glob
.
glob
(
os
.
fsencode
(
os
.
path
.
join
(
self
.
tempdir
,
'Z*Z'
)
+
os
.
sep
))
self
.
assertEqual
(
res
,
[])
res
=
glob
.
glob
(
os
.
fsencode
(
os
.
path
.
join
(
self
.
tempdir
,
'ZZZ'
)
+
os
.
sep
))
self
.
assertEqual
(
res
,
[])
res
=
glob
.
glob
(
os
.
fsencode
(
os
.
path
.
join
(
self
.
tempdir
,
'aa*'
)
+
os
.
sep
))
self
.
assertEqual
(
len
(
res
),
2
)
# either of these results are reasonable
self
.
assertIn
({
os
.
fsdecode
(
x
)
for
x
in
res
},
[
{
self
.
norm
(
'aaa'
),
self
.
norm
(
'aab'
)},
{
self
.
norm
(
'aaa'
)
+
os
.
sep
,
self
.
norm
(
'aab'
)
+
os
.
sep
},
])
@
skip_unless_symlink
def
test_glob_broken_symlinks
(
self
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment