From ca32b34dff688892a82c29c7f8692cde33ee2034 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Wed, 28 Dec 2022 23:50:38 +0100 Subject: [PATCH] Restored ability to build on Python 2 --- src/pya/pya/pyaCallables.cc | 5 +++++ testdata/python/basic.py | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/pya/pya/pyaCallables.cc b/src/pya/pya/pyaCallables.cc index c0a782904..d5d18e8b8 100644 --- a/src/pya/pya/pyaCallables.cc +++ b/src/pya/pya/pyaCallables.cc @@ -663,7 +663,12 @@ method_adaptor (int mid, PyObject *self, PyObject *args) // method is not implemented if (! meth) { +#if PY_MAJOR_VERSION < 3 + PyErr_SetNone(PyExc_NotImplementedError); + return NULL; +#else Py_RETURN_NOTIMPLEMENTED; +#endif } // handle special methods diff --git a/testdata/python/basic.py b/testdata/python/basic.py index 7595babdc..d2e707123 100644 --- a/testdata/python/basic.py +++ b/testdata/python/basic.py @@ -3077,6 +3077,11 @@ class BasicTest(unittest.TestCase): # fallback to __rmul__ for not implemented __mul__ def test_90(self): + + # skip this test for Python 2 + if sys.version_info < (3, 0): + return + class RMulObject: def __init__(self, factor): self.factor = factor