Commit dc34f2c9 authored by Boxiang Sun's avatar Boxiang Sun

Don't access PyClasssObject in Pyston directly. Use PyObject_GetAttrWrapper instead.

In Pyston, PyClassObject is just an opaque pointer. Don't access it directly.
Use PyObject_GetAttrWrapper which provided by Pyston:

-        d = ((PyClassObject *)cls)->cl_dict;
+        d = PyObject_GetAttrWrapper(cls);
parent d3cb5e2a
...@@ -471,14 +471,15 @@ inheritedAttribute(PyTypeObject *self, PyObject *name) ...@@ -471,14 +471,15 @@ inheritedAttribute(PyTypeObject *self, PyObject *name)
if (PyType_Check(cls)) if (PyType_Check(cls))
d = ((PyTypeObject *)cls)->tp_dict; d = ((PyTypeObject *)cls)->tp_dict;
else if (PyClass_Check(cls)) else if (PyClass_Check(cls))
d = ((PyClassObject *)cls)->cl_dict; // d = ((PyClassObject *)cls)->cl_dict;
d = PyObject_GetAttrWrapper(cls);
else else
/* Unrecognized thing, punt */ /* Unrecognized thing, punt */
d = NULL; d = NULL;
if ((d == NULL) || (PyDict_GetItem(d, name) == NULL)) if ((d == NULL) || (PyDict_GetItem(d, name) == NULL))
continue; continue;
return PyObject_GetAttr(cls, name); return PyObject_GetAttr(cls, name);
} }
...@@ -876,25 +877,32 @@ PyECMethod_New_(PyObject *callable, PyObject *inst) ...@@ -876,25 +877,32 @@ PyECMethod_New_(PyObject *callable, PyObject *inst)
{ {
if (! PyExtensionInstance_Check(inst)) if (! PyExtensionInstance_Check(inst))
{ {
PyErr_SetString(PyExc_TypeError, PyErr_SetString(PyExc_TypeError,
"Can't bind non-ExtensionClass instance."); "Can't bind non-ExtensionClass instance.");
return NULL; return NULL;
} }
if (PyMethod_Check(callable)) if (PyMethod_Check(callable))
{ {
if (callable->ob_refcnt == 1) // if (callable->ob_refcnt == 1)
{ // {
Py_XDECREF(((PyMethodObject*)callable)->im_self); // Pyston change:
Py_INCREF(inst); // Py_XDECREF(((PyMethodObject*)callable)->im_self);
((PyMethodObject*)callable)->im_self = inst; // Py_XDECREF(PyMethod_Self((PyObject *)callable));
Py_INCREF(callable); // Py_INCREF(inst);
return callable; // ((PyMethodObject*)callable)->im_self = inst;
} // PyMethod_Self((PyObject *)callable) = inst;
else // Py_INCREF(callable);
// return callable;
// }
// else
// Pyston change:
return callable->ob_type->tp_descr_get( return callable->ob_type->tp_descr_get(
callable, inst, callable, inst,
((PyMethodObject*)callable)->im_class); PyMethod_Class((PyObject *)callable));
// return callable->ob_type->tp_descr_get(
// callable, inst,
// ((PyMethodObject*)callable)->im_class);
} }
else else
return PyMethod_New(callable, inst, (PyObject*)(ECBaseType)); return PyMethod_New(callable, inst, (PyObject*)(ECBaseType));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment