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
3f2291f8
Kaydet (Commit)
3f2291f8
authored
Eki 03, 2008
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Change fnmatch.py to use separate caches for str and bytes keys.
This is necessary to pass the tests with -bb.
üst
7ed51960
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
3 deletions
+5
-3
fnmatch.py
Lib/fnmatch.py
+5
-3
No files found.
Lib/fnmatch.py
Dosyayı görüntüle @
3f2291f8
...
@@ -14,7 +14,8 @@ import re
...
@@ -14,7 +14,8 @@ import re
__all__
=
[
"filter"
,
"fnmatch"
,
"fnmatchcase"
,
"translate"
]
__all__
=
[
"filter"
,
"fnmatch"
,
"fnmatchcase"
,
"translate"
]
_cache
=
{}
_cache
=
{}
# Maps text patterns to compiled regexen.
_cacheb
=
{}
# Ditto for bytes patterns.
def
fnmatch
(
name
,
pat
):
def
fnmatch
(
name
,
pat
):
"""Test whether FILENAME matches PATTERN.
"""Test whether FILENAME matches PATTERN.
...
@@ -38,7 +39,8 @@ def fnmatch(name, pat):
...
@@ -38,7 +39,8 @@ def fnmatch(name, pat):
return
fnmatchcase
(
name
,
pat
)
return
fnmatchcase
(
name
,
pat
)
def
_compile_pattern
(
pat
):
def
_compile_pattern
(
pat
):
regex
=
_cache
.
get
(
pat
)
cache
=
_cacheb
if
isinstance
(
pat
,
bytes
)
else
_cache
regex
=
cache
.
get
(
pat
)
if
regex
is
None
:
if
regex
is
None
:
if
isinstance
(
pat
,
bytes
):
if
isinstance
(
pat
,
bytes
):
pat_str
=
str
(
pat
,
'ISO-8859-1'
)
pat_str
=
str
(
pat
,
'ISO-8859-1'
)
...
@@ -46,7 +48,7 @@ def _compile_pattern(pat):
...
@@ -46,7 +48,7 @@ def _compile_pattern(pat):
res
=
bytes
(
res_str
,
'ISO-8859-1'
)
res
=
bytes
(
res_str
,
'ISO-8859-1'
)
else
:
else
:
res
=
translate
(
pat
)
res
=
translate
(
pat
)
_
cache
[
pat
]
=
regex
=
re
.
compile
(
res
)
cache
[
pat
]
=
regex
=
re
.
compile
(
res
)
return
regex
.
match
return
regex
.
match
def
filter
(
names
,
pat
):
def
filter
(
names
,
pat
):
...
...
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