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):
if not is_final_type:
# 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:
finalised_check = '!_PyGC_FINALIZED(o)'
else:
......
......@@ -387,13 +387,13 @@ PyTypeObject __pyx_AsyncGenType_type = {
0, /* tp_cache */
0, /* tp_subclasses */
0, /* tp_weaklist */
#if PY_VERSION_HEX >= 0x030400a1
#if CYTHON_USE_TP_FINALIZE
0, /*tp_del*/
#else
__Pyx_Coroutine_del, /*tp_del*/
#endif
0, /* tp_version_tag */
#if PY_VERSION_HEX >= 0x030400a1
#if CYTHON_USE_TP_FINALIZE
__Pyx_Coroutine_del, /* tp_finalize */
#endif
};
......
......@@ -1553,13 +1553,13 @@ static PyTypeObject __pyx_CoroutineType_type = {
0, /*tp_cache*/
0, /*tp_subclasses*/
0, /*tp_weaklist*/
#if PY_VERSION_HEX >= 0x030400a1
#if CYTHON_USE_TP_FINALIZE
0, /*tp_del*/
#else
__Pyx_Coroutine_del, /*tp_del*/
#endif
0, /*tp_version_tag*/
#if PY_VERSION_HEX >= 0x030400a1
#if CYTHON_USE_TP_FINALIZE
__Pyx_Coroutine_del, /*tp_finalize*/
#endif
};
......@@ -1653,13 +1653,13 @@ static PyTypeObject __pyx_GeneratorType_type = {
0, /*tp_cache*/
0, /*tp_subclasses*/
0, /*tp_weaklist*/
#if PY_VERSION_HEX >= 0x030400a1
#if CYTHON_USE_TP_FINALIZE
0, /*tp_del*/
#else
__Pyx_Coroutine_del, /*tp_del*/
#endif
0, /*tp_version_tag*/
#if PY_VERSION_HEX >= 0x030400a1
#if CYTHON_USE_TP_FINALIZE
__Pyx_Coroutine_del, /*tp_finalize*/
#endif
};
......
......@@ -51,8 +51,12 @@
#define CYTHON_USE_TYPE_SLOTS 0
#undef CYTHON_USE_PYTYPE_LOOKUP
#define CYTHON_USE_PYTYPE_LOOKUP 0
#if PY_VERSION_HEX < 0x03050000
#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
#define CYTHON_USE_PYLIST_INTERNALS 0
#undef CYTHON_USE_UNICODE_INTERNALS
......@@ -73,6 +77,8 @@
#define CYTHON_FAST_PYCALL 0
#undef CYTHON_PEP489_MULTI_PHASE_INIT
#define CYTHON_PEP489_MULTI_PHASE_INIT 0
#undef CYTHON_USE_TP_FINALIZE
#define CYTHON_USE_TP_FINALIZE 0
#elif defined(PYSTON_VERSION)
#define CYTHON_COMPILING_IN_PYPY 0
......@@ -110,6 +116,8 @@
#define CYTHON_FAST_PYCALL 0
#undef CYTHON_PEP489_MULTI_PHASE_INIT
#define CYTHON_PEP489_MULTI_PHASE_INIT 0
#undef CYTHON_USE_TP_FINALIZE
#define CYTHON_USE_TP_FINALIZE 0
#else
#define CYTHON_COMPILING_IN_PYPY 0
......@@ -168,6 +176,9 @@
#ifndef CYTHON_PEP489_MULTI_PHASE_INIT
#define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
#endif
#ifndef CYTHON_USE_TP_FINALIZE
#define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
#endif
#endif
#if !defined(CYTHON_FAST_PYCCALL)
......
......@@ -116,7 +116,6 @@ static CYTHON_INLINE int __Pyx_unpack_tuple2_exact(
return 0;
#if CYTHON_COMPILING_IN_PYPY
bad:
Py_XDECREF(iter);
Py_XDECREF(value1);
Py_XDECREF(value2);
if (decref_tuple) { Py_XDECREF(tuple); }
......@@ -187,12 +186,10 @@ static PyObject *__Pyx_PyIter_Next2Default(PyObject* defval) {
return NULL;
}
#if CYTHON_USE_TYPE_SLOTS
static void __Pyx_PyIter_Next_ErrorNoIterator(PyObject *iterator) {
PyErr_Format(PyExc_TypeError,
"%.200s object is not an iterator", Py_TYPE(iterator)->tp_name);
}
#endif
// originally copied from Py3's builtin_next()
static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject* iterator, PyObject* defval) {
......
......@@ -294,8 +294,9 @@ static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* iterable, int is_di
// On PyPy3, we need to translate manually a few method names.
// This logic is not needed on CPython thanks to the fast case above.
static PyObject *py_items = NULL, *py_keys = NULL, *py_values = NULL;
const char *name = PyUnicode_AsUTF8(method_name);
PyObject **pp = NULL;
if (method_name) {
const char *name = PyUnicode_AsUTF8(method_name);
if (strcmp(name, "iteritems") == 0) pp = &py_items;
else if (strcmp(name, "iterkeys") == 0) pp = &py_keys;
else if (strcmp(name, "itervalues") == 0) pp = &py_values;
......@@ -307,6 +308,7 @@ static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* iterable, int is_di
}
method_name = *pp;
}
}
#endif
}
*p_orig_length = 0;
......
'''
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 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.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 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 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 not pkg.sub.cy_test.__file__.rstrip('oc').endswith('.py'), pkg.cy_test.__file__"
'''
######## cy_test.py ########
......
......@@ -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]
import 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 ########
......
PYTHON setup.py build_ext --inplace
PYTHON -c "import toppkg; assert '.py' not in toppkg.__file__; 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; assert not toppkg.__file__.rstrip('oc').endswith('.py'); assert toppkg.PACKAGE == 1"
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 "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