Skip to content

Commit f66bbbd

Browse files
tacaswelljcrist
andauthored
MNT: account for CPython 314 changes (#760)
* MNT: account for CPython 314 changes python/cpython#125251 renamed _PY_IMMORTAL_REFCNT -> _PY_IMMORTAL_INITIAL_REFCNT * Define new macro to reduce duplication --------- Co-authored-by: Jim Crist-Harif <jcristharif@gmail.com>
1 parent 29390b0 commit f66bbbd

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

msgspec/_core.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#define PY311_PLUS (PY_VERSION_HEX >= 0x030b0000)
2222
#define PY312_PLUS (PY_VERSION_HEX >= 0x030c0000)
2323
#define PY313_PLUS (PY_VERSION_HEX >= 0x030d0000)
24+
#define PY314_PLUS (PY_VERSION_HEX >= 0x030e0000)
2425

2526
/* Hint to the compiler not to store `x` in a register since it is likely to
2627
* change. Results in much higher performance on GCC, with smaller benefits on
@@ -71,6 +72,12 @@ ms_popcount(uint64_t i) { \
7172
#define MS_UNICODE_EQ(a, b) _PyUnicode_EQ(a, b)
7273
#endif
7374

75+
#if PY314_PLUS
76+
#define MS_IMMORTAL_INITIAL_REFCNT _Py_IMMORTAL_INITIAL_REFCNT
77+
#else
78+
#define MS_IMMORTAL_INITIAL_REFCNT _Py_IMMORTAL_REFCNT
79+
#endif
80+
7481
#define DIV_ROUND_CLOSEST(n, d) ((((n) < 0) == ((d) < 0)) ? (((n) + (d)/2)/(d)) : (((n) - (d)/2)/(d)))
7582

7683
/* These macros are used to manually unroll some loops */
@@ -2155,7 +2162,7 @@ PyTypeObject NoDefault_Type = {
21552162
#if PY312_PLUS
21562163
PyObject _NoDefault_Object = {
21572164
_PyObject_EXTRA_INIT
2158-
{ _Py_IMMORTAL_REFCNT },
2165+
{ MS_IMMORTAL_INITIAL_REFCNT },
21592166
&NoDefault_Type
21602167
};
21612168
#else
@@ -2259,7 +2266,7 @@ PyTypeObject Unset_Type = {
22592266
#if PY312_PLUS
22602267
PyObject _Unset_Object = {
22612268
_PyObject_EXTRA_INIT
2262-
{ _Py_IMMORTAL_REFCNT },
2269+
{ MS_IMMORTAL_INITIAL_REFCNT },
22632270
&Unset_Type
22642271
};
22652272
#else

0 commit comments

Comments
 (0)