@@ -279,6 +279,77 @@ INLINE bool PyLong_IsNonNegative(PyObject *value) {
279
279
}
280
280
#endif
281
281
282
+ /* Python 3.13 */
283
+
284
+ #if PY_VERSION_HEX < 0x030D00A1
285
+ # define PyLong_AsInt (x ) (_PyLong_AsInt(x))
286
+ #endif
287
+
288
+ #if PY_VERSION_HEX < 0x030D00A1
289
+ ALWAYS_INLINE int
290
+ PyModule_Add (PyObject * mod , const char * name , PyObject * value ) {
291
+ int res = PyModule_AddObjectRef (mod , name , value );
292
+ Py_XDECREF (value );
293
+ return res ;
294
+ }
295
+ #endif
296
+
297
+ #if PY_VERSION_HEX < 0x030D00A1
298
+ INLINE int
299
+ PyDict_GetItemRef (PyObject * mp , PyObject * key , PyObject * * result ) {
300
+ #if PY_MAJOR_VERSION >= 3
301
+ PyObject * item = PyDict_GetItemWithError (mp , key );
302
+ #else
303
+ PyObject * item = _PyDict_GetItemWithError (mp , key );
304
+ #endif
305
+ if (item != nullptr ) {
306
+ * result = Py_NewRef (item );
307
+ return 1 ;
308
+ }
309
+ * result = nullptr ;
310
+ return PyErr_Occurred () ? -1 : 0 ;
311
+ }
312
+
313
+ INLINE int
314
+ PyDict_GetItemStringRef (PyObject * mp , const char * key , PyObject * * result ) {
315
+ PyObject * item = nullptr ;
316
+ #if PY_MAJOR_VERSION >= 3
317
+ PyObject * key_obj = PyUnicode_FromString (key );
318
+ item = key_obj ? PyDict_GetItemWithError (mp , key_obj ) : nullptr ;
319
+ #else
320
+ PyObject * key_obj = PyString_FromString (key );
321
+ item = key_obj ? _PyDict_GetItemWithError (mp , key_obj ) : nullptr ;
322
+ #endif
323
+ Py_DECREF (key_obj );
324
+ if (item != nullptr ) {
325
+ * result = Py_NewRef (item );
326
+ return 1 ;
327
+ }
328
+ * result = nullptr ;
329
+ return PyErr_Occurred () ? -1 : 0 ;
330
+ }
331
+ #endif
332
+
333
+ #if PY_VERSION_HEX >= 0x03050200 && PY_VERSION_HEX < 0x030D00A1
334
+ # define PyThreadState_GetUnchecked () (_PyThreadState_UncheckedGet())
335
+ #endif
336
+
337
+ #if PY_VERSION_HEX < 0x030D00A2
338
+ # define PyList_Extend (list , iterable ) (PyList_SetSlice((list), PY_SSIZE_T_MAX, PY_SSIZE_T_MAX, (iterable)))
339
+ # define PyList_Clear (list ) (PyList_SetSlice((list), 0, PY_SSIZE_T_MAX, nullptr))
340
+ #endif
341
+
342
+ #if PY_VERSION_HEX < 0x030D00A4
343
+ # define PyList_GetItemRef (op , index ) (Py_XNewRef(PyList_GetItem((op), (index))))
344
+ #endif
345
+
346
+ #if PY_VERSION_HEX < 0x030D00B3
347
+ # define Py_BEGIN_CRITICAL_SECTION (op ) {
348
+ # define Py_END_CRITICAL_SECTION () }
349
+ # define Py_BEGIN_CRITICAL_SECTION2 (a , b ) {
350
+ # define Py_END_CRITICAL_SECTION2 () }
351
+ #endif
352
+
282
353
/* Other Python implementations */
283
354
284
355
#endif // HAVE_PYTHON
0 commit comments