diff --git a/pythoncapi_compat.h b/pythoncapi_compat.h index e26185c..99970f6 100644 --- a/pythoncapi_compat.h +++ b/pythoncapi_compat.h @@ -1569,6 +1569,11 @@ static inline int PyLong_IsZero(PyObject *obj) // gh-124502 added PyUnicode_Equal() to Python 3.14.0a0 #if PY_VERSION_HEX < 0x030E00A0 + +#if PY_VERSION_HEX >= 0x030d0000 && !defined(PYPY_VERSION) +PyAPI_FUNC(int) _PyUnicode_Equal(PyObject *str1, PyObject *str2); +#endif + static inline int PyUnicode_Equal(PyObject *str1, PyObject *str2) { if (!PyUnicode_Check(str1)) { @@ -1583,8 +1588,6 @@ static inline int PyUnicode_Equal(PyObject *str1, PyObject *str2) } #if PY_VERSION_HEX >= 0x030d0000 && !defined(PYPY_VERSION) - PyAPI_FUNC(int) _PyUnicode_Equal(PyObject *str1, PyObject *str2); - return _PyUnicode_Equal(str1, str2); #elif PY_VERSION_HEX >= 0x03060000 && !defined(PYPY_VERSION) return _PyUnicode_EQ(str1, str2); @@ -1607,11 +1610,14 @@ static inline PyObject* PyBytes_Join(PyObject *sep, PyObject *iterable) #if PY_VERSION_HEX < 0x030E00A0 + +#if PY_VERSION_HEX >= 0x03000000 && !defined(PYPY_VERSION) +PyAPI_FUNC(Py_hash_t) _Py_HashBytes(const void *src, Py_ssize_t len); +#endif + static inline Py_hash_t Py_HashBuffer(const void *ptr, Py_ssize_t len) { #if PY_VERSION_HEX >= 0x03000000 && !defined(PYPY_VERSION) - PyAPI_FUNC(Py_hash_t) _Py_HashBytes(const void *src, Py_ssize_t len); - return _Py_HashBytes(ptr, len); #else Py_hash_t hash; @@ -1948,11 +1954,14 @@ PyLongWriter_Finish(PyLongWriter *writer) // gh-127350 added Py_fopen() and Py_fclose() to Python 3.14a4 #if PY_VERSION_HEX < 0x030E00A4 + +#if 0x030400A2 <= PY_VERSION_HEX && !defined(PYPY_VERSION) +PyAPI_FUNC(FILE*) _Py_fopen_obj(PyObject *path, const char *mode); +#endif + static inline FILE* Py_fopen(PyObject *path, const char *mode) { #if 0x030400A2 <= PY_VERSION_HEX && !defined(PYPY_VERSION) - PyAPI_FUNC(FILE*) _Py_fopen_obj(PyObject *path, const char *mode); - return _Py_fopen_obj(path, mode); #else FILE *f; @@ -2664,6 +2673,10 @@ PyUnstable_Unicode_GET_CACHED_HASH(PyObject *op) // to make objects immortal until 3.14 which has _Py_SetImmortal(). Since // immortal objects are primarily needed for free-threading, this API is implemented // for 3.14 using _Py_SetImmortal() and uses private macros on 3.13. +#if 0x030E0000 <= PY_VERSION_HEX +PyAPI_FUNC(void) _Py_SetImmortal(PyObject *op); +#endif + static inline int PyUnstable_SetImmortal(PyObject *op) { @@ -2672,7 +2685,6 @@ PyUnstable_SetImmortal(PyObject *op) return 0; } #if 0x030E0000 <= PY_VERSION_HEX - PyAPI_FUNC(void) _Py_SetImmortal(PyObject *op); _Py_SetImmortal(op); #else // Python 3.13 doesn't export _Py_SetImmortal() function diff --git a/tests/setup.py b/tests/setup.py index e394bce..b25bc8d 100755 --- a/tests/setup.py +++ b/tests/setup.py @@ -32,9 +32,6 @@ '-Wall', '-Wextra', # Extra warnings '-Wconversion', - # /usr/lib64/pypy3.7/include/pyport.h:68:20: error: redefinition of typedef - # 'Py_hash_t' is a C11 feature - '-Wno-typedef-redefinition', # Formatting checks '-Wformat', '-Wformat-nonliteral', @@ -47,6 +44,14 @@ # Treat all compiler warnings as compiler errors '/WX', )) + # Python 3.11 and older emits C4100 "unreferenced parameter" warnings + # on Py_UNUSED() parameters. Py_UNUSED() was modified in Python 3.12 + # to support MSVC. + if sys.version_info >= (3, 12): + COMMON_FLAGS.extend(( + # Display warnings level 1 to 4 + '/W4', + )) CFLAGS = list(COMMON_FLAGS) CXXFLAGS = list(COMMON_FLAGS)