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
14adbd45
Unverified
Kaydet (Commit)
14adbd45
authored
Nis 20, 2019
tarafından
Raymond Hettinger
Kaydeden (comit)
GitHub
Nis 20, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-36650: Fix handling of empty keyword args in C version of lru_cache. (GH-12881)
üst
9d062d69
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
4 deletions
+21
-4
test_functools.py
Lib/test/test_functools.py
+14
-0
2019-04-19-15-29-55.bpo-36650._EVdrz.rst
...S.d/next/Library/2019-04-19-15-29-55.bpo-36650._EVdrz.rst
+4
-0
_functoolsmodule.c
Modules/_functoolsmodule.c
+3
-4
No files found.
Lib/test/test_functools.py
Dosyayı görüntüle @
14adbd45
...
...
@@ -1271,6 +1271,20 @@ class TestLRU:
self
.
assertEqual
(
f
(
20
),
'.20.'
)
self
.
assertEqual
(
f
.
cache_info
()
.
currsize
,
10
)
def
test_lru_bug_36650
(
self
):
# C version of lru_cache was treating a call with an empty **kwargs
# dictionary as being distinct from a call with no keywords at all.
# This did not result in an incorrect answer, but it did trigger
# an unexpected cache miss.
@self.module.lru_cache
()
def
f
(
x
):
pass
f
(
0
)
f
(
0
,
**
{})
self
.
assertEqual
(
f
.
cache_info
()
.
hits
,
1
)
def
test_lru_hash_only_once
(
self
):
# To protect against weird reentrancy bugs and to improve
# efficiency when faced with slow __hash__ methods, the
...
...
Misc/NEWS.d/next/Library/2019-04-19-15-29-55.bpo-36650._EVdrz.rst
0 → 100644
Dosyayı görüntüle @
14adbd45
The C version of functools.lru_cache() was treating calls with an empty
``**kwargs`` dictionary as being distinct from calls with no keywords at all.
This did not result in an incorrect answer, but it did trigger an unexpected
cache miss.
Modules/_functoolsmodule.c
Dosyayı görüntüle @
14adbd45
...
...
@@ -750,8 +750,10 @@ lru_cache_make_key(PyObject *args, PyObject *kwds, int typed)
PyObject
*
key
,
*
keyword
,
*
value
;
Py_ssize_t
key_size
,
pos
,
key_pos
,
kwds_size
;
kwds_size
=
kwds
?
PyDict_GET_SIZE
(
kwds
)
:
0
;
/* short path, key will match args anyway, which is a tuple */
if
(
!
typed
&&
!
kwds
)
{
if
(
!
typed
&&
!
kwds
_size
)
{
if
(
PyTuple_GET_SIZE
(
args
)
==
1
)
{
key
=
PyTuple_GET_ITEM
(
args
,
0
);
if
(
PyUnicode_CheckExact
(
key
)
||
PyLong_CheckExact
(
key
))
{
...
...
@@ -765,9 +767,6 @@ lru_cache_make_key(PyObject *args, PyObject *kwds, int typed)
return
args
;
}
kwds_size
=
kwds
?
PyDict_GET_SIZE
(
kwds
)
:
0
;
assert
(
kwds_size
>=
0
);
key_size
=
PyTuple_GET_SIZE
(
args
);
if
(
kwds_size
)
key_size
+=
kwds_size
*
2
+
1
;
...
...
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