diff --git a/Include/Python.h b/Include/Python.h index 337119c15fe8b6f..3d723a83616d506 100644 --- a/Include/Python.h +++ b/Include/Python.h @@ -35,12 +35,12 @@ // // The and headers are not included by limited C API // version 3.13 and newer. -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < _Py_PACK_VERSION(3, 11) # include // errno # include // FILE* # include // getenv() #endif -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030d0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < _Py_PACK_VERSION(3, 13) # include // tolower() # ifndef MS_WINDOWS # include // close() diff --git a/Include/abstract.h b/Include/abstract.h index 80f3298701d249e..34ab9eca44739e9 100644 --- a/Include/abstract.h +++ b/Include/abstract.h @@ -141,7 +141,7 @@ extern "C" { This is the equivalent of the Python statement: del o.attr_name. Implemented as a macro in the limited C API 3.12 and older. */ -#if defined(Py_LIMITED_API) && Py_LIMITED_API+0 < 0x030d0000 +#if defined(Py_LIMITED_API) && Py_LIMITED_API+0 < _Py_PACK_VERSION(3, 13) # define PyObject_DelAttrString(O, A) PyObject_SetAttrString((O), (A), NULL) #endif @@ -155,7 +155,7 @@ extern "C" { statement: del o.attr_name. Implemented as a macro in the limited C API 3.12 and older. */ -#if defined(Py_LIMITED_API) && Py_LIMITED_API+0 < 0x030d0000 +#if defined(Py_LIMITED_API) && Py_LIMITED_API+0 < _Py_PACK_VERSION(3, 13) # define PyObject_DelAttr(O, A) PyObject_SetAttr((O), (A), NULL) #endif @@ -282,7 +282,7 @@ PyAPI_FUNC(Py_ssize_t) PyVectorcall_NARGS(size_t nargsf); "tuple" and keyword arguments "dict". "dict" may also be NULL */ PyAPI_FUNC(PyObject *) PyVectorcall_Call(PyObject *callable, PyObject *tuple, PyObject *dict); -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030C0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 12) #define PY_VECTORCALL_ARGUMENTS_OFFSET \ (_Py_STATIC_CAST(size_t, 1) << (8 * sizeof(size_t) - 1)) @@ -407,7 +407,7 @@ PyAPI_FUNC(int) PyIter_Check(PyObject *); This function always succeeds. */ PyAPI_FUNC(int) PyAIter_Check(PyObject *); -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030e0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 14) /* Return 1 and set 'item' to the next item of 'iter' on success. * Return 0 and set 'item' to NULL when there are no remaining values. * Return -1, set 'item' to NULL and set an exception on error. @@ -426,7 +426,7 @@ PyAPI_FUNC(int) PyIter_NextItem(PyObject *iter, PyObject **item); Prefer PyIter_NextItem() instead. */ PyAPI_FUNC(PyObject *) PyIter_Next(PyObject *); -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030A0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 10) /* Takes generator, coroutine or iterator object and sends the value into it. Returns: @@ -885,7 +885,7 @@ PyAPI_FUNC(PyObject *) PyMapping_GetItemString(PyObject *o, If an error other than KeyError is raised, return -1 and set *result to NULL. */ -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 13) PyAPI_FUNC(int) PyMapping_GetOptionalItem(PyObject *, PyObject *, PyObject **); PyAPI_FUNC(int) PyMapping_GetOptionalItemString(PyObject *, const char *, PyObject **); #endif diff --git a/Include/audit.h b/Include/audit.h index 9be54ad44110963..e9f8cc371cdad87 100644 --- a/Include/audit.h +++ b/Include/audit.h @@ -5,7 +5,7 @@ extern "C" { #endif -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 13) PyAPI_FUNC(int) PySys_Audit( const char *event, const char *argFormat, diff --git a/Include/boolobject.h b/Include/boolobject.h index b56e2baecaa36c5..aa412780cfdfc27 100644 --- a/Include/boolobject.h +++ b/Include/boolobject.h @@ -18,7 +18,7 @@ PyAPI_DATA(PyLongObject) _Py_FalseStruct; PyAPI_DATA(PyLongObject) _Py_TrueStruct; /* Use these macros */ -#if defined(Py_LIMITED_API) && Py_LIMITED_API+0 >= 0x030D0000 +#if defined(Py_LIMITED_API) && Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 13) # define Py_False Py_GetConstantBorrowed(Py_CONSTANT_FALSE) # define Py_True Py_GetConstantBorrowed(Py_CONSTANT_TRUE) #else @@ -37,7 +37,7 @@ PyAPI_FUNC(int) Py_IsFalse(PyObject *x); /* Macros for returning Py_True or Py_False, respectively. * Only treat Py_True and Py_False as immortal in the limited C API 3.12 * and newer. */ -#if defined(Py_LIMITED_API) && Py_LIMITED_API+0 < 0x030c0000 +#if defined(Py_LIMITED_API) && Py_LIMITED_API+0 < _Py_PACK_VERSION(3, 12) # define Py_RETURN_TRUE return Py_NewRef(Py_True) # define Py_RETURN_FALSE return Py_NewRef(Py_False) #else diff --git a/Include/dictobject.h b/Include/dictobject.h index 0384e3131dcdb52..f6f0303237495c2 100644 --- a/Include/dictobject.h +++ b/Include/dictobject.h @@ -58,7 +58,7 @@ PyAPI_FUNC(PyObject *) PyDict_GetItemString(PyObject *dp, const char *key); PyAPI_FUNC(int) PyDict_SetItemString(PyObject *dp, const char *key, PyObject *item); PyAPI_FUNC(int) PyDict_DelItemString(PyObject *dp, const char *key); -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030D0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 13) // Return the object from dictionary *op* which has a key *key*. // - If the key is present, set *result to a new strong reference to the value // and return 1. @@ -68,7 +68,7 @@ PyAPI_FUNC(int) PyDict_GetItemRef(PyObject *mp, PyObject *key, PyObject **result PyAPI_FUNC(int) PyDict_GetItemStringRef(PyObject *mp, const char *key, PyObject **result); #endif -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030F0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 15) // Inserts `key` with a value `default_value`, if `key` is not already present // in the dictionary. If `result` is not NULL, then the value associated // with `key` is returned in `*result` (either the existing value, or the now @@ -80,7 +80,7 @@ PyAPI_FUNC(int) PyDict_GetItemStringRef(PyObject *mp, const char *key, PyObject PyAPI_FUNC(int) PyDict_SetDefaultRef(PyObject *mp, PyObject *key, PyObject *default_value, PyObject **result); #endif -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030A0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 10) PyAPI_FUNC(PyObject *) PyObject_GenericGetDict(PyObject *, void *); #endif diff --git a/Include/import.h b/Include/import.h index c062e46bff46bf7..95ab0228420a325 100644 --- a/Include/import.h +++ b/Include/import.h @@ -43,7 +43,7 @@ PyAPI_FUNC(PyObject *) PyImport_AddModuleObject( PyAPI_FUNC(PyObject *) PyImport_AddModule( const char *name /* UTF-8 encoded string */ ); -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 13) PyAPI_FUNC(PyObject *) PyImport_AddModuleRef( const char *name /* UTF-8 encoded string */ ); diff --git a/Include/listobject.h b/Include/listobject.h index e1e059b0ba7466c..48720a8a7a3453b 100644 --- a/Include/listobject.h +++ b/Include/listobject.h @@ -29,7 +29,7 @@ PyAPI_FUNC(PyObject *) PyList_New(Py_ssize_t size); PyAPI_FUNC(Py_ssize_t) PyList_Size(PyObject *); PyAPI_FUNC(PyObject *) PyList_GetItem(PyObject *, Py_ssize_t); -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 13) PyAPI_FUNC(PyObject *) PyList_GetItemRef(PyObject *, Py_ssize_t); #endif PyAPI_FUNC(int) PyList_SetItem(PyObject *, Py_ssize_t, PyObject *); diff --git a/Include/longobject.h b/Include/longobject.h index 38673bc18785fab..124675a6b7768a4 100644 --- a/Include/longobject.h +++ b/Include/longobject.h @@ -26,11 +26,11 @@ PyAPI_FUNC(size_t) PyLong_AsSize_t(PyObject *); PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLong(PyObject *); PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLongMask(PyObject *); -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 13) PyAPI_FUNC(int) PyLong_AsInt(PyObject *); #endif -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030e0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 14) PyAPI_FUNC(PyObject*) PyLong_FromInt32(int32_t value); PyAPI_FUNC(PyObject*) PyLong_FromUInt32(uint32_t value); PyAPI_FUNC(PyObject*) PyLong_FromInt64(int64_t value); @@ -104,7 +104,7 @@ PyAPI_FUNC(PyObject *) PyLong_GetInfo(void); #if !defined(SIZEOF_PID_T) || SIZEOF_PID_T == SIZEOF_INT #define _Py_PARSE_PID "i" #define PyLong_FromPid PyLong_FromLong -# if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000 +# if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 13) # define PyLong_AsPid PyLong_AsInt # elif SIZEOF_INT == SIZEOF_LONG # define PyLong_AsPid PyLong_AsLong diff --git a/Include/memoryobject.h b/Include/memoryobject.h index 2c9146aa2b5b06e..18064dfae449729 100644 --- a/Include/memoryobject.h +++ b/Include/memoryobject.h @@ -15,7 +15,7 @@ PyAPI_FUNC(PyObject *) PyMemoryView_FromObject(PyObject *base); PyAPI_FUNC(PyObject *) PyMemoryView_FromMemory(char *mem, Py_ssize_t size, int flags); #endif -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030b0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 11) PyAPI_FUNC(PyObject *) PyMemoryView_FromBuffer(const Py_buffer *info); #endif PyAPI_FUNC(PyObject *) PyMemoryView_GetContiguous(PyObject *base, diff --git a/Include/methodobject.h b/Include/methodobject.h index e6ec6421d1e59d5..8d10715118987a7 100644 --- a/Include/methodobject.h +++ b/Include/methodobject.h @@ -111,7 +111,7 @@ PyAPI_FUNC(PyObject *) PyCMethod_New(PyMethodDef *, PyObject *, #define METH_COEXIST 0x0040 -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030a0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 10) # define METH_FASTCALL 0x0080 #endif diff --git a/Include/modsupport.h b/Include/modsupport.h index 504a19d341a78a7..7cd227fd262f725 100644 --- a/Include/modsupport.h +++ b/Include/modsupport.h @@ -19,14 +19,14 @@ PyAPI_FUNC(int) PyArg_UnpackTuple(PyObject *, const char *, Py_ssize_t, Py_ssize PyAPI_FUNC(PyObject *) Py_BuildValue(const char *, ...); PyAPI_FUNC(PyObject *) Py_VaBuildValue(const char *, va_list); -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030a0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 10) // Add an attribute with name 'name' and value 'obj' to the module 'mod. // On success, return 0. // On error, raise an exception and return -1. PyAPI_FUNC(int) PyModule_AddObjectRef(PyObject *mod, const char *name, PyObject *value); #endif /* Py_LIMITED_API */ -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 13) // Similar to PyModule_AddObjectRef() but steal a reference to 'value'. PyAPI_FUNC(int) PyModule_Add(PyObject *mod, const char *name, PyObject *value); #endif /* Py_LIMITED_API */ diff --git a/Include/moduleobject.h b/Include/moduleobject.h index 3e12839ec509811..926432da2c371e2 100644 --- a/Include/moduleobject.h +++ b/Include/moduleobject.h @@ -76,14 +76,14 @@ struct PyModuleDef_Slot { #endif /* New in 3.5 */ /* for Py_mod_multiple_interpreters: */ -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030c0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 12) # define Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED ((void *)0) # define Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED ((void *)1) # define Py_MOD_PER_INTERPRETER_GIL_SUPPORTED ((void *)2) #endif /* for Py_mod_gil: */ -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 13) # define Py_MOD_GIL_USED ((void *)0) # define Py_MOD_GIL_NOT_USED ((void *)1) #endif diff --git a/Include/object.h b/Include/object.h index 549b91ebecf4f22..58b310fc018fa3b 100644 --- a/Include/object.h +++ b/Include/object.h @@ -317,7 +317,7 @@ typedef int (*initproc)(PyObject *, PyObject *, PyObject *); typedef PyObject *(*newfunc)(PyTypeObject *, PyObject *, PyObject *); typedef PyObject *(*allocfunc)(PyTypeObject *, Py_ssize_t); -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030c0000 // 3.12 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 12) // 3.12 typedef PyObject *(*vectorcallfunc)(PyObject *callable, PyObject *const *args, size_t nargsf, PyObject *kwnames); #endif @@ -347,20 +347,20 @@ PyAPI_FUNC(PyObject*) PyType_FromModuleAndSpec(PyObject *, PyType_Spec *, PyObje PyAPI_FUNC(PyObject *) PyType_GetModule(PyTypeObject *); PyAPI_FUNC(void *) PyType_GetModuleState(PyTypeObject *); #endif -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030B0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 11) PyAPI_FUNC(PyObject *) PyType_GetName(PyTypeObject *); PyAPI_FUNC(PyObject *) PyType_GetQualName(PyTypeObject *); #endif -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030D0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 13) PyAPI_FUNC(PyObject *) PyType_GetFullyQualifiedName(PyTypeObject *type); PyAPI_FUNC(PyObject *) PyType_GetModuleName(PyTypeObject *type); #endif -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030C0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 12) PyAPI_FUNC(PyObject *) PyType_FromMetaclass(PyTypeObject*, PyObject*, PyType_Spec*, PyObject*); PyAPI_FUNC(void *) PyObject_GetTypeData(PyObject *obj, PyTypeObject *cls); PyAPI_FUNC(Py_ssize_t) PyType_GetTypeDataSize(PyTypeObject *cls); #endif -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030E0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 14) PyAPI_FUNC(int) PyType_GetBaseByToken(PyTypeObject *, void *, PyTypeObject **); #define Py_TP_USE_SPEC NULL #endif @@ -374,7 +374,7 @@ PyAPI_FUNC(int) PyType_IsSubtype(PyTypeObject *, PyTypeObject *); static inline int PyObject_TypeCheck(PyObject *ob, PyTypeObject *type) { return Py_IS_TYPE(ob, type) || PyType_IsSubtype(Py_TYPE(ob), type); } -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < _Py_PACK_VERSION(3, 11) # define PyObject_TypeCheck(ob, type) PyObject_TypeCheck(_PyObject_CAST(ob), (type)) #endif @@ -403,14 +403,14 @@ PyAPI_FUNC(int) PyObject_SetAttrString(PyObject *, const char *, PyObject *); PyAPI_FUNC(int) PyObject_DelAttrString(PyObject *v, const char *name); PyAPI_FUNC(int) PyObject_HasAttrString(PyObject *, const char *); PyAPI_FUNC(PyObject *) PyObject_GetAttr(PyObject *, PyObject *); -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 13) PyAPI_FUNC(int) PyObject_GetOptionalAttr(PyObject *, PyObject *, PyObject **); PyAPI_FUNC(int) PyObject_GetOptionalAttrString(PyObject *, const char *, PyObject **); #endif PyAPI_FUNC(int) PyObject_SetAttr(PyObject *, PyObject *, PyObject *); PyAPI_FUNC(int) PyObject_DelAttr(PyObject *v, PyObject *name); PyAPI_FUNC(int) PyObject_HasAttr(PyObject *, PyObject *); -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 13) PyAPI_FUNC(int) PyObject_HasAttrWithError(PyObject *, PyObject *); PyAPI_FUNC(int) PyObject_HasAttrStringWithError(PyObject *, const char *); #endif @@ -506,7 +506,7 @@ given type object has a specified feature. #define Py_TPFLAGS_BASETYPE (1UL << 10) /* Set if the type implements the vectorcall protocol (PEP 590) */ -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030C0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 12) #define Py_TPFLAGS_HAVE_VECTORCALL (1UL << 11) #ifndef Py_LIMITED_API // Backwards compatibility alias for API that was provisional in Python 3.8 @@ -598,7 +598,7 @@ given type object has a specified feature. #define Py_CONSTANT_EMPTY_BYTES 8 #define Py_CONSTANT_EMPTY_TUPLE 9 -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 13) PyAPI_FUNC(PyObject*) Py_GetConstant(unsigned int constant_id); PyAPI_FUNC(PyObject*) Py_GetConstantBorrowed(unsigned int constant_id); #endif @@ -610,7 +610,7 @@ where NULL (nil) is not suitable (since NULL often means 'error'). */ PyAPI_DATA(PyObject) _Py_NoneStruct; /* Don't use this directly */ -#if defined(Py_LIMITED_API) && Py_LIMITED_API+0 >= 0x030D0000 +#if defined(Py_LIMITED_API) && Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 13) # define Py_None Py_GetConstantBorrowed(Py_CONSTANT_NONE) #else # define Py_None (&_Py_NoneStruct) @@ -622,7 +622,7 @@ PyAPI_FUNC(int) Py_IsNone(PyObject *x); /* Macro for returning Py_None from a function. * Only treat Py_None as immortal in the limited C API 3.12 and newer. */ -#if defined(Py_LIMITED_API) && Py_LIMITED_API+0 < 0x030c0000 +#if defined(Py_LIMITED_API) && Py_LIMITED_API+0 < _Py_PACK_VERSION(3, 12) # define Py_RETURN_NONE return Py_NewRef(Py_None) #else # define Py_RETURN_NONE return Py_None @@ -634,7 +634,7 @@ not implemented for a given type combination. */ PyAPI_DATA(PyObject) _Py_NotImplementedStruct; /* Don't use this directly */ -#if defined(Py_LIMITED_API) && Py_LIMITED_API+0 >= 0x030D0000 +#if defined(Py_LIMITED_API) && Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 13) # define Py_NotImplemented Py_GetConstantBorrowed(Py_CONSTANT_NOT_IMPLEMENTED) #else # define Py_NotImplemented (&_Py_NotImplementedStruct) @@ -642,7 +642,7 @@ PyAPI_DATA(PyObject) _Py_NotImplementedStruct; /* Don't use this directly */ /* Macro for returning Py_NotImplemented from a function. Only treat * Py_NotImplemented as immortal in the limited C API 3.12 and newer. */ -#if defined(Py_LIMITED_API) && Py_LIMITED_API+0 < 0x030c0000 +#if defined(Py_LIMITED_API) && Py_LIMITED_API+0 < _Py_PACK_VERSION(3, 12) # define Py_RETURN_NOTIMPLEMENTED return Py_NewRef(Py_NotImplemented) #else # define Py_RETURN_NOTIMPLEMENTED return Py_NotImplemented @@ -656,7 +656,7 @@ PyAPI_DATA(PyObject) _Py_NotImplementedStruct; /* Don't use this directly */ #define Py_GT 4 #define Py_GE 5 -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030A0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 10) /* Result of calling PyIter_Send */ typedef enum { PYGEN_RETURN = 0, @@ -762,7 +762,7 @@ PyType_HasFeature(PyTypeObject *type, unsigned long feature) static inline int PyType_Check(PyObject *op) { return PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_TYPE_SUBCLASS); } -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < _Py_PACK_VERSION(3, 11) # define PyType_Check(op) PyType_Check(_PyObject_CAST(op)) #endif @@ -772,15 +772,15 @@ static inline int PyType_Check(PyObject *op) { static inline int PyType_CheckExact(PyObject *op) { return Py_IS_TYPE(op, &PyType_Type); } -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < _Py_PACK_VERSION(3, 11) # define PyType_CheckExact(op) PyType_CheckExact(_PyObject_CAST(op)) #endif -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 13) PyAPI_FUNC(PyObject *) PyType_GetModuleByDef(PyTypeObject *, PyModuleDef *); #endif -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030e0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 14) PyAPI_FUNC(int) PyType_Freeze(PyTypeObject *type); #endif diff --git a/Include/patchlevel.h b/Include/patchlevel.h index 5723d1be301af45..96787626d91fe4b 100644 --- a/Include/patchlevel.h +++ b/Include/patchlevel.h @@ -37,6 +37,7 @@ (((Z) & 0xff) << 8) | \ (((LEVEL) & 0xf) << 4) | \ (((SERIAL) & 0xf) << 0)) +#define _Py_PACK_VERSION(X, Y) _Py_PACK_FULL_VERSION(X, Y, 0, 0, 0) /* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. Use this for numeric comparisons, e.g. #if PY_VERSION_HEX >= ... */ diff --git a/Include/pybuffer.h b/Include/pybuffer.h index 6371b9b483777ba..7624e967302c133 100644 --- a/Include/pybuffer.h +++ b/Include/pybuffer.h @@ -6,7 +6,7 @@ extern "C" { #endif -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030b0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 11) /* === New Buffer API ============================================ * Limited API and stable ABI since Python 3.11 diff --git a/Include/pyerrors.h b/Include/pyerrors.h index cfabbc5fe8d5da0..0f93d2791fb575b 100644 --- a/Include/pyerrors.h +++ b/Include/pyerrors.h @@ -18,7 +18,7 @@ PyAPI_FUNC(void) PyErr_Fetch(PyObject **, PyObject **, PyObject **); PyAPI_FUNC(void) PyErr_Restore(PyObject *, PyObject *, PyObject *); PyAPI_FUNC(PyObject *) PyErr_GetRaisedException(void); PyAPI_FUNC(void) PyErr_SetRaisedException(PyObject *); -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030b0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 11) PyAPI_FUNC(PyObject*) PyErr_GetHandledException(void); PyAPI_FUNC(void) PyErr_SetHandledException(PyObject *); #endif @@ -239,7 +239,7 @@ PyAPI_FUNC(void) PyErr_WriteUnraisable(PyObject *); /* In signalmodule.c */ PyAPI_FUNC(int) PyErr_CheckSignals(void); PyAPI_FUNC(void) PyErr_SetInterrupt(void); -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030A0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 10) PyAPI_FUNC(int) PyErr_SetInterruptEx(int signum); #endif diff --git a/Include/pylifecycle.h b/Include/pylifecycle.h index f11ac4d2a9f10e9..c1501c6cb28e23e 100644 --- a/Include/pylifecycle.h +++ b/Include/pylifecycle.h @@ -49,11 +49,11 @@ typedef void (*PyOS_sighandler_t)(int); PyAPI_FUNC(PyOS_sighandler_t) PyOS_getsig(int); PyAPI_FUNC(PyOS_sighandler_t) PyOS_setsig(int, PyOS_sighandler_t); -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030B0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 11) PyAPI_DATA(const unsigned long) Py_Version; #endif -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030D0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 13) PyAPI_FUNC(int) Py_IsFinalizing(void); #endif diff --git a/Include/pymacro.h b/Include/pymacro.h index f08ed1a1ecf0f9f..f67ddc2b88fbbcc 100644 --- a/Include/pymacro.h +++ b/Include/pymacro.h @@ -318,7 +318,6 @@ #define _Py_IS_TYPE_SIGNED(type) ((type)(-1) <= 0) // Version helpers. These are primarily macros, but have exported equivalents. -#define _Py_PACK_VERSION(X, Y) _Py_PACK_FULL_VERSION(X, Y, 0, 0, 0) #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 14) PyAPI_FUNC(uint32_t) Py_PACK_FULL_VERSION(int x, int y, int z, int level, int serial); PyAPI_FUNC(uint32_t) Py_PACK_VERSION(int x, int y); diff --git a/Include/pymem.h b/Include/pymem.h index a80da99e1dd7fc5..6162148a996d7d9 100644 --- a/Include/pymem.h +++ b/Include/pymem.h @@ -87,7 +87,7 @@ PyAPI_FUNC(void) PyMem_Free(void *ptr); #define PyMem_DEL(p) PyMem_Free((p)) -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 13) // Memory allocator which doesn't require the GIL to be held. // Usually, it's just a thin wrapper to functions of the standard C library: // malloc(), calloc(), realloc() and free(). The difference is that diff --git a/Include/pyport.h b/Include/pyport.h index de1240be76b3dad..ca597d9f119363d 100644 --- a/Include/pyport.h +++ b/Include/pyport.h @@ -190,7 +190,7 @@ typedef Py_ssize_t Py_ssize_clean_t; #endif // Soft deprecated since Python 3.14, use memcpy() instead. -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < _Py_PACK_VERSION(3, 11) # define Py_MEMCPY memcpy #endif diff --git a/Include/pythonrun.h b/Include/pythonrun.h index 92b50aa807bf704..af706c91387aea8 100644 --- a/Include/pythonrun.h +++ b/Include/pythonrun.h @@ -13,7 +13,7 @@ PyAPI_FUNC(void) PyErr_Print(void); PyAPI_FUNC(void) PyErr_PrintEx(int); PyAPI_FUNC(void) PyErr_Display(PyObject *, PyObject *, PyObject *); -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030C0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 12) PyAPI_FUNC(void) PyErr_DisplayException(PyObject *); #endif diff --git a/Include/refcount.h b/Include/refcount.h index 9b681f6a254a42a..86c023ff46a6533 100644 --- a/Include/refcount.h +++ b/Include/refcount.h @@ -96,7 +96,7 @@ check by comparing the reference count field to the minimum immortality refcount // Py_REFCNT() implementation for the stable ABI PyAPI_FUNC(Py_ssize_t) Py_REFCNT(PyObject *ob); -#if defined(Py_LIMITED_API) && Py_LIMITED_API+0 >= 0x030e0000 +#if defined(Py_LIMITED_API) && Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 14) // Stable ABI implements Py_REFCNT() as a function call // on limited C API version 3.14 and newer, and on abi3t. #elif defined(_Py_OPAQUE_PYOBJECT) @@ -115,7 +115,7 @@ PyAPI_FUNC(Py_ssize_t) Py_REFCNT(PyObject *ob); Py_ARITHMETIC_RIGHT_SHIFT(Py_ssize_t, shared, _Py_REF_SHARED_SHIFT); #endif } - #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 + #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < _Py_PACK_VERSION(3, 11) # define Py_REFCNT(ob) _Py_REFCNT(_PyObject_CAST(ob)) #else # define Py_REFCNT(ob) _Py_REFCNT(ob) @@ -153,7 +153,7 @@ PyAPI_FUNC(void) _Py_SetRefcnt(PyObject *ob, Py_ssize_t refcnt); static inline void Py_SET_REFCNT(PyObject *ob, Py_ssize_t refcnt) { assert(refcnt >= 0); -#if (defined(Py_LIMITED_API) && Py_LIMITED_API+0 >= 0x030d0000) \ +#if (defined(Py_LIMITED_API) && Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 13)) \ || defined(_Py_OPAQUE_PYOBJECT) // Stable ABI implements Py_SET_REFCNT() as a function call // on limited C API version 3.13 and newer, and abi3t. @@ -197,7 +197,7 @@ static inline void Py_SET_REFCNT(PyObject *ob, Py_ssize_t refcnt) { #endif // Py_GIL_DISABLED #endif // Py_LIMITED_API } -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < _Py_PACK_VERSION(3, 11) # define Py_SET_REFCNT(ob, refcnt) Py_SET_REFCNT(_PyObject_CAST(ob), (refcnt)) #endif @@ -254,13 +254,13 @@ PyAPI_FUNC(void) _Py_DecRef(PyObject *); static inline Py_ALWAYS_INLINE void Py_INCREF(PyObject *op) { -#if (defined(Py_LIMITED_API) && (Py_LIMITED_API+0 >= 0x030c0000 || defined(Py_REF_DEBUG))) \ +#if (defined(Py_LIMITED_API) && (Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 12) || defined(Py_REF_DEBUG))) \ || defined(_Py_OPAQUE_PYOBJECT) // Stable ABI implements Py_INCREF() as a function call on limited C API // version 3.12 and newer, abi3t, and on Python built in debug mode. // _Py_IncRef() was added to Python 3.10.0a7, use Py_IncRef() on older versions. // Py_IncRef() accepts NULL whereas _Py_IncRef() doesn't. -# if Py_LIMITED_API+0 >= 0x030a00A7 +# if Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 10) _Py_IncRef(op); # else Py_IncRef(op); @@ -306,7 +306,7 @@ static inline Py_ALWAYS_INLINE void Py_INCREF(PyObject *op) #endif #endif } -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < _Py_PACK_VERSION(3, 11) # define Py_INCREF(op) Py_INCREF(_PyObject_CAST(op)) #endif @@ -324,14 +324,14 @@ PyAPI_FUNC(void) _Py_MergeZeroLocalRefcount(PyObject *); #endif // Py_GIL_DISABLED #endif // Py_LIMITED_API -#if (defined(Py_LIMITED_API) && (Py_LIMITED_API+0 >= 0x030c0000 || defined(Py_REF_DEBUG))) \ +#if (defined(Py_LIMITED_API) && (Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 12) || defined(Py_REF_DEBUG))) \ || defined(_Py_OPAQUE_PYOBJECT) // Stable ABI implements Py_DECREF() as a function call on limited C API // version 3.12 and newer, abi3t, and on Python built in debug mode. // _Py_DecRef() was added to Python 3.10.0a7, use Py_DecRef() on older versions. // Py_DecRef() accepts NULL whereas _Py_DecRef() doesn't. static inline void Py_DECREF(PyObject *op) { -# if Py_LIMITED_API+0 >= 0x030a00A7 +# if Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 10) _Py_DecRef(op); # else Py_DecRef(op); @@ -607,7 +607,7 @@ static inline void Py_XINCREF(PyObject *op) Py_INCREF(op); } } -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < _Py_PACK_VERSION(3, 11) # define Py_XINCREF(op) Py_XINCREF(_PyObject_CAST(op)) #endif @@ -617,7 +617,7 @@ static inline void Py_XDECREF(PyObject *op) Py_DECREF(op); } } -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < _Py_PACK_VERSION(3, 11) # define Py_XDECREF(op) Py_XDECREF(_PyObject_CAST(op)) #endif @@ -643,7 +643,7 @@ static inline PyObject* _Py_XNewRef(PyObject *obj) // Py_NewRef() and Py_XNewRef() are exported as functions for the stable ABI. // Names overridden with macros by static inline functions for best // performances. -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < _Py_PACK_VERSION(3, 11) # define Py_NewRef(obj) _Py_NewRef(_PyObject_CAST(obj)) # define Py_XNewRef(obj) _Py_XNewRef(_PyObject_CAST(obj)) #else diff --git a/Include/sliceobject.h b/Include/sliceobject.h index 9d6a16da95fe2f5..0c1141ac2b7c92e 100644 --- a/Include/sliceobject.h +++ b/Include/sliceobject.h @@ -8,7 +8,7 @@ extern "C" { PyAPI_DATA(PyObject) _Py_EllipsisObject; /* Don't use this directly */ -#if defined(Py_LIMITED_API) && Py_LIMITED_API+0 >= 0x030D0000 +#if defined(Py_LIMITED_API) && Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 13) # define Py_Ellipsis Py_GetConstantBorrowed(Py_CONSTANT_ELLIPSIS) #else # define Py_Ellipsis (&_Py_EllipsisObject) diff --git a/Include/sysmodule.h b/Include/sysmodule.h index fc6da6f4c797b36..85521a6546dde93 100644 --- a/Include/sysmodule.h +++ b/Include/sysmodule.h @@ -4,7 +4,7 @@ extern "C" { #endif -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030f0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 15) PyAPI_FUNC(PyObject *) PySys_GetAttr(PyObject *); PyAPI_FUNC(PyObject *) PySys_GetAttrString(const char *); PyAPI_FUNC(int) PySys_GetOptionalAttr(PyObject *, PyObject **); diff --git a/Include/unicodeobject.h b/Include/unicodeobject.h index fbced4896bd0143..301b841944c744e 100644 --- a/Include/unicodeobject.h +++ b/Include/unicodeobject.h @@ -397,7 +397,7 @@ PyAPI_FUNC(PyObject*) PyUnicode_AsUTF8String( when the unicodeobject is deallocated. */ -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030A0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 10) PyAPI_FUNC(const char *) PyUnicode_AsUTF8AndSize( PyObject *unicode, Py_ssize_t *size); @@ -900,7 +900,7 @@ PyAPI_FUNC(int) PyUnicode_CompareWithASCIIString( const char *right /* ASCII-encoded string */ ); -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030D0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 13) /* Compare a Unicode object with UTF-8 encoded C string. Return 1 if they are equal, or 0 otherwise. This function does not raise exceptions. */ @@ -909,7 +909,7 @@ PyAPI_FUNC(int) PyUnicode_EqualToUTF8(PyObject *, const char *); PyAPI_FUNC(int) PyUnicode_EqualToUTF8AndSize(PyObject *, const char *, Py_ssize_t); #endif -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030e0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 14) PyAPI_FUNC(int) PyUnicode_Equal(PyObject *str1, PyObject *str2); #endif diff --git a/Include/weakrefobject.h b/Include/weakrefobject.h index 17fac62961c0fb8..421995143482ee3 100644 --- a/Include/weakrefobject.h +++ b/Include/weakrefobject.h @@ -28,7 +28,7 @@ PyAPI_FUNC(PyObject *) PyWeakref_NewRef(PyObject *ob, PyAPI_FUNC(PyObject *) PyWeakref_NewProxy(PyObject *ob, PyObject *callback); -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030D0000 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 13) PyAPI_FUNC(int) PyWeakref_GetRef(PyObject *ref, PyObject **pobj); #endif