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
e03e5b1f
Kaydet (Commit)
e03e5b1f
authored
Ara 07, 2002
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Remove assumption that cls is a subclass of dict.
Simplifies the code and gets Just van Rossum's example to work.
üst
4e52ca82
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
10 deletions
+4
-10
test_types.py
Lib/test/test_types.py
+3
-3
dictobject.c
Objects/dictobject.c
+1
-7
No files found.
Lib/test/test_types.py
Dosyayı görüntüle @
e03e5b1f
...
@@ -566,9 +566,9 @@ from UserDict import UserDict
...
@@ -566,9 +566,9 @@ from UserDict import UserDict
class
mydict
(
dict
):
class
mydict
(
dict
):
def
__new__
(
cls
,
*
args
,
**
kwargs
):
def
__new__
(
cls
,
*
args
,
**
kwargs
):
return
UserDict
(
*
args
,
**
kwargs
)
return
UserDict
(
*
args
,
**
kwargs
)
try
:
mydict
.
fromkeys
(
'a b c'
.
split
()
)
ud
=
mydict
.
fromkeys
(
'ab'
)
except
TypeError
:
pass
if
ud
!=
{
'a'
:
None
,
'b'
:
None
}
or
not
isinstance
(
ud
,
UserDict
):
else
:
raise
TestFailed
,
'dict.fromkeys() failed to detect non-dict class.
'
raise
TestFailed
,
'fromkeys did not instantiate using __new__
'
# dict.copy()
# dict.copy()
d
=
{
1
:
1
,
2
:
2
,
3
:
3
}
d
=
{
1
:
1
,
2
:
2
,
3
:
3
}
if
d
.
copy
()
!=
{
1
:
1
,
2
:
2
,
3
:
3
}:
raise
TestFailed
,
'dict copy'
if
d
.
copy
()
!=
{
1
:
1
,
2
:
2
,
3
:
3
}:
raise
TestFailed
,
'dict copy'
...
...
Objects/dictobject.c
Dosyayı görüntüle @
e03e5b1f
...
@@ -979,12 +979,6 @@ dict_fromkeys(PyObject *mp, PyObject *args)
...
@@ -979,12 +979,6 @@ dict_fromkeys(PyObject *mp, PyObject *args)
d
=
PyObject_CallObject
(
cls
,
NULL
);
d
=
PyObject_CallObject
(
cls
,
NULL
);
if
(
d
==
NULL
)
if
(
d
==
NULL
)
return
NULL
;
return
NULL
;
if
(
!
PyDict_Check
(
d
))
{
Py_DECREF
(
d
);
PyErr_SetString
(
PyExc_TypeError
,
"class constructor must return a subclass of dict"
);
return
NULL
;
}
it
=
PyObject_GetIter
(
seq
);
it
=
PyObject_GetIter
(
seq
);
if
(
it
==
NULL
){
if
(
it
==
NULL
){
...
@@ -999,7 +993,7 @@ dict_fromkeys(PyObject *mp, PyObject *args)
...
@@ -999,7 +993,7 @@ dict_fromkeys(PyObject *mp, PyObject *args)
goto
Fail
;
goto
Fail
;
break
;
break
;
}
}
status
=
Py
Di
ct_SetItem
(
d
,
key
,
value
);
status
=
Py
Obje
ct_SetItem
(
d
,
key
,
value
);
Py_DECREF
(
key
);
Py_DECREF
(
key
);
if
(
status
<
0
)
if
(
status
<
0
)
goto
Fail
;
goto
Fail
;
...
...
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