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
39d43b46
Kaydet (Commit)
39d43b46
authored
May 27, 2009
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
correctly handle descrs with __missing__
üst
a68cad13
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
7 deletions
+18
-7
test_descr.py
Lib/test/test_descr.py
+12
-2
dictobject.c
Objects/dictobject.c
+6
-5
No files found.
Lib/test/test_descr.py
Dosyayı görüntüle @
39d43b46
...
...
@@ -1689,7 +1689,15 @@ order (MRO) for bases """
return
isinstance
(
int
,
obj
)
def
do_issubclass
(
obj
):
return
issubclass
(
int
,
obj
)
def
swallow
(
*
args
):
pass
def
swallow
(
*
args
):
pass
def
do_dict_missing
(
checker
):
class
DictSub
(
checker
.
__class__
,
dict
):
pass
self
.
assertEqual
(
DictSub
()[
"hi"
],
4
)
def
some_number
(
self_
,
key
):
self
.
assertEqual
(
key
,
"hi"
)
return
4
# It would be nice to have every special method tested here, but I'm
# only listing the ones I can remember outside of typeobject.c, since it
...
...
@@ -1701,6 +1709,8 @@ order (MRO) for bases """
{
"__iter__"
:
iden
,
"next"
:
stop
}),
(
"__sizeof__"
,
sys
.
getsizeof
,
zero
,
set
(),
{}),
(
"__instancecheck__"
,
do_isinstance
,
return_true
,
set
(),
{}),
(
"__missing__"
,
do_dict_missing
,
some_number
,
set
((
"__class__"
,)),
{}),
(
"__subclasscheck__"
,
do_issubclass
,
return_true
,
set
((
"__bases__"
,)),
{}),
(
"__enter__"
,
run_context
,
iden
,
set
(),
{
"__exit__"
:
swallow
}),
...
...
@@ -1713,7 +1723,7 @@ order (MRO) for bases """
def
__getattribute__
(
self
,
attr
,
test
=
self
):
if
attr
not
in
ok
:
test
.
fail
(
"__getattribute__ called with {0}"
.
format
(
attr
))
return
object
.
__getattribute__
(
attr
)
return
object
.
__getattribute__
(
self
,
attr
)
class
SpecialDescr
(
object
):
def
__init__
(
self
,
impl
):
self
.
impl
=
impl
...
...
Objects/dictobject.c
Dosyayı görüntüle @
39d43b46
...
...
@@ -1155,13 +1155,14 @@ dict_subscript(PyDictObject *mp, register PyObject *key)
/* Look up __missing__ method if we're a subclass. */
PyObject
*
missing
;
static
PyObject
*
missing_str
=
NULL
;
if
(
missing_str
==
NULL
)
missing_str
=
PyString_InternFromString
(
"__missing__"
);
missing
=
_PyType_Lookup
(
Py_TYPE
(
mp
),
missing_str
);
missing
=
_PyObject_LookupSpecial
((
PyObject
*
)
mp
,
"__missing__"
,
&
missing_str
);
if
(
missing
!=
NULL
)
return
PyObject_CallFunctionObjArgs
(
missing
,
(
PyObject
*
)
mp
,
key
,
NULL
);
key
,
NULL
);
else
if
(
PyErr_Occurred
())
return
NULL
;
}
set_key_error
(
key
);
return
NULL
;
...
...
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