]> granicus.if.org Git - python/commitdiff
(Merge 3.1) Issue #9756: When calling a method descriptor or a slot wrapper
authorVictor Stinner <victor.stinner@haypocalc.com>
Sun, 1 May 2011 21:31:36 +0000 (23:31 +0200)
committerVictor Stinner <victor.stinner@haypocalc.com>
Sun, 1 May 2011 21:31:36 +0000 (23:31 +0200)
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).

1  2 
Lib/test/test_descr.py
Misc/NEWS
Objects/descrobject.c

Simple merge
diff --cc Misc/NEWS
index 07b7714d4c8b6a3c5899091c6d6179a6ac8cd88d,41bda2a6a78c193d02ac219a6749fe8813f22243..381c7f27a6bb61e282805ea07d8651c1accc1e5b
+++ b/Misc/NEWS
@@@ -10,14 -10,11 +10,19 @@@ What's New in Python 3.2.1
  Core and Builtins
  -----------------
  
+ - 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).
 +- Issue #10914: Initialize correctly the filesystem codec when creating a new
 +  subinterpreter to fix a bootstrap issue with codecs implemented in Python, as
 +  the ISO-8859-15 codec.
 +
 +- Issue #10517: After fork(), reinitialize the TLS used by the PyGILState_*
 +  APIs, to avoid a crash with the pthread implementation in RHEL 5.  Patch
 +  by Charles-François Natali.
 +
  - Issue #6780: fix starts/endswith error message to mention that tuples are
    accepted too.
  
index 11c68d336c0fe9defb74e00df4e321038cb9190c,9eda4bdd7da7755c790388015f1fb1b858f8c715..93daefd75f8563e3896ea2e8c0ed44eb758d5715
@@@ -226,7 -226,8 +226,8 @@@ methoddescr_call(PyMethodDescrObject *d
          return NULL;
      }
      self = PyTuple_GET_ITEM(args, 0);
-     if (!PyObject_IsInstance(self, (PyObject *)PyDescr_TYPE(descr))) {
+     if (!_PyObject_RealIsSubclass((PyObject *)Py_TYPE(self),
 -                                  (PyObject *)(descr->d_type))) {
++                                  (PyObject *)PyDescr_TYPE(descr))) {
          PyErr_Format(PyExc_TypeError,
                       "descriptor '%V' "
                       "requires a '%.100s' object "
@@@ -284,7 -285,8 +285,8 @@@ wrapperdescr_call(PyWrapperDescrObject 
          return NULL;
      }
      self = PyTuple_GET_ITEM(args, 0);
-     if (!PyObject_IsInstance(self, (PyObject *)PyDescr_TYPE(descr))) {
+     if (!_PyObject_RealIsSubclass((PyObject *)Py_TYPE(self),
 -                                  (PyObject *)(descr->d_type))) {
++                                  (PyObject *)PyDescr_TYPE(descr))) {
          PyErr_Format(PyExc_TypeError,
                       "descriptor '%V' "
                       "requires a '%.100s' object "
@@@ -1065,7 -1067,8 +1067,8 @@@ PyWrapper_New(PyObject *d, PyObject *se
  
      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 *)(descr->d_type)));
++                                    (PyObject *)PyDescr_TYPE(descr)));
  
      wp = PyObject_GC_New(wrapperobject, &wrappertype);
      if (wp != NULL) {