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
710cd34b
Kaydet (Commit)
710cd34b
authored
9 years ago
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #25449: Fixed a crash and leaking NULL in repr() of OrderedDict that
was mutated by direct calls of dict methods.
üst
b45b7b21
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
2 deletions
+70
-2
test_collections.py
Lib/test/test_collections.py
+54
-0
NEWS
Misc/NEWS
+3
-0
odictobject.c
Objects/odictobject.c
+13
-2
No files found.
Lib/test/test_collections.py
Dosyayı görüntüle @
710cd34b
...
...
@@ -2145,6 +2145,60 @@ class OrderedDictTests:
key
=
c0
+
c1
od
[
key
]
=
key
# Direct use of dict methods
def
test_dict_setitem
(
self
):
OrderedDict
=
self
.
OrderedDict
od
=
OrderedDict
()
dict
.
__setitem__
(
od
,
'spam'
,
1
)
self
.
assertNotIn
(
'NULL'
,
repr
(
od
))
def
test_dict_delitem
(
self
):
OrderedDict
=
self
.
OrderedDict
od
=
OrderedDict
()
od
[
'spam'
]
=
1
od
[
'ham'
]
=
2
dict
.
__delitem__
(
od
,
'spam'
)
with
self
.
assertRaises
(
KeyError
):
repr
(
od
)
def
test_dict_clear
(
self
):
OrderedDict
=
self
.
OrderedDict
od
=
OrderedDict
()
od
[
'spam'
]
=
1
od
[
'ham'
]
=
2
dict
.
clear
(
od
)
self
.
assertNotIn
(
'NULL'
,
repr
(
od
))
def
test_dict_pop
(
self
):
OrderedDict
=
self
.
OrderedDict
od
=
OrderedDict
()
od
[
'spam'
]
=
1
od
[
'ham'
]
=
2
dict
.
pop
(
od
,
'spam'
)
with
self
.
assertRaises
(
KeyError
):
repr
(
od
)
def
test_dict_popitem
(
self
):
OrderedDict
=
self
.
OrderedDict
od
=
OrderedDict
()
od
[
'spam'
]
=
1
od
[
'ham'
]
=
2
dict
.
popitem
(
od
)
with
self
.
assertRaises
(
KeyError
):
repr
(
od
)
def
test_dict_setdefault
(
self
):
OrderedDict
=
self
.
OrderedDict
od
=
OrderedDict
()
dict
.
setdefault
(
od
,
'spam'
,
1
)
self
.
assertNotIn
(
'NULL'
,
repr
(
od
))
def
test_dict_update
(
self
):
od
=
OrderedDict
()
dict
.
update
(
od
,
[(
'spam'
,
1
)])
self
.
assertNotIn
(
'NULL'
,
repr
(
od
))
class
PurePythonOrderedDictTests
(
OrderedDictTests
,
unittest
.
TestCase
):
...
...
This diff is collapsed.
Click to expand it.
Misc/NEWS
Dosyayı görüntüle @
710cd34b
...
...
@@ -11,6 +11,9 @@ Release date: TBA
Core and Builtins
-----------------
- Issue #25449: Fixed a crash and leaking NULL in repr() of OrderedDict that
was mutated by direct calls of dict methods.
- Issue #25449: Iterating OrderedDict with keys with unstable hash now raises
KeyError in C implementations as well as in Python implementation.
...
...
This diff is collapsed.
Click to expand it.
Objects/odictobject.c
Dosyayı görüntüle @
710cd34b
...
...
@@ -1462,7 +1462,6 @@ odict_repr(PyODictObject *self)
{
int
i
;
_Py_IDENTIFIER
(
items
);
Py_ssize_t
count
=
-
1
;
PyObject
*
pieces
=
NULL
,
*
result
=
NULL
;
const
char
*
classname
;
...
...
@@ -1481,6 +1480,7 @@ odict_repr(PyODictObject *self)
}
if
(
PyODict_CheckExact
(
self
))
{
Py_ssize_t
count
=
0
;
_ODictNode
*
node
;
pieces
=
PyList_New
(
PyODict_SIZE
(
self
));
if
(
pieces
==
NULL
)
...
...
@@ -1499,8 +1499,19 @@ odict_repr(PyODictObject *self)
if
(
pair
==
NULL
)
goto
Done
;
PyList_SET_ITEM
(
pieces
,
++
count
,
pair
);
/* steals reference */
if
(
count
<
PyList_GET_SIZE
(
pieces
))
PyList_SET_ITEM
(
pieces
,
count
,
pair
);
/* steals reference */
else
{
if
(
PyList_Append
(
pieces
,
pair
)
<
0
)
{
Py_DECREF
(
pair
);
goto
Done
;
}
Py_DECREF
(
pair
);
}
count
++
;
}
if
(
count
<
PyList_GET_SIZE
(
pieces
))
PyList_GET_SIZE
(
pieces
)
=
count
;
}
else
{
PyObject
*
items
=
_PyObject_CallMethodIdObjArgs
((
PyObject
*
)
self
,
...
...
This diff is collapsed.
Click to expand it.
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