Commit 96b5707d authored by Boxiang Sun's avatar Boxiang Sun

Use plain Pyston implementation of PyObject_GenericGetAttr in ExtensionClass.

In zope ExtensionClass, it just copied and inlined the codes from CPython's
PyObject_GenericGetAttr and _PyObject_GetDictPtr. Which are not work for Pyston.
So just call correspond function in Pyston.
parent dc34f2c9
......@@ -45,7 +45,9 @@ Base_getattro(PyObject *obj, PyObject *name)
{
/* This is a modified copy of PyObject_GenericGetAttr.
See the change note below. */
PyObject *res = PyObject_GenericGetAttr(obj, name);
return res;
#if 0
PyTypeObject *tp = obj->ob_type;
PyObject *descr = NULL;
PyObject *res = NULL;
......@@ -123,51 +125,51 @@ Base_getattro(PyObject *obj, PyObject *name)
}
/* Inline _PyObject_GetDictPtr */
dictoffset = tp->tp_dictoffset;
if (dictoffset != 0) {
PyObject *dict;
if (dictoffset < 0) {
int tsize;
size_t size;
tsize = ((PyVarObject *)obj)->ob_size;
if (tsize < 0)
tsize = -tsize;
size = _PyObject_VAR_SIZE(tp, tsize);
dictoffset += (long)size;
assert(dictoffset > 0);
assert(dictoffset % SIZEOF_VOID_P == 0);
}
dictptr = (PyObject **) ((char *)obj + dictoffset);
dict = *dictptr;
if (dict != NULL) {
Py_INCREF(dict);
res = PyDict_GetItem(dict, name);
if (res != NULL) {
Py_INCREF(res);
Py_XDECREF(descr);
Py_DECREF(dict);
/* CHANGED!
If the tp_descr_get of res is of_get,
then call it. */
if (PyObject_TypeCheck(res->ob_type,
&ExtensionClassType)
&& res->ob_type->tp_descr_get != NULL) {
PyObject *tres;
tres = res->ob_type->tp_descr_get(
res, obj,
OBJECT(obj->ob_type));
Py_DECREF(res);
res = tres;
}
goto done;
}
Py_DECREF(dict);
}
}
dictoffset = tp->tp_dictoffset;
if (dictoffset != 0) {
PyObject *dict;
if (dictoffset < 0) {
int tsize;
size_t size;
tsize = ((PyVarObject *)obj)->ob_size;
if (tsize < 0)
tsize = -tsize;
size = _PyObject_VAR_SIZE(tp, tsize);
dictoffset += (long)size;
assert(dictoffset > 0);
assert(dictoffset % SIZEOF_VOID_P == 0);
}
dictptr = (PyObject **) ((char *)obj + dictoffset);
dict = *dictptr;
if (dict != NULL) {
Py_INCREF(dict);
res = PyDict_GetItem(dict, name);
if (res != NULL) {
Py_INCREF(res);
Py_XDECREF(descr);
Py_DECREF(dict);
/* CHANGED!
If the tp_descr_get of res is of_get,
then call it. */
if (PyObject_TypeCheck(res->ob_type,
&ExtensionClassType)
&& res->ob_type->tp_descr_get != NULL) {
PyObject *tres;
tres = res->ob_type->tp_descr_get(
res, obj,
OBJECT(obj->ob_type));
Py_DECREF(res);
res = tres;
}
goto done;
}
Py_DECREF(dict);
}
/* } */
if (f != NULL) {
res = f(descr, obj, (PyObject *)obj->ob_type);
......@@ -182,10 +184,11 @@ Base_getattro(PyObject *obj, PyObject *name)
}
/* CHANGED: Just use the name. Don't format. */
PyErr_SetObject(PyExc_AttributeError, name);
PyErr_SetObject(PyExc_AttributeError, PyString_FromString("Are you kidding me?"));
done:
Py_DECREF(name);
return res;
#endif
}
#include "pickle/pickle.c"
......
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