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
15ee821e
Kaydet (Commit)
15ee821e
authored
Nis 24, 2012
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
distiguish between refusing to creating shared keys and error (#13903)
üst
17feca0e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
4 deletions
+14
-4
test_dict.py
Lib/test/test_dict.py
+7
-0
dictobject.c
Objects/dictobject.c
+7
-4
No files found.
Lib/test/test_dict.py
Dosyayı görüntüle @
15ee821e
...
...
@@ -889,6 +889,13 @@ class DictTest(unittest.TestCase):
self
.
assertEqual
(
f
.
msg
,
getattr
(
f
,
_str
(
'msg'
)))
self
.
assertEqual
(
f
.
msg
,
f
.
__dict__
[
_str
(
'msg'
)])
def
test_object_set_item_single_instance_non_str_key
(
self
):
class
Foo
:
pass
f
=
Foo
()
f
.
__dict__
[
1
]
=
1
f
.
a
=
'a'
self
.
assertEqual
(
f
.
__dict__
,
{
1
:
1
,
'a'
:
'a'
})
from
test
import
mapping_tests
class
GeneralMappingTests
(
mapping_tests
.
BasicTestMappingProtocol
):
...
...
Objects/dictobject.c
Dosyayı görüntüle @
15ee821e
...
...
@@ -966,6 +966,8 @@ dictresize(PyDictObject *mp, Py_ssize_t minused)
return
0
;
}
/* Returns NULL if unable to split table.
* A NULL return does not necessarily indicate an error */
static
PyDictKeysObject
*
make_keys_shared
(
PyObject
*
op
)
{
...
...
@@ -973,7 +975,8 @@ make_keys_shared(PyObject *op)
Py_ssize_t
size
;
PyDictObject
*
mp
=
(
PyDictObject
*
)
op
;
assert
(
PyDict_CheckExact
(
op
));
if
(
!
PyDict_CheckExact
(
op
))
return
NULL
;
if
(
!
_PyDict_HasSplitTable
(
mp
))
{
PyDictKeyEntry
*
ep0
;
PyObject
**
values
;
...
...
@@ -3694,14 +3697,14 @@ _PyObjectDict_SetItem(PyTypeObject *tp, PyObject **dictptr,
res
=
PyDict_SetItem
(
dict
,
key
,
value
);
if
(
cached
!=
((
PyDictObject
*
)
dict
)
->
ma_keys
)
{
/* Either update tp->ht_cached_keys or delete it */
if
(
cached
->
dk_refcnt
==
1
&&
PyDict_CheckExact
(
dict
)
)
{
if
(
cached
->
dk_refcnt
==
1
)
{
CACHED_KEYS
(
tp
)
=
make_keys_shared
(
dict
);
if
(
CACHED_KEYS
(
tp
)
==
NULL
)
return
-
1
;
}
else
{
CACHED_KEYS
(
tp
)
=
NULL
;
}
DK_DECREF
(
cached
);
if
(
CACHED_KEYS
(
tp
)
==
NULL
&&
PyErr_Occurred
())
return
-
1
;
}
}
}
else
{
...
...
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