Commit e6931d60 authored by Boxiang Sun's avatar Boxiang Sun

Enable CPython's macro PyCFunction_GET_FUNCTION. Fixes issue #1260

The function PyCFunction_GetFunction(func) check func type should be
exactly PyCFunction_Type. PyCFunction_GET_FUNCTION(func) does not check
func type. But assumes func layout starts with PyCFunctionObject. i.e.
for allowing func to be PyCFunction_Type subclass.

This way an extension which subclasses PyCFunctionObject will get
into trouble using PyCFunction_GET_FUNCTION() on Pyston
parent cc87a036
...@@ -32,8 +32,7 @@ PyAPI_FUNC(PyCFunction) PyCFunction_GetFunction(PyObject *) PYSTON_NOEXCEPT; ...@@ -32,8 +32,7 @@ PyAPI_FUNC(PyCFunction) PyCFunction_GetFunction(PyObject *) PYSTON_NOEXCEPT;
PyAPI_FUNC(BORROWED(PyObject *)) PyCFunction_GetSelf(PyObject *) PYSTON_NOEXCEPT; PyAPI_FUNC(BORROWED(PyObject *)) PyCFunction_GetSelf(PyObject *) PYSTON_NOEXCEPT;
PyAPI_FUNC(int) PyCFunction_GetFlags(PyObject *) PYSTON_NOEXCEPT; PyAPI_FUNC(int) PyCFunction_GetFlags(PyObject *) PYSTON_NOEXCEPT;
// Pyston change: changed to function calls
#if 0
/* Macros for direct access to these values. Type checks are *not* /* Macros for direct access to these values. Type checks are *not*
done, so use with care. */ done, so use with care. */
#define PyCFunction_GET_FUNCTION(func) \ #define PyCFunction_GET_FUNCTION(func) \
...@@ -42,13 +41,7 @@ PyAPI_FUNC(int) PyCFunction_GetFlags(PyObject *) PYSTON_NOEXCEPT; ...@@ -42,13 +41,7 @@ PyAPI_FUNC(int) PyCFunction_GetFlags(PyObject *) PYSTON_NOEXCEPT;
(((PyCFunctionObject *)func) -> m_self) (((PyCFunctionObject *)func) -> m_self)
#define PyCFunction_GET_FLAGS(func) \ #define PyCFunction_GET_FLAGS(func) \
(((PyCFunctionObject *)func) -> m_ml -> ml_flags) (((PyCFunctionObject *)func) -> m_ml -> ml_flags)
#endif
#define PyCFunction_GET_FUNCTION(func) \
PyCFunction_GetFunction((PyObject*)(func))
#define PyCFunction_GET_SELF(func) \
PyCFunction_GetSelf((PyObject*)(func))
#define PyCFunction_GET_FLAGS(func) \
PyCFunction_GetFlags((PyObject*)(func))
PyAPI_FUNC(PyObject *) PyCFunction_Call(PyObject *, PyObject *, PyObject *) PYSTON_NOEXCEPT; PyAPI_FUNC(PyObject *) PyCFunction_Call(PyObject *, PyObject *, PyObject *) PYSTON_NOEXCEPT;
struct PyMethodDef { struct PyMethodDef {
......
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