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
d28bb624
Kaydet (Commit)
d28bb624
authored
Kas 25, 2015
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #24097: Fixed crash in object.__reduce__() if slot name is freed inside
__getattr__. Original patch by Antoine Pitrou.
üst
33e7ea5a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
0 deletions
+23
-0
test_descr.py
Lib/test/test_descr.py
+17
-0
NEWS
Misc/NEWS
+3
-0
typeobject.c
Objects/typeobject.c
+3
-0
No files found.
Lib/test/test_descr.py
Dosyayı görüntüle @
d28bb624
...
...
@@ -4988,6 +4988,23 @@ class PicklingTests(unittest.TestCase):
objcopy2
=
deepcopy
(
objcopy
)
self
.
_assert_is_copy
(
obj
,
objcopy2
)
def
test_issue24097
(
self
):
# Slot name is freed inside __getattr__ and is later used.
class
S
(
str
):
# Not interned
pass
class
A
:
__slotnames__
=
[
S
(
'spam'
)]
def
__getattr__
(
self
,
attr
):
if
attr
==
'spam'
:
A
.
__slotnames__
[:]
=
[
S
(
'spam'
)]
return
42
else
:
raise
AttributeError
import
copyreg
expected
=
(
copyreg
.
__newobj__
,
(
A
,),
(
None
,
{
'spam'
:
42
}),
None
,
None
)
self
.
assertEqual
(
A
()
.
__reduce__
(
2
),
expected
)
# Shouldn't crash
class
SharedKeyTests
(
unittest
.
TestCase
):
...
...
Misc/NEWS
Dosyayı görüntüle @
d28bb624
...
...
@@ -10,6 +10,9 @@ Release date: tba
Core and Builtins
-----------------
- Issue #24097: Fixed crash in object.__reduce__() if slot name is freed inside
__getattr__.
- Issue #24731: Fixed crash on converting objects with special methods
__bytes__, __trunc__, and __float__ returning instances of subclasses of
bytes, int, and float to subclasses of bytes, int, and float correspondingly.
...
...
Objects/typeobject.c
Dosyayı görüntüle @
d28bb624
...
...
@@ -3768,8 +3768,10 @@ _PyObject_GetState(PyObject *obj)
PyObject
*
name
,
*
value
;
name
=
PyList_GET_ITEM
(
slotnames
,
i
);
Py_INCREF
(
name
);
value
=
PyObject_GetAttr
(
obj
,
name
);
if
(
value
==
NULL
)
{
Py_DECREF
(
name
);
if
(
!
PyErr_ExceptionMatches
(
PyExc_AttributeError
))
{
goto
error
;
}
...
...
@@ -3778,6 +3780,7 @@ _PyObject_GetState(PyObject *obj)
}
else
{
int
err
=
PyDict_SetItem
(
slots
,
name
,
value
);
Py_DECREF
(
name
);
Py_DECREF
(
value
);
if
(
err
)
{
goto
error
;
...
...
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