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
3ce465ab
Kaydet (Commit)
3ce465ab
authored
Ock 27, 2015
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #23191: fnmatch functions that use caching are now threadsafe.
üst
c328d11e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
6 deletions
+12
-6
fnmatch.py
Lib/fnmatch.py
+10
-6
NEWS
Misc/NEWS
+2
-0
No files found.
Lib/fnmatch.py
Dosyayı görüntüle @
3ce465ab
...
@@ -47,12 +47,14 @@ def filter(names, pat):
...
@@ -47,12 +47,14 @@ def filter(names, pat):
import
os
,
posixpath
import
os
,
posixpath
result
=
[]
result
=
[]
pat
=
os
.
path
.
normcase
(
pat
)
pat
=
os
.
path
.
normcase
(
pat
)
if
not
pat
in
_cache
:
try
:
re_pat
=
_cache
[
pat
]
except
KeyError
:
res
=
translate
(
pat
)
res
=
translate
(
pat
)
if
len
(
_cache
)
>=
_MAXCACHE
:
if
len
(
_cache
)
>=
_MAXCACHE
:
_cache
.
clear
()
_cache
.
clear
()
_cache
[
pat
]
=
re
.
compile
(
res
)
_cache
[
pat
]
=
re
_pat
=
re
.
compile
(
res
)
match
=
_cache
[
pat
]
.
match
match
=
re_pat
.
match
if
os
.
path
is
posixpath
:
if
os
.
path
is
posixpath
:
# normcase on posix is NOP. Optimize it away from the loop.
# normcase on posix is NOP. Optimize it away from the loop.
for
name
in
names
:
for
name
in
names
:
...
@@ -71,12 +73,14 @@ def fnmatchcase(name, pat):
...
@@ -71,12 +73,14 @@ def fnmatchcase(name, pat):
its arguments.
its arguments.
"""
"""
if
not
pat
in
_cache
:
try
:
re_pat
=
_cache
[
pat
]
except
KeyError
:
res
=
translate
(
pat
)
res
=
translate
(
pat
)
if
len
(
_cache
)
>=
_MAXCACHE
:
if
len
(
_cache
)
>=
_MAXCACHE
:
_cache
.
clear
()
_cache
.
clear
()
_cache
[
pat
]
=
re
.
compile
(
res
)
_cache
[
pat
]
=
re
_pat
=
re
.
compile
(
res
)
return
_cache
[
pat
]
.
match
(
name
)
is
not
None
return
re_pat
.
match
(
name
)
is
not
None
def
translate
(
pat
):
def
translate
(
pat
):
"""Translate a shell PATTERN to a regular expression.
"""Translate a shell PATTERN to a regular expression.
...
...
Misc/NEWS
Dosyayı görüntüle @
3ce465ab
...
@@ -15,6 +15,8 @@ Core and Builtins
...
@@ -15,6 +15,8 @@ Core and Builtins
Library
Library
-------
-------
- Issue #23191: fnmatch functions that use caching are now threadsafe.
- Issue #18518: timeit now rejects statements which can't be compiled outside
- Issue #18518: timeit now rejects statements which can't be compiled outside
a function or a loop (e.g. "return" or "break").
a function or a loop (e.g. "return" or "break").
...
...
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