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
fc252265
Kaydet (Commit)
fc252265
authored
Eyl 15, 2005
tarafından
Brett Cannon
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Clear the regex cache when the locale changes.
Backport of fix for bug #1290505.
üst
bedda76d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
1 deletion
+7
-1
_strptime.py
Lib/_strptime.py
+2
-1
test_strptime.py
Lib/test/test_strptime.py
+2
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/_strptime.py
Dosyayı görüntüle @
fc252265
...
@@ -272,13 +272,14 @@ _regex_cache = {}
...
@@ -272,13 +272,14 @@ _regex_cache = {}
def
strptime
(
data_string
,
format
=
"
%
a
%
b
%
d
%
H:
%
M:
%
S
%
Y"
):
def
strptime
(
data_string
,
format
=
"
%
a
%
b
%
d
%
H:
%
M:
%
S
%
Y"
):
"""Return a time struct based on the input string and the format string."""
"""Return a time struct based on the input string and the format string."""
global
_TimeRE_cache
global
_TimeRE_cache
,
_regex_cache
_cache_lock
.
acquire
()
_cache_lock
.
acquire
()
try
:
try
:
time_re
=
_TimeRE_cache
time_re
=
_TimeRE_cache
locale_time
=
time_re
.
locale_time
locale_time
=
time_re
.
locale_time
if
_getlang
()
!=
locale_time
.
lang
:
if
_getlang
()
!=
locale_time
.
lang
:
_TimeRE_cache
=
TimeRE
()
_TimeRE_cache
=
TimeRE
()
_regex_cache
=
{}
if
len
(
_regex_cache
)
>
_CACHE_MAX_SIZE
:
if
len
(
_regex_cache
)
>
_CACHE_MAX_SIZE
:
_regex_cache
.
clear
()
_regex_cache
.
clear
()
format_regex
=
_regex_cache
.
get
(
format
)
format_regex
=
_regex_cache
.
get
(
format
)
...
...
Lib/test/test_strptime.py
Dosyayı görüntüle @
fc252265
...
@@ -462,10 +462,12 @@ class CacheTests(unittest.TestCase):
...
@@ -462,10 +462,12 @@ class CacheTests(unittest.TestCase):
# Make sure cache is recreated when current locale does not match what
# Make sure cache is recreated when current locale does not match what
# cached object was created with.
# cached object was created with.
_strptime
.
strptime
(
"10"
,
"
%
d"
)
_strptime
.
strptime
(
"10"
,
"
%
d"
)
_strptime
.
strptime
(
"2005"
,
"
%
Y"
)
_strptime
.
_TimeRE_cache
.
locale_time
.
lang
=
"Ni"
_strptime
.
_TimeRE_cache
.
locale_time
.
lang
=
"Ni"
original_time_re
=
id
(
_strptime
.
_TimeRE_cache
)
original_time_re
=
id
(
_strptime
.
_TimeRE_cache
)
_strptime
.
strptime
(
"10"
,
"
%
d"
)
_strptime
.
strptime
(
"10"
,
"
%
d"
)
self
.
failIfEqual
(
original_time_re
,
id
(
_strptime
.
_TimeRE_cache
))
self
.
failIfEqual
(
original_time_re
,
id
(
_strptime
.
_TimeRE_cache
))
self
.
failUnlessEqual
(
len
(
_strptime
.
_regex_cache
),
1
)
def
test_regex_cleanup
(
self
):
def
test_regex_cleanup
(
self
):
# Make sure cached regexes are discarded when cache becomes "full".
# Make sure cached regexes are discarded when cache becomes "full".
...
...
Misc/NEWS
Dosyayı görüntüle @
fc252265
...
@@ -92,6 +92,9 @@ Extension Modules
...
@@ -92,6 +92,9 @@ Extension Modules
Library
Library
-------
-------
-
Bug
#
1290505
:
time
.
strptime
()
was
not
invalidating
its
regex
cache
when
the
locale
changed
.
-
Fix
a
misuse
of
str
.
find
()
in
detection
of
use
of
%
U
or
%
W
in
datetime
-
Fix
a
misuse
of
str
.
find
()
in
detection
of
use
of
%
U
or
%
W
in
datetime
format
.
format
.
...
...
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