Commit 3fdd71a9 authored by scoder's avatar scoder Committed by GitHub

Merge pull request #1871 from rlamy/pypy3-fixes

PyPy 3 fixes
parents e6315294 d6f0b23a
...@@ -1408,7 +1408,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1408,7 +1408,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
if not is_final_type: if not is_final_type:
# in Py3.4+, call tp_finalize() as early as possible # in Py3.4+, call tp_finalize() as early as possible
code.putln("#if PY_VERSION_HEX >= 0x030400a1") code.putln("#if CYTHON_USE_TP_FINALIZE")
if needs_gc: if needs_gc:
finalised_check = '!_PyGC_FINALIZED(o)' finalised_check = '!_PyGC_FINALIZED(o)'
else: else:
......
...@@ -387,13 +387,13 @@ PyTypeObject __pyx_AsyncGenType_type = { ...@@ -387,13 +387,13 @@ PyTypeObject __pyx_AsyncGenType_type = {
0, /* tp_cache */ 0, /* tp_cache */
0, /* tp_subclasses */ 0, /* tp_subclasses */
0, /* tp_weaklist */ 0, /* tp_weaklist */
#if PY_VERSION_HEX >= 0x030400a1 #if CYTHON_USE_TP_FINALIZE
0, /*tp_del*/ 0, /*tp_del*/
#else #else
__Pyx_Coroutine_del, /*tp_del*/ __Pyx_Coroutine_del, /*tp_del*/
#endif #endif
0, /* tp_version_tag */ 0, /* tp_version_tag */
#if PY_VERSION_HEX >= 0x030400a1 #if CYTHON_USE_TP_FINALIZE
__Pyx_Coroutine_del, /* tp_finalize */ __Pyx_Coroutine_del, /* tp_finalize */
#endif #endif
}; };
......
...@@ -1553,13 +1553,13 @@ static PyTypeObject __pyx_CoroutineType_type = { ...@@ -1553,13 +1553,13 @@ static PyTypeObject __pyx_CoroutineType_type = {
0, /*tp_cache*/ 0, /*tp_cache*/
0, /*tp_subclasses*/ 0, /*tp_subclasses*/
0, /*tp_weaklist*/ 0, /*tp_weaklist*/
#if PY_VERSION_HEX >= 0x030400a1 #if CYTHON_USE_TP_FINALIZE
0, /*tp_del*/ 0, /*tp_del*/
#else #else
__Pyx_Coroutine_del, /*tp_del*/ __Pyx_Coroutine_del, /*tp_del*/
#endif #endif
0, /*tp_version_tag*/ 0, /*tp_version_tag*/
#if PY_VERSION_HEX >= 0x030400a1 #if CYTHON_USE_TP_FINALIZE
__Pyx_Coroutine_del, /*tp_finalize*/ __Pyx_Coroutine_del, /*tp_finalize*/
#endif #endif
}; };
...@@ -1653,13 +1653,13 @@ static PyTypeObject __pyx_GeneratorType_type = { ...@@ -1653,13 +1653,13 @@ static PyTypeObject __pyx_GeneratorType_type = {
0, /*tp_cache*/ 0, /*tp_cache*/
0, /*tp_subclasses*/ 0, /*tp_subclasses*/
0, /*tp_weaklist*/ 0, /*tp_weaklist*/
#if PY_VERSION_HEX >= 0x030400a1 #if CYTHON_USE_TP_FINALIZE
0, /*tp_del*/ 0, /*tp_del*/
#else #else
__Pyx_Coroutine_del, /*tp_del*/ __Pyx_Coroutine_del, /*tp_del*/
#endif #endif
0, /*tp_version_tag*/ 0, /*tp_version_tag*/
#if PY_VERSION_HEX >= 0x030400a1 #if CYTHON_USE_TP_FINALIZE
__Pyx_Coroutine_del, /*tp_finalize*/ __Pyx_Coroutine_del, /*tp_finalize*/
#endif #endif
}; };
......
...@@ -51,8 +51,12 @@ ...@@ -51,8 +51,12 @@
#define CYTHON_USE_TYPE_SLOTS 0 #define CYTHON_USE_TYPE_SLOTS 0
#undef CYTHON_USE_PYTYPE_LOOKUP #undef CYTHON_USE_PYTYPE_LOOKUP
#define CYTHON_USE_PYTYPE_LOOKUP 0 #define CYTHON_USE_PYTYPE_LOOKUP 0
#undef CYTHON_USE_ASYNC_SLOTS #if PY_VERSION_HEX < 0x03050000
#define CYTHON_USE_ASYNC_SLOTS 0 #undef CYTHON_USE_ASYNC_SLOTS
#define CYTHON_USE_ASYNC_SLOTS 0
#elif !defined(CYTHON_USE_ASYNC_SLOTS)
#define CYTHON_USE_ASYNC_SLOTS 1
#endif
#undef CYTHON_USE_PYLIST_INTERNALS #undef CYTHON_USE_PYLIST_INTERNALS
#define CYTHON_USE_PYLIST_INTERNALS 0 #define CYTHON_USE_PYLIST_INTERNALS 0
#undef CYTHON_USE_UNICODE_INTERNALS #undef CYTHON_USE_UNICODE_INTERNALS
...@@ -73,6 +77,8 @@ ...@@ -73,6 +77,8 @@
#define CYTHON_FAST_PYCALL 0 #define CYTHON_FAST_PYCALL 0
#undef CYTHON_PEP489_MULTI_PHASE_INIT #undef CYTHON_PEP489_MULTI_PHASE_INIT
#define CYTHON_PEP489_MULTI_PHASE_INIT 0 #define CYTHON_PEP489_MULTI_PHASE_INIT 0
#undef CYTHON_USE_TP_FINALIZE
#define CYTHON_USE_TP_FINALIZE 0
#elif defined(PYSTON_VERSION) #elif defined(PYSTON_VERSION)
#define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_PYPY 0
...@@ -110,6 +116,8 @@ ...@@ -110,6 +116,8 @@
#define CYTHON_FAST_PYCALL 0 #define CYTHON_FAST_PYCALL 0
#undef CYTHON_PEP489_MULTI_PHASE_INIT #undef CYTHON_PEP489_MULTI_PHASE_INIT
#define CYTHON_PEP489_MULTI_PHASE_INIT 0 #define CYTHON_PEP489_MULTI_PHASE_INIT 0
#undef CYTHON_USE_TP_FINALIZE
#define CYTHON_USE_TP_FINALIZE 0
#else #else
#define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_PYPY 0
...@@ -168,6 +176,9 @@ ...@@ -168,6 +176,9 @@
#ifndef CYTHON_PEP489_MULTI_PHASE_INIT #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
#define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000) #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
#endif #endif
#ifndef CYTHON_USE_TP_FINALIZE
#define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
#endif
#endif #endif
#if !defined(CYTHON_FAST_PYCCALL) #if !defined(CYTHON_FAST_PYCCALL)
......
...@@ -116,7 +116,6 @@ static CYTHON_INLINE int __Pyx_unpack_tuple2_exact( ...@@ -116,7 +116,6 @@ static CYTHON_INLINE int __Pyx_unpack_tuple2_exact(
return 0; return 0;
#if CYTHON_COMPILING_IN_PYPY #if CYTHON_COMPILING_IN_PYPY
bad: bad:
Py_XDECREF(iter);
Py_XDECREF(value1); Py_XDECREF(value1);
Py_XDECREF(value2); Py_XDECREF(value2);
if (decref_tuple) { Py_XDECREF(tuple); } if (decref_tuple) { Py_XDECREF(tuple); }
...@@ -187,12 +186,10 @@ static PyObject *__Pyx_PyIter_Next2Default(PyObject* defval) { ...@@ -187,12 +186,10 @@ static PyObject *__Pyx_PyIter_Next2Default(PyObject* defval) {
return NULL; return NULL;
} }
#if CYTHON_USE_TYPE_SLOTS
static void __Pyx_PyIter_Next_ErrorNoIterator(PyObject *iterator) { static void __Pyx_PyIter_Next_ErrorNoIterator(PyObject *iterator) {
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
"%.200s object is not an iterator", Py_TYPE(iterator)->tp_name); "%.200s object is not an iterator", Py_TYPE(iterator)->tp_name);
} }
#endif
// originally copied from Py3's builtin_next() // originally copied from Py3's builtin_next()
static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject* iterator, PyObject* defval) { static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject* iterator, PyObject* defval) {
......
...@@ -294,18 +294,20 @@ static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* iterable, int is_di ...@@ -294,18 +294,20 @@ static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* iterable, int is_di
// On PyPy3, we need to translate manually a few method names. // On PyPy3, we need to translate manually a few method names.
// This logic is not needed on CPython thanks to the fast case above. // This logic is not needed on CPython thanks to the fast case above.
static PyObject *py_items = NULL, *py_keys = NULL, *py_values = NULL; static PyObject *py_items = NULL, *py_keys = NULL, *py_values = NULL;
const char *name = PyUnicode_AsUTF8(method_name);
PyObject **pp = NULL; PyObject **pp = NULL;
if (strcmp(name, "iteritems") == 0) pp = &py_items; if (method_name) {
else if (strcmp(name, "iterkeys") == 0) pp = &py_keys; const char *name = PyUnicode_AsUTF8(method_name);
else if (strcmp(name, "itervalues") == 0) pp = &py_values; if (strcmp(name, "iteritems") == 0) pp = &py_items;
if (pp) { else if (strcmp(name, "iterkeys") == 0) pp = &py_keys;
if (!*pp) { else if (strcmp(name, "itervalues") == 0) pp = &py_values;
*pp = PyUnicode_FromString(name + 4); if (pp) {
if (!*pp) if (!*pp) {
return NULL; *pp = PyUnicode_FromString(name + 4);
if (!*pp)
return NULL;
}
method_name = *pp;
} }
method_name = *pp;
} }
#endif #endif
} }
......
''' '''
PYTHON -m Cython.Build.Cythonize -i '**/*_test.py' PYTHON -m Cython.Build.Cythonize -i '**/*_test.py'
PYTHON -c "import cy_test; assert cy_test.TEST == 'cy_test', cy_test.TEST; assert '.py' not in cy_test.__file__, cy_test.__file__" PYTHON -c "import cy_test; assert cy_test.TEST == 'cy_test', cy_test.TEST; assert not cy_test.__file__.rstrip('oc').endswith('.py'), cy_test.__file__"
PYTHON -c "import pkg.cy_test; assert pkg.cy_test.TEST == 'pkg.cy_test', pkg.cy_test.TEST; assert '.py' not in pkg.cy_test.__file__, pkg.cy_test.__file__" PYTHON -c "import pkg.cy_test; assert pkg.cy_test.TEST == 'pkg.cy_test', pkg.cy_test.TEST; assert not pkg.cy_test.__file__.rstrip('oc').endswith('.py'), pkg.cy_test.__file__"
PYTHON -c "import pkg.sub.cy_test; assert pkg.sub.cy_test.TEST == 'pkg.sub.cy_test', pkg.sub.cy_test.TEST; assert '.py' not in pkg.sub.cy_test.__file__, pkg.cy_test.__file__" PYTHON -c "import pkg.sub.cy_test; assert pkg.sub.cy_test.TEST == 'pkg.sub.cy_test', pkg.sub.cy_test.TEST; assert not pkg.sub.cy_test.__file__.rstrip('oc').endswith('.py'), pkg.cy_test.__file__"
''' '''
######## cy_test.py ######## ######## cy_test.py ########
......
...@@ -11,7 +11,7 @@ if sys.version_info[0] < 3 or sys.version_info >= (3,3): ...@@ -11,7 +11,7 @@ if sys.version_info[0] < 3 or sys.version_info >= (3,3):
# __init__.py compilation isn't supported in Py 3.[012] # __init__.py compilation isn't supported in Py 3.[012]
import pkg.sub.test import pkg.sub.test
assert pkg.sub.test.TEST == 'pkg.sub.test' assert pkg.sub.test.TEST == 'pkg.sub.test'
assert '.py' not in pkg.sub.test.__file__ assert not pkg.sub.test.__file__.rstrip('oc').endswith('.py')
######## test.py ######## ######## test.py ########
......
PYTHON setup.py build_ext --inplace PYTHON setup.py build_ext --inplace
PYTHON -c "import toppkg; assert '.py' not in toppkg.__file__; assert toppkg.PACKAGE == 1" PYTHON -c "import toppkg; assert not toppkg.__file__.rstrip('oc').endswith('.py'); assert toppkg.PACKAGE == 1"
PYTHON -c "import toppkg.subpkg; assert '.py' not in toppkg.__file__; assert '.py' not in toppkg.subpkg.__file__; assert toppkg.subpkg.PACKAGE == 2" PYTHON -c "import toppkg.subpkg; assert not toppkg.__file__.rstrip('oc').endswith('.py'); assert not toppkg.subpkg.__file__.rstrip('oc').endswith('.py'); assert toppkg.subpkg.PACKAGE == 2"
PYTHON -c "import toppkg.a; assert toppkg.a.MODULE == 'a'" PYTHON -c "import toppkg.a; assert toppkg.a.MODULE == 'a'"
PYTHON -c "from toppkg.subpkg import a; assert a.MODULE == 'subpkg.a'" PYTHON -c "from toppkg.subpkg import a; assert a.MODULE == 'subpkg.a'"
......
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