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)
if (PyType_Check(cls))
d = ((PyTypeObject *)cls)->tp_dict;
else if (PyClass_Check(cls))
d = ((PyClassObject *)cls)->cl_dict;
// d = ((PyClassObject *)cls)->cl_dict;
d = PyObject_GetAttrWrapper(cls);
else
/* Unrecognized thing, punt */
d = NULL;
if ((d == NULL) || (PyDict_GetItem(d, name) == NULL))
continue;
return PyObject_GetAttr(cls, name);
}
......@@ -876,25 +877,32 @@ PyECMethod_New_(PyObject *callable, PyObject *inst)
{
if (! PyExtensionInstance_Check(inst))
{
PyErr_SetString(PyExc_TypeError,
PyErr_SetString(PyExc_TypeError,
"Can't bind non-ExtensionClass instance.");
return NULL;
}
if (PyMethod_Check(callable))
{
if (callable->ob_refcnt == 1)
{
Py_XDECREF(((PyMethodObject*)callable)->im_self);
Py_INCREF(inst);
((PyMethodObject*)callable)->im_self = inst;
Py_INCREF(callable);
return callable;
}
else
// if (callable->ob_refcnt == 1)
// {
// Pyston change:
// Py_XDECREF(((PyMethodObject*)callable)->im_self);
// Py_XDECREF(PyMethod_Self((PyObject *)callable));
// Py_INCREF(inst);
// ((PyMethodObject*)callable)->im_self = inst;
// PyMethod_Self((PyObject *)callable) = inst;
// Py_INCREF(callable);
// return callable;
// }
// else
// Pyston change:
return callable->ob_type->tp_descr_get(
callable, inst,
((PyMethodObject*)callable)->im_class);
callable, inst,
PyMethod_Class((PyObject *)callable));
// return callable->ob_type->tp_descr_get(
// callable, inst,
// ((PyMethodObject*)callable)->im_class);
}
else
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