Skip to content

Commit 0b7ac7e

Browse files
committed
Fix Python 3.11a2-3.11a6
1 parent c7d3657 commit 0b7ac7e

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

pythoncapi_compat.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,11 @@ _Py_IS_TYPE(const PyObject *ob, const PyTypeObject *type) {
391391
#endif
392392

393393

394-
// bpo-11734 added _PyFloat_Pack2() and _PyFloat_Unpack2() to Python 3.6.0b1.
395394
// bpo-46906 added PyFloat_Pack2() and PyFloat_Unpack2() to Python 3.11a7.
396-
#if 0x030600B1 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x030B00A7 && !defined(PYPY_VERSION)
395+
// bpo-11734 added _PyFloat_Pack2() and _PyFloat_Unpack2() to Python 3.6.0b1.
396+
// Python 3.11a2 moved _PyFloat_Pack2() and _PyFloat_Unpack2() to the internal
397+
// C API: Python 3.11a2-3.11a6 versions are not supported.
398+
#if 0x030600B1 <= PY_VERSION_HEX && PY_VERSION_HEX <= 0x030B00A1 && !defined(PYPY_VERSION)
397399
PYCAPI_COMPAT_STATIC_INLINE(int)
398400
PyFloat_Pack2(double x, char *p, int le)
399401
{ return _PyFloat_Pack2(x, (unsigned char*)p, le); }
@@ -406,7 +408,10 @@ PyFloat_Unpack2(const char *p, int le)
406408

407409
// bpo-46906 added PyFloat_Pack4(), PyFloat_Pack8(), PyFloat_Unpack4() and
408410
// PyFloat_Unpack8() to Python 3.11a7.
409-
#if PY_VERSION_HEX < 0x030B00A7 && !defined(PYPY_VERSION)
411+
// Python 3.11a2 moved _PyFloat_Pack4(), _PyFloat_Pack8(), _PyFloat_Unpack4()
412+
// and _PyFloat_Unpack8() to the internal C API: Python 3.11a2-3.11a6 versions
413+
// are not supported.
414+
#if PY_VERSION_HEX <= 0x030B00A1 && !defined(PYPY_VERSION)
410415
PYCAPI_COMPAT_STATIC_INLINE(int)
411416
PyFloat_Pack4(double x, char *p, int le)
412417
{ return _PyFloat_Pack4(x, (unsigned char*)p, le); }

tests/test_pythoncapi_compat_cext.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@
66
// the issue to be able to test pythoncapi_compat.h on these unsupported Python
77
// versions anyway.
88
#include "Python.h"
9-
#if (0x030B00A2 <= PY_VERSION_HEX && PY_VERSION_HEX <= 0x030B00A6) && !defined(PYPY_VERSION)
10-
# define Py_BUILD_CORE 1
11-
# include "internal/pycore_floatobject.h"
12-
# undef Py_BUILD_CORE
13-
#endif
149

1510
#include "pythoncapi_compat.h"
1611

@@ -417,7 +412,7 @@ test_module(PyObject *Py_UNUSED(module), PyObject* Py_UNUSED(ignored))
417412
}
418413

419414

420-
#ifndef PYPY_VERSION
415+
#if (PY_VERSION_HEX <= 0x030B00A1 || 0x030B00A7 <= PY_VERSION_HEX) && !defined(PYPY_VERSION)
421416
static PyObject *
422417
test_float_pack(PyObject *Py_UNUSED(module), PyObject* Py_UNUSED(ignored))
423418
{
@@ -470,7 +465,7 @@ test_float_pack(PyObject *Py_UNUSED(module), PyObject* Py_UNUSED(ignored))
470465

471466
Py_RETURN_NONE;
472467
}
473-
#endif // !PYPY_VERSION
468+
#endif
474469

475470

476471
static struct PyMethodDef methods[] = {
@@ -485,7 +480,7 @@ static struct PyMethodDef methods[] = {
485480
{"test_calls", test_calls, METH_NOARGS, NULL},
486481
{"test_gc", test_gc, METH_NOARGS, NULL},
487482
{"test_module", test_module, METH_NOARGS, NULL},
488-
#ifndef PYPY_VERSION
483+
#if (PY_VERSION_HEX <= 0x030B00A1 || 0x030B00A7 <= PY_VERSION_HEX) && !defined(PYPY_VERSION)
489484
{"test_float_pack", test_float_pack, METH_NOARGS, NULL},
490485
#endif
491486
{NULL, NULL, 0, NULL}

0 commit comments

Comments
 (0)