Skip to content

Commit e0455b7

Browse files
committed
Merge branch 'master' into long_import-export
2 parents a1cb729 + 900c130 commit e0455b7

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

docs/users.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ Examples of projects using pythoncapi_compat.h
4545
<https://github.com/pyansys/hollerith/blob/main/src/pythoncapi_compat.h>`__)
4646
* `PyTorch <https://github.com/pytorch/pytorch/>`_ (`pythoncapi_compat.h copy
4747
<https://github.com/pytorch/pytorch/blob/main/torch/csrc/utils/pythoncapi_compat.h>`__)
48-
48+
* `PyGObject <https://gitlab.gnome.org/GNOME/pygobject/>`_
49+
(`commit <https://gitlab.gnome.org/GNOME/pygobject/-/commit/074c0348417b87d3003dbb409e6fc26b61121de3>`__,
50+
`pythoncapi-compat Meson subproject
51+
<https://gitlab.gnome.org/GNOME/pygobject/-/blob/main/subprojects/pythoncapi-compat.wrap?ref_type=heads>`__)
4952

5053
Projects not using pythoncapi_compat.h
5154
======================================

pythoncapi_compat.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ PyFrame_GetVarString(PyFrameObject *frame, const char *name)
287287

288288

289289
// bpo-39947 added PyThreadState_GetInterpreter() to Python 3.9.0a5
290-
#if PY_VERSION_HEX < 0x030900A5 || defined(PYPY_VERSION)
290+
#if PY_VERSION_HEX < 0x030900A5 || (defined(PYPY_VERSION) && PY_VERSION_HEX < 0x030B0000)
291291
static inline PyInterpreterState *
292292
PyThreadState_GetInterpreter(PyThreadState *tstate)
293293
{
@@ -918,7 +918,7 @@ static inline int
918918
PyObject_VisitManagedDict(PyObject *obj, visitproc visit, void *arg)
919919
{
920920
PyObject **dict = _PyObject_GetDictPtr(obj);
921-
if (*dict == NULL) {
921+
if (dict == NULL || *dict == NULL) {
922922
return -1;
923923
}
924924
Py_VISIT(*dict);
@@ -929,7 +929,7 @@ static inline void
929929
PyObject_ClearManagedDict(PyObject *obj)
930930
{
931931
PyObject **dict = _PyObject_GetDictPtr(obj);
932-
if (*dict == NULL) {
932+
if (dict == NULL || *dict == NULL) {
933933
return;
934934
}
935935
Py_CLEAR(*dict);
@@ -1204,11 +1204,11 @@ static inline int PyTime_PerfCounter(PyTime_t *result)
12041204
#endif
12051205

12061206
// gh-111389 added hash constants to Python 3.13.0a5. These constants were
1207-
// added first as private macros to Python 3.4.0b1 and PyPy 7.3.9.
1207+
// added first as private macros to Python 3.4.0b1 and PyPy 7.3.8.
12081208
#if (!defined(PyHASH_BITS) \
12091209
&& ((!defined(PYPY_VERSION) && PY_VERSION_HEX >= 0x030400B1) \
12101210
|| (defined(PYPY_VERSION) && PY_VERSION_HEX >= 0x03070000 \
1211-
&& PYPY_VERSION_NUM >= 0x07090000)))
1211+
&& PYPY_VERSION_NUM >= 0x07030800)))
12121212
# define PyHASH_BITS _PyHASH_BITS
12131213
# define PyHASH_MODULUS _PyHASH_MODULUS
12141214
# define PyHASH_INF _PyHASH_INF

runtests.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import argparse
1414
import os.path
1515
import shutil
16-
import subprocess
1716
import sys
1817
try:
1918
from shutil import which

tests/test_pythoncapi_compat_cext.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ test_import(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args))
758758
static void
759759
gc_collect(void)
760760
{
761-
#if defined(PYPY_VERSION)
761+
#if defined(PYPY_VERSION) && PY_VERSION_HEX < 0x030B0000
762762
PyObject *mod = PyImport_ImportModule("gc");
763763
assert(mod != _Py_NULL);
764764

@@ -1475,8 +1475,8 @@ test_long_api(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args))
14751475

14761476
// --- HeapCTypeWithManagedDict --------------------------------------------
14771477

1478-
// Py_TPFLAGS_MANAGED_DICT was added to Python 3.11.0a3
1479-
#if PY_VERSION_HEX >= 0x030B00A3
1478+
// Py_TPFLAGS_MANAGED_DICT was added to Python 3.11.0a3 but is not implemented on PyPy
1479+
#if PY_VERSION_HEX >= 0x030B00A3 && ! defined(PYPY_VERSION)
14801480
# define TEST_MANAGED_DICT
14811481

14821482
typedef struct {
@@ -1659,7 +1659,7 @@ test_hash(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args))
16591659

16601660
#if ((!defined(PYPY_VERSION) && PY_VERSION_HEX >= 0x030400B1) \
16611661
|| (defined(PYPY_VERSION) && PY_VERSION_HEX >= 0x03070000 \
1662-
&& PYPY_VERSION_NUM >= 0x07090000))
1662+
&& PYPY_VERSION_NUM >= 0x07030800))
16631663
// Just check that constants are available
16641664
size_t bits = PyHASH_BITS;
16651665
assert(bits >= 8);

0 commit comments

Comments
 (0)