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
3f345c39
Kaydet (Commit)
3f345c39
authored
Haz 07, 2019
tarafından
Jeroen Demeyer
Kaydeden (comit)
Petr Viktorin
Haz 07, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-37151: simplify classmethoddescr_call (GH-13340)
üst
307d4cb9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
30 deletions
+18
-30
test_descr.py
Lib/test/test_descr.py
+2
-2
descrobject.c
Objects/descrobject.c
+16
-28
No files found.
Lib/test/test_descr.py
Dosyayı görüntüle @
3f345c39
...
@@ -1613,8 +1613,8 @@ order (MRO) for bases """
...
@@ -1613,8 +1613,8 @@ order (MRO) for bases """
spam_cm
(
spam
.
spamlist
())
spam_cm
(
spam
.
spamlist
())
self
.
assertEqual
(
self
.
assertEqual
(
str
(
cm
.
exception
),
str
(
cm
.
exception
),
"descriptor 'classmeth'
requires a type
"
"descriptor 'classmeth'
for type 'xxsubtype.spamlist'
"
"
but received a 'xxsubtype.spamlist' instance
"
)
"
needs a type, not a 'xxsubtype.spamlist' as arg 2
"
)
with
self
.
assertRaises
(
TypeError
)
as
cm
:
with
self
.
assertRaises
(
TypeError
)
as
cm
:
spam_cm
(
list
)
spam_cm
(
list
)
...
...
Objects/descrobject.c
Dosyayı görüntüle @
3f345c39
...
@@ -300,16 +300,19 @@ _PyMethodDescr_Vectorcall(PyObject *descrobj,
...
@@ -300,16 +300,19 @@ _PyMethodDescr_Vectorcall(PyObject *descrobj,
return
result
;
return
result
;
}
}
/* Instances of classmethod_descriptor are unlikely to be called directly.
For one, the analogous class "classmethod" (for Python classes) is not
callable. Second, users are not likely to access a classmethod_descriptor
directly, since it means pulling it from the class __dict__.
This is just an excuse to say that this doesn't need to be optimized:
we implement this simply by calling __get__ and then calling the result.
*/
static
PyObject
*
static
PyObject
*
classmethoddescr_call
(
PyMethodDescrObject
*
descr
,
PyObject
*
args
,
classmethoddescr_call
(
PyMethodDescrObject
*
descr
,
PyObject
*
args
,
PyObject
*
kwds
)
PyObject
*
kwds
)
{
{
Py_ssize_t
argc
;
Py_ssize_t
argc
=
PyTuple_GET_SIZE
(
args
);
PyObject
*
self
,
*
result
;
/* Make sure that the first argument is acceptable as 'self' */
assert
(
PyTuple_Check
(
args
));
argc
=
PyTuple_GET_SIZE
(
args
);
if
(
argc
<
1
)
{
if
(
argc
<
1
)
{
PyErr_Format
(
PyExc_TypeError
,
PyErr_Format
(
PyExc_TypeError
,
"descriptor '%V' of '%.100s' "
"descriptor '%V' of '%.100s' "
...
@@ -318,30 +321,15 @@ classmethoddescr_call(PyMethodDescrObject *descr, PyObject *args,
...
@@ -318,30 +321,15 @@ classmethoddescr_call(PyMethodDescrObject *descr, PyObject *args,
PyDescr_TYPE
(
descr
)
->
tp_name
);
PyDescr_TYPE
(
descr
)
->
tp_name
);
return
NULL
;
return
NULL
;
}
}
self
=
PyTuple_GET_ITEM
(
args
,
0
);
PyObject
*
self
=
PyTuple_GET_ITEM
(
args
,
0
);
if
(
!
PyType_Check
(
self
))
{
PyObject
*
bound
=
classmethod_get
(
descr
,
NULL
,
self
);
PyErr_Format
(
PyExc_TypeError
,
if
(
bound
==
NULL
)
{
"descriptor '%V' requires a type "
"but received a '%.100s' instance"
,
descr_name
((
PyDescrObject
*
)
descr
),
"?"
,
self
->
ob_type
->
tp_name
);
return
NULL
;
}
if
(
!
PyType_IsSubtype
((
PyTypeObject
*
)
self
,
PyDescr_TYPE
(
descr
)))
{
PyErr_Format
(
PyExc_TypeError
,
"descriptor '%V' requires a subtype of '%.100s' "
"but received '%.100s'"
,
descr_name
((
PyDescrObject
*
)
descr
),
"?"
,
PyDescr_TYPE
(
descr
)
->
tp_name
,
((
PyTypeObject
*
)
self
)
->
tp_name
);
return
NULL
;
return
NULL
;
}
}
PyObject
*
res
=
_PyObject_FastCallDict
(
bound
,
_PyTuple_ITEMS
(
args
)
+
1
,
result
=
_PyMethodDef_RawFastCallDict
(
descr
->
d_method
,
self
,
argc
-
1
,
kwds
);
&
_PyTuple_ITEMS
(
args
)[
1
],
argc
-
1
,
Py_DECREF
(
bound
);
kwds
);
return
res
;
result
=
_Py_CheckFunctionResult
((
PyObject
*
)
descr
,
result
,
NULL
);
return
result
;
}
}
Py_LOCAL_INLINE
(
PyObject
*
)
Py_LOCAL_INLINE
(
PyObject
*
)
...
...
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