Commit 09485f95 authored by scoder's avatar scoder Committed by GitHub

Merge pull request #528 from Daetalus/pyston_changes

Initial Cython patch for Pyston.
parents 499d2622 9a02e1ca
......@@ -553,7 +553,7 @@ PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value) {
__Pyx_PyThreadState_assign
if (value) {
#if CYTHON_COMPILING_IN_PYPY
#if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
// FIXME: what to do in PyPy?
#else
// Generators always return to their most recent caller, not
......@@ -580,7 +580,7 @@ PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value) {
if (retval) {
__Pyx_ExceptionSwap(&self->exc_type, &self->exc_value,
&self->exc_traceback);
#if CYTHON_COMPILING_IN_PYPY
#if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
// FIXME: what to do in PyPy?
#else
// Don't keep the reference to f_back any longer than necessary. It
......@@ -1486,7 +1486,7 @@ static void __Pyx__ReturnWithStopIteration(PyObject* value); /*proto*/
static void __Pyx__ReturnWithStopIteration(PyObject* value) {
PyObject *exc, *args;
#if CYTHON_COMPILING_IN_CPYTHON
#if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
__Pyx_PyThreadState_declare
if ((PY_VERSION_HEX >= 0x03030000 && PY_VERSION_HEX < 0x030500B1) || unlikely(PyTuple_Check(value))) {
args = PyTuple_New(1);
......
......@@ -1200,6 +1200,10 @@ static PyObject* __Pyx_Method_ClassMethod(PyObject *method) {
// cdef classes
return PyClassMethod_New(method);
}
#else
#if CYTHON_COMPILING_IN_PYSTON
// Pyston add this API for convinience.
if (PyMethodDescr_Check(method)) {
#else
// It appears that PyMethodDescr_Type is not anywhere exposed in the Python/C API
static PyTypeObject *methoddescr_type = NULL;
......@@ -1210,6 +1214,7 @@ static PyObject* __Pyx_Method_ClassMethod(PyObject *method) {
Py_DECREF(meth);
}
if (PyObject_TypeCheck(method, methoddescr_type)) {
#endif
// cdef classes
PyMethodDescrObject *descr = (PyMethodDescrObject *)method;
#if PY_VERSION_HEX < 0x03020000
......
......@@ -53,6 +53,33 @@
#define CYTHON_UNPACK_METHODS 0
#undef CYTHON_FAST_THREAD_STATE
#define CYTHON_FAST_THREAD_STATE 0
#elif defined(PYSTON_VERSION)
#define CYTHON_COMPILING_IN_PYSTON 1
#define CYTHON_COMPILING_IN_PYPY 0
#define CYTHON_COMPILING_IN_CPYTHON 0
#ifndef CYTHON_USE_TYPE_SLOTS
#define CYTHON_USE_TYPE_SLOTS 1
#endif
#undef CYTHON_USE_ASYNC_SLOTS
#define CYTHON_USE_ASYNC_SLOTS 0
#undef CYTHON_USE_PYLIST_INTERNALS
#define CYTHON_USE_PYLIST_INTERNALS 0
#ifndef CYTHON_USE_UNICODE_INTERNALS
#define CYTHON_USE_UNICODE_INTERNALS 1
#endif
#undef CYTHON_USE_PYLONG_INTERNALS
#define CYTHON_USE_PYLONG_INTERNALS 0
#ifndef CYTHON_AVOID_BORROWED_REFS
#define CYTHON_AVOID_BORROWED_REFS 0
#endif
#ifndef CYTHON_ASSUME_SAFE_MACROS
#define CYTHON_ASSUME_SAFE_MACROS 1
#endif
#ifndef CYTHON_UNPACK_METHODS
#define CYTHON_UNPACK_METHODS 1
#endif
#undef CYTHON_FAST_THREAD_STATE
#define CYTHON_FAST_THREAD_STATE 0
#else
#define CYTHON_COMPILING_IN_PYPY 0
#define CYTHON_COMPILING_IN_CPYTHON 1
......@@ -186,8 +213,14 @@
#define PyObject_Realloc(p) PyMem_Realloc(p)
#endif
#define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
#define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
/* Pyston provided out off box */
#if !CYTHON_COMPILING_IN_PYSTON
#define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
#define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
#else
#define __Pyx_PyCode_HasFreeVars PyCode_HasFreeVars
#define __Pyx_PyFrame_SetLineNumber PyFrame_SetLineNumber
#endif
#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
......
......@@ -5,7 +5,7 @@
// but maybe some other profilers don't.
#ifndef CYTHON_PROFILE
#if CYTHON_COMPILING_IN_PYPY
#if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
#define CYTHON_PROFILE 0
#else
#define CYTHON_PROFILE 1
......
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