From 9898e989dac8076aa5bf520176b3ff00d8fdca4f Mon Sep 17 00:00:00 2001 From: mattip Date: Mon, 18 Nov 2024 19:23:50 +0200 Subject: [PATCH 1/3] prepare for pypy3.11 release --- pythoncapi_compat.h | 6 +++--- runtests.py | 1 - tests/test_pythoncapi_compat.py | 2 +- tests/test_pythoncapi_compat_cext.c | 6 +++--- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/pythoncapi_compat.h b/pythoncapi_compat.h index 7c76858..2218b1b 100644 --- a/pythoncapi_compat.h +++ b/pythoncapi_compat.h @@ -287,7 +287,7 @@ PyFrame_GetVarString(PyFrameObject *frame, const char *name) // bpo-39947 added PyThreadState_GetInterpreter() to Python 3.9.0a5 -#if PY_VERSION_HEX < 0x030900A5 || defined(PYPY_VERSION) +#if PY_VERSION_HEX < 0x030900A5 || (defined(PYPY_VERSION) && PY_VERSION_HEX < 0x030B0000) static inline PyInterpreterState * PyThreadState_GetInterpreter(PyThreadState *tstate) { @@ -918,7 +918,7 @@ static inline int PyObject_VisitManagedDict(PyObject *obj, visitproc visit, void *arg) { PyObject **dict = _PyObject_GetDictPtr(obj); - if (*dict == NULL) { + if (dict == NULL || *dict == NULL) { return -1; } Py_VISIT(*dict); @@ -929,7 +929,7 @@ static inline void PyObject_ClearManagedDict(PyObject *obj) { PyObject **dict = _PyObject_GetDictPtr(obj); - if (*dict == NULL) { + if (dict == NULL || *dict == NULL) { return; } Py_CLEAR(*dict); diff --git a/runtests.py b/runtests.py index 5064550..2e92dba 100755 --- a/runtests.py +++ b/runtests.py @@ -13,7 +13,6 @@ import argparse import os.path import shutil -import subprocess import sys try: from shutil import which diff --git a/tests/test_pythoncapi_compat.py b/tests/test_pythoncapi_compat.py index 8480415..e4717e0 100644 --- a/tests/test_pythoncapi_compat.py +++ b/tests/test_pythoncapi_compat.py @@ -62,7 +62,7 @@ def build_ext(): display_title("Build test extensions") if os.path.exists("build"): shutil.rmtree("build") - cmd = [sys.executable, "setup.py", "build"] + cmd = [sys.executable, "setup.py", "build", "--debug"] if VERBOSE: run_command(cmd) print() diff --git a/tests/test_pythoncapi_compat_cext.c b/tests/test_pythoncapi_compat_cext.c index c413689..765a9ea 100644 --- a/tests/test_pythoncapi_compat_cext.c +++ b/tests/test_pythoncapi_compat_cext.c @@ -758,7 +758,7 @@ test_import(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args)) static void gc_collect(void) { -#if defined(PYPY_VERSION) +#if defined(PYPY_VERSION) && PY_VERSION_HEX < 0x030B0000 PyObject *mod = PyImport_ImportModule("gc"); assert(mod != _Py_NULL); @@ -1432,8 +1432,8 @@ test_long_api(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args)) // --- HeapCTypeWithManagedDict -------------------------------------------- -// Py_TPFLAGS_MANAGED_DICT was added to Python 3.11.0a3 -#if PY_VERSION_HEX >= 0x030B00A3 +// Py_TPFLAGS_MANAGED_DICT was added to Python 3.11.0a3 but is very much an implementation detail +#if PY_VERSION_HEX >= 0x030B00A3 || ! defined(PYPY_VERSION) # define TEST_MANAGED_DICT typedef struct { From 8cabe0d0ff37d5c54a830e2887722dc650500620 Mon Sep 17 00:00:00 2001 From: mattip Date: Mon, 18 Nov 2024 20:51:43 +0200 Subject: [PATCH 2/3] fix logic --- tests/test_pythoncapi_compat_cext.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_pythoncapi_compat_cext.c b/tests/test_pythoncapi_compat_cext.c index 765a9ea..4f369f7 100644 --- a/tests/test_pythoncapi_compat_cext.c +++ b/tests/test_pythoncapi_compat_cext.c @@ -1432,8 +1432,8 @@ test_long_api(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args)) // --- HeapCTypeWithManagedDict -------------------------------------------- -// Py_TPFLAGS_MANAGED_DICT was added to Python 3.11.0a3 but is very much an implementation detail -#if PY_VERSION_HEX >= 0x030B00A3 || ! defined(PYPY_VERSION) +// Py_TPFLAGS_MANAGED_DICT was added to Python 3.11.0a3 but is not implemented on PyPy +#if PY_VERSION_HEX >= 0x030B00A3 && ! defined(PYPY_VERSION) # define TEST_MANAGED_DICT typedef struct { From f0ce9ceb2d3f2fe301329617356e578b2ee78702 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 19 Nov 2024 09:07:02 +0100 Subject: [PATCH 3/3] Update tests/test_pythoncapi_compat.py --- tests/test_pythoncapi_compat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_pythoncapi_compat.py b/tests/test_pythoncapi_compat.py index e4717e0..8480415 100644 --- a/tests/test_pythoncapi_compat.py +++ b/tests/test_pythoncapi_compat.py @@ -62,7 +62,7 @@ def build_ext(): display_title("Build test extensions") if os.path.exists("build"): shutil.rmtree("build") - cmd = [sys.executable, "setup.py", "build", "--debug"] + cmd = [sys.executable, "setup.py", "build"] if VERBOSE: run_command(cmd) print()