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
0a66a1cd
Kaydet (Commit)
0a66a1cd
authored
Kas 09, 2016
tarafından
Yury Selivanov
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge 3.6 (issue #28653)
üst
04c954d2
46a02db9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
2 deletions
+27
-2
test_functools.py
Lib/test/test_functools.py
+19
-0
NEWS
Misc/NEWS
+2
-0
_functoolsmodule.c
Modules/_functoolsmodule.c
+6
-2
No files found.
Lib/test/test_functools.py
Dosyayı görüntüle @
0a66a1cd
...
...
@@ -1189,6 +1189,25 @@ class TestLRU:
self
.
assertEqual
(
misses
,
4
)
self
.
assertEqual
(
currsize
,
2
)
def
test_lru_type_error
(
self
):
# Regression test for issue #28653.
# lru_cache was leaking when one of the arguments
# wasn't cacheable.
@functools.lru_cache
(
maxsize
=
None
)
def
infinite_cache
(
o
):
pass
@functools.lru_cache
(
maxsize
=
10
)
def
limited_cache
(
o
):
pass
with
self
.
assertRaises
(
TypeError
):
infinite_cache
([])
with
self
.
assertRaises
(
TypeError
):
limited_cache
([])
def
test_lru_with_maxsize_none
(
self
):
@self.module.lru_cache
(
maxsize
=
None
)
def
fib
(
n
):
...
...
Misc/NEWS
Dosyayı görüntüle @
0a66a1cd
...
...
@@ -48,6 +48,8 @@ Library
-
Issue
#
28652
:
Make
loop
methods
reject
socket
kinds
they
do
not
support
.
-
Issue
#
28653
:
Fix
a
refleak
in
functools
.
lru_cache
.
Documentation
-------------
...
...
Modules/_functoolsmodule.c
Dosyayı görüntüle @
0a66a1cd
...
...
@@ -793,8 +793,10 @@ infinite_lru_cache_wrapper(lru_cache_object *self, PyObject *args, PyObject *kwd
if
(
!
key
)
return
NULL
;
hash
=
PyObject_Hash
(
key
);
if
(
hash
==
-
1
)
if
(
hash
==
-
1
)
{
Py_DECREF
(
key
);
return
NULL
;
}
result
=
_PyDict_GetItem_KnownHash
(
self
->
cache
,
key
,
hash
);
if
(
result
)
{
Py_INCREF
(
result
);
...
...
@@ -849,8 +851,10 @@ bounded_lru_cache_wrapper(lru_cache_object *self, PyObject *args, PyObject *kwds
if
(
!
key
)
return
NULL
;
hash
=
PyObject_Hash
(
key
);
if
(
hash
==
-
1
)
if
(
hash
==
-
1
)
{
Py_DECREF
(
key
);
return
NULL
;
}
link
=
(
lru_list_elem
*
)
_PyDict_GetItem_KnownHash
(
self
->
cache
,
key
,
hash
);
if
(
link
)
{
lru_cache_extricate_link
(
link
);
...
...
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