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