summaryrefslogtreecommitdiffstats
path: root/Objects/descrobject.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-05-01 21:31:36 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-05-01 21:31:36 (GMT)
commitd9561318d849df12775d7a111aa85bbf62a54c0f (patch)
tree72c5bd9cfa4a614054c05a52cae6839a3679523c /Objects/descrobject.c
parentda623ed9f43a13bc285a7e29ae8774d29c481332 (diff)
parent3249dec02484674830177488c8f01d8d04873928 (diff)
downloadcpython-d9561318d849df12775d7a111aa85bbf62a54c0f.zip
cpython-d9561318d849df12775d7a111aa85bbf62a54c0f.tar.gz
cpython-d9561318d849df12775d7a111aa85bbf62a54c0f.tar.bz2
(Merge 3.1) Issue #9756: When calling a method descriptor or a slot wrapper
descriptor, the check of the object type doesn't read the __class__ attribute anymore. Fix a crash if a class override its __class__ attribute (e.g. a proxy of the str type).
Diffstat (limited to 'Objects/descrobject.c')
-rw-r--r--Objects/descrobject.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/Objects/descrobject.c b/Objects/descrobject.c
index 11c68d3..93daefd 100644
--- a/Objects/descrobject.c
+++ b/Objects/descrobject.c
@@ -226,7 +226,8 @@ methoddescr_call(PyMethodDescrObject *descr, PyObject *args, PyObject *kwds)
return NULL;
}
self = PyTuple_GET_ITEM(args, 0);
- if (!PyObject_IsInstance(self, (PyObject *)PyDescr_TYPE(descr))) {
+ if (!_PyObject_RealIsSubclass((PyObject *)Py_TYPE(self),
+ (PyObject *)PyDescr_TYPE(descr))) {
PyErr_Format(PyExc_TypeError,
"descriptor '%V' "
"requires a '%.100s' object "
@@ -284,7 +285,8 @@ wrapperdescr_call(PyWrapperDescrObject *descr, PyObject *args, PyObject *kwds)
return NULL;
}
self = PyTuple_GET_ITEM(args, 0);
- if (!PyObject_IsInstance(self, (PyObject *)PyDescr_TYPE(descr))) {
+ if (!_PyObject_RealIsSubclass((PyObject *)Py_TYPE(self),
+ (PyObject *)PyDescr_TYPE(descr))) {
PyErr_Format(PyExc_TypeError,
"descriptor '%V' "
"requires a '%.100s' object "
@@ -1065,7 +1067,8 @@ PyWrapper_New(PyObject *d, PyObject *self)
assert(PyObject_TypeCheck(d, &PyWrapperDescr_Type));
descr = (PyWrapperDescrObject *)d;
- assert(PyObject_IsInstance(self, (PyObject *)PyDescr_TYPE(descr)));
+ assert(_PyObject_RealIsSubclass((PyObject *)Py_TYPE(self),
+ (PyObject *)PyDescr_TYPE(descr)));
wp = PyObject_GC_New(wrapperobject, &wrappertype);
if (wp != NULL) {