Commit d8bcbdac authored by Matti Picus's avatar Matti Picus Committed by GitHub

Adapt to upcoming PyPy3.8/9 releases (GH4517)

parent cb5eb5a1
......@@ -1079,7 +1079,7 @@ class SlotTable(object):
EmptySlot("tp_vectorcall", ifdef="PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)"),
EmptySlot("tp_print", ifdef="PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000"),
# PyPy specific extension - only here to avoid C compiler warnings.
EmptySlot("tp_pypy_flags", ifdef="CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX > 0x03080000"),
EmptySlot("tp_pypy_flags", ifdef="CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000"),
)
#------------------------------------------------------------------------------------------
......
......@@ -463,7 +463,7 @@ static PyTypeObject __pyx_AsyncGenType_type = {
#if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
0, /*tp_print*/
#endif
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX > 0x03080000
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
0, /*tp_pypy_flags*/
#endif
};
......@@ -732,7 +732,7 @@ static PyTypeObject __pyx__PyAsyncGenASendType_type = {
#if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
0, /*tp_print*/
#endif
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX > 0x03080000
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
0, /*tp_pypy_flags*/
#endif
};
......@@ -867,7 +867,7 @@ static PyTypeObject __pyx__PyAsyncGenWrappedValueType_type = {
#if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
0, /*tp_print*/
#endif
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX > 0x03080000
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
0, /*tp_pypy_flags*/
#endif
};
......@@ -1205,7 +1205,7 @@ static PyTypeObject __pyx__PyAsyncGenAThrowType_type = {
#if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
0, /*tp_print*/
#endif
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX > 0x03080000
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
0, /*tp_pypy_flags*/
#endif
};
......
......@@ -1622,7 +1622,7 @@ static PyTypeObject __pyx_CoroutineAwaitType_type = {
#if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
0, /*tp_print*/
#endif
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX > 0x03080000
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
0, /*tp_pypy_flags*/
#endif
};
......@@ -1811,7 +1811,7 @@ static PyTypeObject __pyx_CoroutineType_type = {
#if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
0, /*tp_print*/
#endif
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX > 0x03080000
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
0, /*tp_pypy_flags*/
#endif
};
......@@ -1961,7 +1961,7 @@ static PyTypeObject __pyx_IterableCoroutineType_type = {
#if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
0, /*tp_print*/
#endif
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX > 0x03080000
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
0, /*tp_pypy_flags*/
#endif
};
......@@ -2107,7 +2107,7 @@ static PyTypeObject __pyx_GeneratorType_type = {
#if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
0, /*tp_print*/
#endif
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX > 0x03080000
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
0, /*tp_pypy_flags*/
#endif
};
......
......@@ -1041,7 +1041,7 @@ static PyTypeObject __pyx_CyFunctionType_type = {
#if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
0, /*tp_print*/
#endif
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX > 0x03080000
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
0, /*tp_pypy_flags*/
#endif
};
......@@ -1582,7 +1582,7 @@ static PyTypeObject __pyx_FusedFunctionType_type = {
#if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
0, /*tp_print*/
#endif
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX > 0x03080000
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
0, /*tp_pypy_flags*/
#endif
};
......
......@@ -108,9 +108,10 @@ void inita(void)
if (!sys_modules) return;
mod = PyInit_a();
if (!mod) return;
#if PY_VERSION_HEX >= 0x03050000
#if PY_VERSION_HEX >= 0x03050000 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
/* FIXME: this is incomplete and users shouldn't have to do this in the first place... */
if (!PyModule_Check(mod)) {
/* In PEP 489 multi-phase init, PyInit_a returns PyModuleDef */
PyModuleDef *mdef = (PyModuleDef*)mod;
PyObject *modname = PyUnicode_FromString("a");
if (!modname) return;
......
......@@ -107,7 +107,7 @@ def test_use_positional_as_keyword1(a, /):
>>> test_use_positional_as_keyword1(1)
>>> test_use_positional_as_keyword1(a=1) # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: test_use_positional_as_keyword1() ... keyword arguments...
TypeError: test_use_positional_as_keyword1() ... keyword argument...
"""
def test_use_positional_as_keyword2(a, /, b):
......@@ -116,7 +116,7 @@ def test_use_positional_as_keyword2(a, /, b):
>>> test_use_positional_as_keyword2(1, b=2)
>>> test_use_positional_as_keyword2(a=1, b=2) # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: test_use_positional_as_keyword2() ... positional...arguments...
TypeError: test_use_positional_as_keyword2() ... positional...argument...
"""
def test_use_positional_as_keyword3(a, b, /):
......@@ -212,7 +212,7 @@ def test_no_standard_args_usage(a, b, /, *, c):
>>> test_no_standard_args_usage(1, 2, c=3)
>>> test_no_standard_args_usage(1, b=2, c=3) # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: test_no_standard_args_usage() ... positional... arguments...
TypeError: test_no_standard_args_usage() ... positional... argument...
"""
#def test_change_default_pos_only():
......@@ -383,7 +383,7 @@ def test_serialization2(a, /, b):
(1, 2)
>>> unpickled_optional(a=1, b=2) # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: test_serialization2() ... positional... arguments...
TypeError: test_serialization2() ... positional... argument...
"""
return (a, b)
......
......@@ -162,8 +162,12 @@ class TestClassGetitem(unittest.TestCase):
# BEGIN - Additional tests from cython
def test_no_class_getitem(self):
class C: ...
# note that PyPy raises AttributeError on __class_getitem__
with self.assertRaises(TypeError if not hasattr(sys, "pypy_version_info") else AttributeError):
# PyPy<7.3.8 raises AttributeError on __class_getitem__
if hasattr(sys, "pypy_version_info") and sys.pypy_version_info < (7, 3, 8):
err = AttributeError
else:
err = TypeError
with self.assertRaises(err):
C[int]
# END - Additional tests from cython
......
......@@ -51,8 +51,12 @@ cdef class Invalid4:
class TestClassGetitem(unittest.TestCase):
# BEGIN - Additional tests from cython
def test_no_class_getitem(self):
# note that PyPy raises AttributeError on __class_getitem__
with self.assertRaises(TypeError if not hasattr(sys, "pypy_version_info") else AttributeError):
# PyPy<7.3.8 raises AttributeError on __class_getitem__
if hasattr(sys, "pypy_version_info") and sys.pypy_version_info < (7, 3, 8):
err = AttributeError
else:
err = TypeError
with self.assertRaises(err):
UnSupport[int]
# END - Additional tests from cython
......
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