Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
735b790f
Kaydet (Commit)
735b790f
authored
Kas 09, 2015
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #25584: Fixed recursive glob() with patterns starting with '**'.
üst
f9827ea6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
10 deletions
+26
-10
glob.py
Lib/glob.py
+9
-4
test_glob.py
Lib/test/test_glob.py
+15
-6
NEWS
Misc/NEWS
+2
-0
No files found.
Lib/glob.py
Dosyayı görüntüle @
735b790f
...
...
@@ -30,6 +30,13 @@ def iglob(pathname, *, recursive=False):
If recursive is true, the pattern '**' will match any files and
zero or more directories and subdirectories.
"""
it
=
_iglob
(
pathname
,
recursive
)
if
recursive
and
_isrecursive
(
pathname
):
s
=
next
(
it
)
# skip empty string
assert
not
s
return
it
def
_iglob
(
pathname
,
recursive
):
dirname
,
basename
=
os
.
path
.
split
(
pathname
)
if
not
has_magic
(
pathname
):
if
basename
:
...
...
@@ -50,7 +57,7 @@ def iglob(pathname, *, recursive=False):
# drive or UNC path. Prevent an infinite recursion if a drive or UNC path
# contains magic characters (i.e. r'\\?\C:').
if
dirname
!=
pathname
and
has_magic
(
dirname
):
dirs
=
iglob
(
dirname
,
recursive
=
recursive
)
dirs
=
_iglob
(
dirname
,
recursive
)
else
:
dirs
=
[
dirname
]
if
has_magic
(
basename
):
...
...
@@ -98,12 +105,10 @@ def glob0(dirname, basename):
def
glob2
(
dirname
,
pattern
):
assert
_isrecursive
(
pattern
)
if
dirname
:
yield
pattern
[:
0
]
yield
pattern
[:
0
]
yield
from
_rlistdir
(
dirname
)
# Recursively yields relative pathnames inside a literal directory.
def
_rlistdir
(
dirname
):
if
not
dirname
:
if
isinstance
(
dirname
,
bytes
):
...
...
Lib/test/test_glob.py
Dosyayı görüntüle @
735b790f
...
...
@@ -31,6 +31,7 @@ class GlobTests(unittest.TestCase):
self
.
mktemp
(
'.bb'
,
'H'
)
self
.
mktemp
(
'aaa'
,
'zzzF'
)
self
.
mktemp
(
'ZZZ'
)
self
.
mktemp
(
'EF'
)
self
.
mktemp
(
'a'
,
'bcd'
,
'EF'
)
self
.
mktemp
(
'a'
,
'bcd'
,
'efg'
,
'ha'
)
if
can_symlink
():
...
...
@@ -200,7 +201,7 @@ class GlobTests(unittest.TestCase):
def
test_recursive_glob
(
self
):
eq
=
self
.
assertSequencesEqual_noorder
full
=
[(
'ZZZ'
,),
full
=
[(
'
EF'
,),
(
'
ZZZ'
,),
(
'a'
,),
(
'a'
,
'D'
),
(
'a'
,
'bcd'
),
(
'a'
,
'bcd'
,
'EF'
),
...
...
@@ -217,8 +218,8 @@ class GlobTests(unittest.TestCase):
(
'sym3'
,
'efg'
,
'ha'
),
]
eq
(
self
.
rglob
(
'**'
),
self
.
joins
((
''
,),
*
full
))
eq
(
self
.
rglob
(
'.'
,
'**'
),
self
.
joins
((
'.'
,
'
'
),
*
((
'.'
,)
+
i
for
i
in
full
)))
eq
(
self
.
rglob
(
os
.
curdir
,
'**
'
),
self
.
joins
((
os
.
curdir
,
''
),
*
((
os
.
curdir
,)
+
i
for
i
in
full
)))
dirs
=
[(
'a'
,
''
),
(
'a'
,
'bcd'
,
''
),
(
'a'
,
'bcd'
,
'efg'
,
''
),
(
'aaa'
,
''
),
(
'aab'
,
''
)]
if
can_symlink
():
...
...
@@ -229,11 +230,11 @@ class GlobTests(unittest.TestCase):
(
'a'
,
''
),
(
'a'
,
'D'
),
(
'a'
,
'bcd'
),
(
'a'
,
'bcd'
,
'EF'
),
(
'a'
,
'bcd'
,
'efg'
),
(
'a'
,
'bcd'
,
'efg'
,
'ha'
)))
eq
(
self
.
rglob
(
'a**'
),
self
.
joins
((
'a'
,),
(
'aaa'
,),
(
'aab'
,)))
expect
=
[(
'a'
,
'bcd'
,
'EF'
)]
expect
=
[(
'a'
,
'bcd'
,
'EF'
)
,
(
'EF'
,)
]
if
can_symlink
():
expect
+=
[(
'sym3'
,
'EF'
)]
eq
(
self
.
rglob
(
'**'
,
'EF'
),
self
.
joins
(
*
expect
))
expect
=
[(
'a'
,
'bcd'
,
'EF'
),
(
'aaa'
,
'zzzF'
),
(
'aab'
,
'F'
)]
expect
=
[(
'a'
,
'bcd'
,
'EF'
),
(
'aaa'
,
'zzzF'
),
(
'aab'
,
'F'
)
,
(
'EF'
,)
]
if
can_symlink
():
expect
+=
[(
'sym3'
,
'EF'
)]
eq
(
self
.
rglob
(
'**'
,
'*F'
),
self
.
joins
(
*
expect
))
...
...
@@ -247,10 +248,18 @@ class GlobTests(unittest.TestCase):
eq
(
glob
.
glob
(
'**'
,
recursive
=
True
),
[
join
(
*
i
)
for
i
in
full
])
eq
(
glob
.
glob
(
join
(
'**'
,
''
),
recursive
=
True
),
[
join
(
*
i
)
for
i
in
dirs
])
eq
(
glob
.
glob
(
join
(
'**'
,
'*'
),
recursive
=
True
),
[
join
(
*
i
)
for
i
in
full
])
eq
(
glob
.
glob
(
join
(
os
.
curdir
,
'**'
),
recursive
=
True
),
[
join
(
os
.
curdir
,
''
)]
+
[
join
(
os
.
curdir
,
*
i
)
for
i
in
full
])
eq
(
glob
.
glob
(
join
(
os
.
curdir
,
'**'
,
''
),
recursive
=
True
),
[
join
(
os
.
curdir
,
''
)]
+
[
join
(
os
.
curdir
,
*
i
)
for
i
in
dirs
])
eq
(
glob
.
glob
(
join
(
os
.
curdir
,
'**'
,
'*'
),
recursive
=
True
),
[
join
(
os
.
curdir
,
*
i
)
for
i
in
full
])
eq
(
glob
.
glob
(
join
(
'**'
,
'zz*F'
),
recursive
=
True
),
[
join
(
'aaa'
,
'zzzF'
)])
eq
(
glob
.
glob
(
'**zz*F'
,
recursive
=
True
),
[])
expect
=
[
join
(
'a'
,
'bcd'
,
'EF'
)]
expect
=
[
join
(
'a'
,
'bcd'
,
'EF'
)
,
'EF'
]
if
can_symlink
():
expect
+=
[
join
(
'sym3'
,
'EF'
)]
eq
(
glob
.
glob
(
join
(
'**'
,
'EF'
),
recursive
=
True
),
expect
)
...
...
Misc/NEWS
Dosyayı görüntüle @
735b790f
...
...
@@ -61,6 +61,8 @@ Core and Builtins
Library
-------
-
Issue
#
25584
:
Fixed
recursive
glob
()
with
patterns
starting
with
'\*\*'
.
-
Issue
#
25446
:
Fix
regression
in
smtplib
's AUTH LOGIN support.
- Issue #18010: Fix the pydoc web server'
s
module
search
function
to
handle
...
...
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