| 1 |
+++++++++++++++++++++++ |
| 2 |
pythoncapi_compat.h API |
| 3 |
+++++++++++++++++++++++ |
| 4 |
|
| 5 |
The ``pythoncapi_compat.h`` header file provides implementations of recent |
| 6 |
functions for old Python versions. |
| 7 |
|
| 8 |
Supported Python versions: |
| 9 |
|
| 10 |
* Python 3.6 - 3.14 |
| 11 |
* PyPy 2.7 and PyPy 3.6 - 3.10 |
| 12 |
|
| 13 |
Python 2.7 and Python 3.5 are no longer officially supported since GitHub |
| 14 |
Actions doesn't support them anymore: only best effort support is provided. |
| 15 |
|
| 16 |
C++03 and C++11 are supported on Python 3.6 and newer. |
| 17 |
|
| 18 |
A C11 subset (without optional features) is required, like ``static inline`` |
| 19 |
functions: see `PEP 7 <https://www.python.org/dev/peps/pep-0007/>`_. ISO C90 |
| 20 |
is partially supported for Python 2.7. |
| 21 |
|
| 22 |
Some functions related to frame objects and ``PyThreadState`` are not available |
| 23 |
on PyPy. |
| 24 |
|
| 25 |
Latest version of the header file: |
| 26 |
`pythoncapi_compat.h <https://raw.githubusercontent.com/python/pythoncapi-compat/main/pythoncapi_compat.h>`_. |
| 27 |
|
| 28 |
|
| 29 |
Python 3.15 |
| 30 |
----------- |
| 31 |
|
| 32 |
.. c:function:: PyObject* PySys_GetAttr(const char *name) |
| 33 |
|
| 34 |
See `PySys_GetAttr() documentation <https://docs.python.org/dev/c-api/sys.html#c.PySys_GetAttr>`__. |
| 35 |
|
| 36 |
.. c:function:: PyObject* PySys_GetAttrString(const char *name) |
| 37 |
|
| 38 |
See `PySys_GetAttrString() documentation <https://docs.python.org/dev/c-api/sys.html#c.PySys_GetAttrString>`__. |
| 39 |
|
| 40 |
.. c:function:: PyObject* PySys_GetOptionalAttr(const char *name) |
| 41 |
|
| 42 |
See `PySys_GetOptionalAttr() documentation <https://docs.python.org/dev/c-api/sys.html#c.PySys_GetOptionalAttr>`__. |
| 43 |
|
| 44 |
.. c:function:: PyObject* PySys_GetOptionalAttrString(const char *name) |
| 45 |
|
| 46 |
See `PySys_GetOptionalAttrString() documentation <https://docs.python.org/dev/c-api/sys.html#c.PySys_GetOptionalAttrString>`__. |
| 47 |
|
| 48 |
.. c:function:: PyBytesWriter* PyBytesWriter_Create(Py_ssize_t size) |
| 49 |
.. c:function:: void* PyBytesWriter_GetData(PyBytesWriter *writer) |
| 50 |
.. c:function:: Py_ssize_t PyBytesWriter_GetSize(PyBytesWriter *writer) |
| 51 |
.. c:function:: PyObject* PyBytesWriter_FinishWithSize(PyBytesWriter *writer, Py_ssize_t size) |
| 52 |
.. c:function:: PyObject* PyBytesWriter_Finish(PyBytesWriter *writer) |
| 53 |
.. c:function:: PyObject* PyBytesWriter_FinishWithPointer(PyBytesWriter *writer, void *buf) |
| 54 |
.. c:function:: void PyBytesWriter_Discard(PyBytesWriter *writer) |
| 55 |
.. c:function:: int PyBytesWriter_Resize(PyBytesWriter *writer, Py_ssize_t size) |
| 56 |
.. c:function:: int PyBytesWriter_Grow(PyBytesWriter *writer, Py_ssize_t size) |
| 57 |
.. c:function:: void* PyBytesWriter_GrowAndUpdatePointer(PyBytesWriter *writer, Py_ssize_t size, void *buf) |
| 58 |
.. c:function:: int PyBytesWriter_WriteBytes(PyBytesWriter *writer, const void *bytes, Py_ssize_t size) |
| 59 |
.. c:function:: int PyBytesWriter_Format(PyBytesWriter *writer, const char *format, ...) |
| 60 |
|
| 61 |
See `PyBytesWriter documentation <https://docs.python.org/dev/c-api/bytes.html#pybyteswriter>`__. |
| 62 |
|
| 63 |
|
| 64 |
Python 3.14 |
| 65 |
----------- |
| 66 |
|
| 67 |
.. c:struct:: PyLongLayout |
| 68 |
|
| 69 |
See `PyLongLayout documentation <https://docs.python.org/dev/c-api/long.html#c.PyLongLayout>`__. |
| 70 |
|
| 71 |
.. c:function:: const PyLongLayout* PyLong_GetNativeLayout(void) |
| 72 |
|
| 73 |
See `PyLong_GetNativeLayout() documentation <https://docs.python.org/dev/c-api/long.html#c.PyLong_GetNativeLayout>`__. |
| 74 |
|
| 75 |
.. c:struct:: PyLongExport |
| 76 |
|
| 77 |
See `PyLongExport documentation <https://docs.python.org/dev/c-api/long.html#c.PyLongExport>`__. |
| 78 |
|
| 79 |
.. c:function:: int PyLong_Export(PyObject *obj, PyLongExport *export_long) |
| 80 |
|
| 81 |
See `PyLong_Export() documentation <https://docs.python.org/dev/c-api/long.html#c.PyLong_Export>`__. |
| 82 |
|
| 83 |
.. c:function:: void PyLong_FreeExport(PyLongExport *export_long) |
| 84 |
|
| 85 |
See `PyLong_FreeExport() documentation <https://docs.python.org/dev/c-api/long.html#c.PyLong_FreeExport>`__. |
| 86 |
|
| 87 |
.. c:struct:: PyLongWriter |
| 88 |
|
| 89 |
See `PyLongWriter documentation <https://docs.python.org/dev/c-api/long.html#c.PyLongWriter>`__. |
| 90 |
|
| 91 |
.. c:function:: PyLongWriter* PyLongWriter_Create(int negative, Py_ssize_t ndigits, void **digits) |
| 92 |
|
| 93 |
See `PyLongWriter_Create() documentation <https://docs.python.org/dev/c-api/long.html#c.PyLongWriter_Create>`__. |
| 94 |
|
| 95 |
.. c:function:: PyObject* PyLongWriter_Finish(PyLongWriter *writer) |
| 96 |
|
| 97 |
See `PyLongWriter_Finish() documentation <https://docs.python.org/dev/c-api/long.html#c.PyLongWriter_Finish>`__. |
| 98 |
|
| 99 |
.. c:function:: void PyLongWriter_Discard(PyLongWriter *writer) |
| 100 |
|
| 101 |
See `PyLongWriter_Discard() documentation <https://docs.python.org/dev/c-api/long.html#c.PyLongWriter_Discard>`__. |
| 102 |
|
| 103 |
.. c:function:: int PyLong_IsPositive(PyObject *obj) |
| 104 |
|
| 105 |
See `PyLong_IsPositive() documentation <https://docs.python.org/dev/c-api/long.html#c.PyLong_IsPositive>`__. |
| 106 |
|
| 107 |
.. c:function:: int PyLong_IsNegative(PyObject *obj) |
| 108 |
|
| 109 |
See `PyLong_IsNegative() documentation <https://docs.python.org/dev/c-api/long.html#c.PyLong_IsNegative>`__. |
| 110 |
|
| 111 |
.. c:function:: int PyLong_IsZero(PyObject *obj) |
| 112 |
|
| 113 |
See `PyLong_IsZero() documentation <https://docs.python.org/dev/c-api/long.html#c.PyLong_IsZero>`__. |
| 114 |
|
| 115 |
.. c:function:: int PyLong_GetSign(PyObject *obj, int *sign) |
| 116 |
|
| 117 |
See `PyLong_GetSign() documentation <https://docs.python.org/dev/c-api/long.html#c.PyLong_GetSign>`__. |
| 118 |
|
| 119 |
.. c:function:: PyObject* PyIter_NextItem(PyObject *sep, PyObject *iterable) |
| 120 |
|
| 121 |
See `PyIter_NextItem() documentation <https://docs.python.org/dev/c-api/iter.html#c.PyIter_NextItem>`__. |
| 122 |
|
| 123 |
.. c:function:: PyObject* PyBytes_Join(PyObject *sep, PyObject *iterable) |
| 124 |
|
| 125 |
See `PyBytes_Join() documentation <https://docs.python.org/dev/c-api/bytes.html#c.PyBytes_Join>`__. |
| 126 |
|
| 127 |
.. c:function:: Py_hash_t Py_HashBuffer(const void *ptr, Py_ssize_t len) |
| 128 |
|
| 129 |
See `Py_HashBuffer() documentation <https://docs.python.org/dev/c-api/hash.html#c.Py_HashBuffer>`__. |
| 130 |
|
| 131 |
.. c:function:: int PyUnicode_Equal(PyObject *str1, PyObject *str2) |
| 132 |
|
| 133 |
See `PyUnicode_Equal() documentation <https://docs.python.org/dev/c-api/unicode.html#c.PyUnicode_Equal>`__. |
| 134 |
|
| 135 |
.. c:function:: PyUnicodeWriter* PyUnicodeWriter_Create(Py_ssize_t length) |
| 136 |
|
| 137 |
See `PyUnicodeWriter_Create() documentation <https://docs.python.org/dev/c-api/unicode.html#c.PyUnicodeWriter_Create>`__. |
| 138 |
|
| 139 |
.. c:function:: PyObject* PyUnicodeWriter_Finish(PyUnicodeWriter *writer) |
| 140 |
|
| 141 |
See `PyUnicodeWriter_Finish() documentation <https://docs.python.org/dev/c-api/unicode.html#c.PyUnicodeWriter_Finish>`__. |
| 142 |
|
| 143 |
.. c:function:: void PyUnicodeWriter_Discard(PyUnicodeWriter *writer) |
| 144 |
|
| 145 |
See `PyUnicodeWriter_Discard() documentation <https://docs.python.org/dev/c-api/unicode.html#c.PyUnicodeWriter_Discard>`__. |
| 146 |
|
| 147 |
.. c:function:: int PyUnicodeWriter_WriteChar(PyUnicodeWriter *writer, Py_UCS4 ch) |
| 148 |
|
| 149 |
See `PyUnicodeWriter_WriteChar() documentation <https://docs.python.org/dev/c-api/unicode.html#c.PyUnicodeWriter_WriteChar>`__. |
| 150 |
|
| 151 |
.. c:function:: int PyUnicodeWriter_WriteUTF8(PyUnicodeWriter *writer, const char *str, Py_ssize_t size) |
| 152 |
|
| 153 |
See `PyUnicodeWriter_WriteUTF8() documentation <https://docs.python.org/dev/c-api/unicode.html#c.PyUnicodeWriter_WriteUTF8>`__. |
| 154 |
|
| 155 |
.. c:function:: int PyUnicodeWriter_WriteASCII(PyUnicodeWriter *writer, const char *str, Py_ssize_t size) |
| 156 |
|
| 157 |
See `PyUnicodeWriter_WriteASCII() documentation <https://docs.python.org/dev/c-api/unicode.html#c.PyUnicodeWriter_WriteASCII>`__. |
| 158 |
|
| 159 |
.. c:function:: int PyUnicodeWriter_WriteWideChar(PyUnicodeWriter *writer, const wchar_t *str, Py_ssize_t size) |
| 160 |
|
| 161 |
See `PyUnicodeWriter_WriteWideChar() documentation <https://docs.python.org/dev/c-api/unicode.html#c.PyUnicodeWriter_WriteWideChar>`__. |
| 162 |
|
| 163 |
.. c:function:: int PyUnicodeWriter_WriteStr(PyUnicodeWriter *writer, PyObject *obj) |
| 164 |
|
| 165 |
See `PyUnicodeWriter_WriteStr() documentation <https://docs.python.org/dev/c-api/unicode.html#c.PyUnicodeWriter_WriteStr>`__. |
| 166 |
|
| 167 |
.. c:function:: int PyUnicodeWriter_WriteRepr(PyUnicodeWriter *writer, PyObject *obj) |
| 168 |
|
| 169 |
See `PyUnicodeWriter_WriteRepr() documentation <https://docs.python.org/dev/c-api/unicode.html#c.PyUnicodeWriter_WriteRepr>`__. |
| 170 |
|
| 171 |
.. c:function:: int PyUnicodeWriter_WriteSubstring(PyUnicodeWriter *writer, PyObject *str, Py_ssize_t start, Py_ssize_t end) |
| 172 |
|
| 173 |
See `PyUnicodeWriter_WriteSubstring() documentation <https://docs.python.org/dev/c-api/unicode.html#c.PyUnicodeWriter_WriteSubstring>`__. |
| 174 |
|
| 175 |
.. c:function:: int PyUnicodeWriter_Format(PyUnicodeWriter *writer, const char *format, ...) |
| 176 |
|
| 177 |
See `PyUnicodeWriter_Format() documentation <https://docs.python.org/dev/c-api/unicode.html#c.PyUnicodeWriter_Format>`__. |
| 178 |
|
| 179 |
.. c:function:: int PyLong_AsInt32(PyObject *obj, int32_t *pvalue) |
| 180 |
|
| 181 |
See `PyLong_AsInt32() documentation <https://docs.python.org/dev/c-api/long.html#c.PyLong_AsInt32>`__. |
| 182 |
|
| 183 |
.. c:function:: int PyLong_AsInt64(PyObject *obj, int64_t *pvalue) |
| 184 |
|
| 185 |
See `PyLong_AsInt64() documentation <https://docs.python.org/dev/c-api/long.html#c.PyLong_AsInt64>`__. |
| 186 |
|
| 187 |
.. c:function:: int PyLong_AsUInt32(PyObject *obj, uint32_t *pvalue) |
| 188 |
|
| 189 |
See `PyLong_AsUInt32() documentation <https://docs.python.org/dev/c-api/long.html#c.PyLong_AsUInt32>`__. |
| 190 |
|
| 191 |
.. c:function:: int PyLong_AsUInt64(PyObject *obj, uint64_t *pvalue) |
| 192 |
|
| 193 |
See `PyLong_AsUInt64() documentation <https://docs.python.org/dev/c-api/long.html#c.PyLong_AsUInt64>`__. |
| 194 |
|
| 195 |
.. c:function:: PyObject* PyLong_FromInt32(int32_t value) |
| 196 |
|
| 197 |
See `PyLong_FromInt32() documentation <https://docs.python.org/dev/c-api/long.html#c.PyLong_FromInt32>`__. |
| 198 |
|
| 199 |
.. c:function:: PyObject* PyLong_FromInt64(int64_t value) |
| 200 |
|
| 201 |
See `PyLong_FromInt64() documentation <https://docs.python.org/dev/c-api/long.html#c.PyLong_FromInt64>`__. |
| 202 |
|
| 203 |
.. c:function:: PyObject* PyLong_FromUInt32(uint32_t value) |
| 204 |
|
| 205 |
See `PyLong_FromUInt32() documentation <https://docs.python.org/dev/c-api/long.html#c.PyLong_FromUInt32>`__. |
| 206 |
|
| 207 |
.. c:function:: PyObject* PyLong_FromUInt64(uint64_t value) |
| 208 |
|
| 209 |
See `PyLong_FromUInt64() documentation <https://docs.python.org/dev/c-api/long.html#c.PyLong_FromUInt64>`__. |
| 210 |
|
| 211 |
.. c:function:: FILE* Py_fopen(PyObject *path, const char *mode) |
| 212 |
|
| 213 |
See `Py_fopen() documentation <https://docs.python.org/dev/c-api/sys.html#c.Py_fopen>`__. |
| 214 |
|
| 215 |
.. c:function:: int Py_fclose(FILE *file) |
| 216 |
|
| 217 |
See `Py_fclose() documentation <https://docs.python.org/dev/c-api/sys.html#c.Py_fclose>`__. |
| 218 |
|
| 219 |
.. c:function:: PyObject* PyConfig_Get(const char *name) |
| 220 |
|
| 221 |
See `PyConfig_Get() documentation <https://docs.python.org/dev/c-api/init_config.html#c.PyConfig_Get>`__. |
| 222 |
|
| 223 |
.. c:function:: int PyConfig_GetInt(const char *name, int *value) |
| 224 |
|
| 225 |
See `PyConfig_GetInt() documentation <https://docs.python.org/dev/c-api/init_config.html#c.PyConfig_GetInt>`__. |
| 226 |
|
| 227 |
.. c:function:: int PyUnstable_Object_IsUniquelyReferenced(PyObject *op) |
| 228 |
|
| 229 |
See `PyUnstable_Object_IsUniquelyReferenced() documentation <https://docs.python.org/dev/c-api/object.html#c.PyUnstable_Object_IsUniquelyReferenced>`__. |
| 230 |
|
| 231 |
Not supported: |
| 232 |
|
| 233 |
* ``PyConfig_Names()`` |
| 234 |
* ``PyConfig_Set()`` |
| 235 |
* ``PyInitConfig_AddModule()`` |
| 236 |
* ``PyInitConfig_Create()`` |
| 237 |
* ``PyInitConfig_Free()`` |
| 238 |
* ``PyInitConfig_FreeStrList()`` |
| 239 |
* ``PyInitConfig_GetError()`` |
| 240 |
* ``PyInitConfig_GetExitCode()`` |
| 241 |
* ``PyInitConfig_GetInt()`` |
| 242 |
* ``PyInitConfig_GetStr()`` |
| 243 |
* ``PyInitConfig_GetStrList()`` |
| 244 |
* ``PyInitConfig_HasOption()`` |
| 245 |
* ``PyInitConfig_SetInt()`` |
| 246 |
* ``PyInitConfig_SetStr()`` |
| 247 |
* ``PyInitConfig_SetStrList()`` |
| 248 |
* ``PyType_GetBaseByToken()`` |
| 249 |
* ``PyUnicodeWriter_DecodeUTF8Stateful()`` |
| 250 |
* ``Py_InitializeFromInitConfig()`` |
| 251 |
|
| 252 |
|
| 253 |
Python 3.13 |
| 254 |
----------- |
| 255 |
|
| 256 |
.. c:function:: int PyDict_GetItemRef(PyObject *p, PyObject *key, PyObject **result) |
| 257 |
|
| 258 |
See `PyDict_GetItemRef() documentation <https://docs.python.org/dev/c-api/dict.html#c.PyDict_GetItemRef>`__. |
| 259 |
|
| 260 |
.. c:function:: int PyDict_GetItemStringRef(PyObject *p, const char *key, PyObject **result) |
| 261 |
|
| 262 |
See `PyDict_GetItemStringRef() documentation <https://docs.python.org/dev/c-api/dict.html#c.PyDict_GetItemStringRef>`__. |
| 263 |
|
| 264 |
.. c:function:: PyObject* PyImport_AddModuleRef(const char *name) |
| 265 |
|
| 266 |
See `PyImport_AddModuleRef() documentation <https://docs.python.org/dev/c-api/import.html#c.PyImport_AddModuleRef>`__. |
| 267 |
|
| 268 |
.. c:function:: int PyObject_GetOptionalAttr(PyObject *obj, PyObject *attr_name, PyObject **result) |
| 269 |
|
| 270 |
See `PyObject_GetOptionalAttr() documentation <https://docs.python.org/dev/c-api/object.html#c.PyObject_GetOptionalAttr>`__. |
| 271 |
|
| 272 |
.. c:function:: int PyObject_GetOptionalAttrString(PyObject *obj, const char *attr_name, PyObject **result) |
| 273 |
|
| 274 |
See `PyObject_GetOptionalAttrString() documentation <https://docs.python.org/dev/c-api/object.html#c.PyObject_GetOptionalAttrString>`__. |
| 275 |
|
| 276 |
.. c:function:: int PyObject_HasAttrWithError(PyObject *obj, PyObject *attr_name) |
| 277 |
|
| 278 |
See `PyObject_HasAttrWithError() documentation <https://docs.python.org/dev/c-api/object.html#c.PyObject_HasAttrWithError>`__. |
| 279 |
|
| 280 |
.. c:function:: int PyObject_HasAttrStringWithError(PyObject *obj, const char *attr_name) |
| 281 |
|
| 282 |
See `PyObject_HasAttrStringWithError() documentation <https://docs.python.org/dev/c-api/object.html#c.PyObject_HasAttrStringWithError>`__. |
| 283 |
|
| 284 |
.. c:function:: int PyMapping_GetOptionalItem(PyObject *obj, PyObject *key, PyObject **result) |
| 285 |
|
| 286 |
See `PyMapping_GetOptionalItem() documentation <https://docs.python.org/dev/c-api/mapping.html#c.PyMapping_GetOptionalItem>`__. |
| 287 |
|
| 288 |
.. c:function:: int PyMapping_GetOptionalItemString(PyObject *obj, const char *key, PyObject **result) |
| 289 |
|
| 290 |
See `PyMapping_GetOptionalItemString() documentation <https://docs.python.org/dev/c-api/mapping.html#c.PyMapping_GetOptionalItemString>`__. |
| 291 |
|
| 292 |
.. c:function:: int PyMapping_HasKeyWithError(PyObject *obj, PyObject *key) |
| 293 |
|
| 294 |
See `PyMapping_HasKeyWithError() documentation <https://docs.python.org/dev/c-api/mapping.html#c.PyMapping_HasKeyWithError>`__. |
| 295 |
|
| 296 |
.. c:function:: int PyMapping_HasKeyStringWithError(PyObject *obj, const char *key) |
| 297 |
|
| 298 |
See `PyMapping_HasKeyStringWithError() documentation <https://docs.python.org/dev/c-api/mapping.html#c.PyMapping_HasKeyStringWithError>`__. |
| 299 |
|
| 300 |
.. c:function:: int PyModule_Add(PyObject *module, const char *name, PyObject *value) |
| 301 |
|
| 302 |
See `PyModule_Add() documentation <https://docs.python.org/dev/c-api/module.html#c.PyModule_Add>`__. |
| 303 |
|
| 304 |
.. c:function:: int PyWeakref_GetRef(PyObject *ref, PyObject **pobj) |
| 305 |
|
| 306 |
See `PyWeakref_GetRef() documentation <https://docs.python.org/dev/c-api/weakref.html#c.PyWeakref_GetRef>`__. |
| 307 |
|
| 308 |
.. c:function:: int Py_IsFinalizing() |
| 309 |
|
| 310 |
Return non-zero if the Python interpreter is shutting down, return 0 |
| 311 |
otherwise. |
| 312 |
|
| 313 |
Availability: Python 3.3 and newer, PyPy 7.3 and newer. |
| 314 |
|
| 315 |
See `Py_IsFinalizing() documentation <https://docs.python.org/dev/c-api/init.html#c.Py_IsFinalizing>`__. |
| 316 |
|
| 317 |
.. c:function:: int PyDict_ContainsString(PyObject *p, const char *key) |
| 318 |
|
| 319 |
See `PyDict_ContainsString() documentation <https://docs.python.org/dev/c-api/dict.html#c.PyDict_ContainsString>`__. |
| 320 |
|
| 321 |
.. c:function:: int PyLong_AsInt(PyObject *obj) |
| 322 |
|
| 323 |
See `PyLong_AsInt() documentation <https://docs.python.org/dev/c-api/long.html#c.PyLong_AsInt>`__. |
| 324 |
|
| 325 |
.. c:function:: int PyObject_VisitManagedDict(PyObject *obj, visitproc visit, void *arg) |
| 326 |
|
| 327 |
See `PyObject_VisitManagedDict() documentation <https://docs.python.org/dev/c-api/object.html#c.PyObject_VisitManagedDict>`__. |
| 328 |
|
| 329 |
.. c:function:: void PyObject_ClearManagedDict(PyObject *obj) |
| 330 |
|
| 331 |
See `PyObject_ClearManagedDict() documentation <https://docs.python.org/dev/c-api/object.html#c.PyObject_ClearManagedDict>`__. |
| 332 |
|
| 333 |
.. c:function:: PyThreadState* PyThreadState_GetUnchecked(void) |
| 334 |
|
| 335 |
See `PyThreadState_GetUnchecked() documentation <https://docs.python.org/dev/c-api/init.html#c.PyThreadState_GetUnchecked>`__. |
| 336 |
|
| 337 |
Available on Python 3.5.2 and newer. |
| 338 |
|
| 339 |
.. c:function:: int PyUnicode_EqualToUTF8(PyObject *unicode, const char *str) |
| 340 |
|
| 341 |
See `PyUnicode_EqualToUTF8() documentation <https://docs.python.org/dev/c-api/unicode.html#c.PyUnicode_EqualToUTF8>`__. |
| 342 |
|
| 343 |
.. c:function:: int PyUnicode_EqualToUTF8AndSize(PyObject *unicode, const char *str, Py_ssize_t size) |
| 344 |
|
| 345 |
See `PyUnicode_EqualToUTF8AndSize() documentation <https://docs.python.org/dev/c-api/unicode.html#c.PyUnicode_EqualToUTF8AndSize>`__. |
| 346 |
|
| 347 |
.. c:function:: int PyList_Extend(PyObject *list, PyObject *iterable) |
| 348 |
|
| 349 |
See `PyList_Extend() documentation <https://docs.python.org/dev/c-api/list.html#c.PyList_Extend>`__. |
| 350 |
|
| 351 |
.. c:function:: int PyList_Clear(PyObject *list) |
| 352 |
|
| 353 |
See `PyList_Clear() documentation <https://docs.python.org/dev/c-api/list.html#c.PyList_Clear>`__. |
| 354 |
|
| 355 |
.. c:function:: int PyDict_Pop(PyObject *dict, PyObject *key, PyObject **result) |
| 356 |
|
| 357 |
See `PyDict_Pop() documentation <https://docs.python.org/dev/c-api/dict.html#c.PyDict_Pop>`__. |
| 358 |
|
| 359 |
.. c:function:: int PyDict_PopString(PyObject *dict, const char *key, PyObject **result) |
| 360 |
|
| 361 |
See `PyDict_PopString() documentation <https://docs.python.org/dev/c-api/dict.html#c.PyDict_PopString>`__. |
| 362 |
|
| 363 |
.. c:function:: Py_hash_t Py_HashPointer(const void *ptr) |
| 364 |
|
| 365 |
See `Py_HashPointer() documentation <https://docs.python.org/dev/c-api/hash.html#c.Py_HashPointer>`__. |
| 366 |
|
| 367 |
.. c:type:: PyTime_t |
| 368 |
|
| 369 |
A timestamp or duration in nanoseconds, represented as a signed 64-bit |
| 370 |
integer. |
| 371 |
|
| 372 |
.. c:var:: PyTime_t PyTime_MIN |
| 373 |
|
| 374 |
Minimum value of :c:type:`PyTime_t`. |
| 375 |
|
| 376 |
.. c:var:: PyTime_t PyTime_MAX |
| 377 |
|
| 378 |
Maximum value of :c:type:`PyTime_t`. |
| 379 |
|
| 380 |
.. c:function:: double PyTime_AsSecondsDouble(PyTime_t t) |
| 381 |
|
| 382 |
See `PyTime_AsSecondsDouble() documentation <https://docs.python.org/dev/c-api/time.html#c.PyTime_AsSecondsDouble>`__. |
| 383 |
|
| 384 |
.. c:function:: int PyTime_Monotonic(PyTime_t *result) |
| 385 |
|
| 386 |
See `PyTime_Monotonic() documentation <https://docs.python.org/dev/c-api/time.html#c.PyTime_Monotonic>`__. |
| 387 |
|
| 388 |
.. c:function:: int PyTime_Time(PyTime_t *result) |
| 389 |
|
| 390 |
See `PyTime_Time() documentation <https://docs.python.org/dev/c-api/time.html#c.PyTime_Time>`__. |
| 391 |
|
| 392 |
.. c:function:: int PyTime_PerfCounter(PyTime_t *result) |
| 393 |
|
| 394 |
See `PyTime_PerfCounter() documentation <https://docs.python.org/dev/c-api/time.html#c.PyTime_PerfCounter>`__. |
| 395 |
|
| 396 |
.. c:function:: PyObject* PyList_GetItemRef(PyObject *op, Py_ssize_t index) |
| 397 |
|
| 398 |
See `PyList_GetItemRef() documentation <https://docs.python.org/dev/c-api/list.html#c.PyList_GetItemRef>`__. |
| 399 |
|
| 400 |
.. c:function:: int PyDict_SetDefaultRef(PyObject *d, PyObject *key, PyObject *default_value, PyObject **result) |
| 401 |
|
| 402 |
See `PyDict_SetDefaultRef() documentation <https://docs.python.org/dev/c-api/dict.html#c.PyDict_SetDefaultRef>`__. |
| 403 |
|
| 404 |
|
| 405 |
Not supported: |
| 406 |
|
| 407 |
* ``PyErr_FormatUnraisable()``. |
| 408 |
* ``PyLong_AsNativeBytes()`` |
| 409 |
* ``PyLong_FromNativeBytes()`` |
| 410 |
* ``PyLong_FromUnsignedNativeBytes()`` |
| 411 |
* ``PyObject_GenericHash()``. |
| 412 |
* ``PySys_Audit()``. |
| 413 |
* ``PySys_AuditTuple()``. |
| 414 |
* ``PyType_GetFullyQualifiedName()`` |
| 415 |
* ``PyType_GetModuleName()`` |
| 416 |
|
| 417 |
Python 3.12 |
| 418 |
----------- |
| 419 |
|
| 420 |
.. c:function:: PyObject* PyFrame_GetVar(PyFrameObject *frame, PyObject *name) |
| 421 |
|
| 422 |
See `PyFrame_GetVar() documentation <https://docs.python.org/dev/c-api/frame.html#c.PyFrame_GetVar>`__. |
| 423 |
|
| 424 |
Not available on PyPy. |
| 425 |
|
| 426 |
.. c:function:: PyObject* PyFrame_GetVarString(PyFrameObject *frame, const char *name) |
| 427 |
|
| 428 |
See `PyFrame_GetVarString() documentation <https://docs.python.org/dev/c-api/frame.html#c.PyFrame_GetVarString>`__. |
| 429 |
|
| 430 |
Not available on PyPy. |
| 431 |
|
| 432 |
.. c:function:: PyObject* Py_GetConstant(unsigned int constant_id) |
| 433 |
|
| 434 |
See `Py_GetConstant() documentation <https://docs.python.org/dev/c-api/object.html#c.Py_GetConstant>`__. |
| 435 |
|
| 436 |
.. c:function:: PyObject* Py_GetConstantBorrowed(unsigned int constant_id) |
| 437 |
|
| 438 |
See `Py_GetConstantBorrowed() documentation <https://docs.python.org/dev/c-api/object.html#c.Py_GetConstantBorrowed>`__. |
| 439 |
|
| 440 |
|
| 441 |
Not supported: |
| 442 |
|
| 443 |
* ``PyDict_AddWatcher()``, ``PyDict_Watch()``. |
| 444 |
* ``PyCode_AddWatcher()``, ``PyCode_ClearWatcher()``. |
| 445 |
* ``PyErr_GetRaisedException()``, ``PyErr_SetRaisedException()``. |
| 446 |
* ``_PyErr_ChainExceptions1()``. |
| 447 |
* ``PyErr_DisplayException()``. |
| 448 |
* ``_Py_IsImmortal()``. |
| 449 |
* ``Py_NewInterpreterFromConfig()``. |
| 450 |
* ``PyException_GetArgs()``, ``PyException_SetArgs()``. |
| 451 |
* ``PyEval_SetProfileAllThreads()``, ``PyEval_SetTraceAllThreads()``. |
| 452 |
* ``PyFunction_SetVectorcall()``. |
| 453 |
* ``PyType_FromMetaclass()``: implementation too big to be backported. |
| 454 |
* ``PyVectorcall_Call()``. |
| 455 |
|
| 456 |
Python 3.11 |
| 457 |
----------- |
| 458 |
|
| 459 |
.. c:function:: PyObject* PyCode_GetCellvars(PyCodeObject *code) |
| 460 |
|
| 461 |
See `PyCode_GetCellvars() documentation <https://docs.python.org/dev/c-api/code.html#c.PyCode_GetCellvars>`__. |
| 462 |
|
| 463 |
Not available on PyPy. |
| 464 |
|
| 465 |
.. c:function:: PyObject* PyCode_GetCode(PyCodeObject *code) |
| 466 |
|
| 467 |
See `PyCode_GetCode() documentation <https://docs.python.org/dev/c-api/code.html#c.PyCode_GetCode>`__. |
| 468 |
|
| 469 |
Not available on PyPy. |
| 470 |
|
| 471 |
.. c:function:: PyObject* PyCode_GetFreevars(PyCodeObject *code) |
| 472 |
|
| 473 |
See `PyCode_GetFreevars() documentation <https://docs.python.org/dev/c-api/code.html#c.PyCode_GetFreevars>`__. |
| 474 |
|
| 475 |
Not available on PyPy. |
| 476 |
|
| 477 |
.. c:function:: PyObject* PyCode_GetVarnames(PyCodeObject *code) |
| 478 |
|
| 479 |
See `PyCode_GetVarnames() documentation <https://docs.python.org/dev/c-api/code.html#c.PyCode_GetVarnames>`__. |
| 480 |
|
| 481 |
Not available on PyPy. |
| 482 |
|
| 483 |
.. c:function:: PyObject* PyFrame_GetBuiltins(PyFrameObject *frame) |
| 484 |
|
| 485 |
See `PyFrame_GetBuiltins() documentation <https://docs.python.org/dev/c-api/frame.html#c.PyFrame_GetBuiltins>`__. |
| 486 |
|
| 487 |
Not available on PyPy. |
| 488 |
|
| 489 |
.. c:function:: PyObject* PyFrame_GetGlobals(PyFrameObject *frame) |
| 490 |
|
| 491 |
See `PyFrame_GetGlobals() documentation <https://docs.python.org/dev/c-api/frame.html#c.PyFrame_GetGlobals>`__. |
| 492 |
|
| 493 |
Not available on PyPy. |
| 494 |
|
| 495 |
.. c:function:: int PyFrame_GetLasti(PyFrameObject *frame) |
| 496 |
|
| 497 |
See `PyFrame_GetLasti() documentation <https://docs.python.org/dev/c-api/frame.html#c.PyFrame_GetLasti>`__. |
| 498 |
|
| 499 |
Not available on PyPy. |
| 500 |
|
| 501 |
.. c:function:: PyObject* PyFrame_GetLocals(PyFrameObject *frame) |
| 502 |
|
| 503 |
See `PyFrame_GetLocals() documentation <https://docs.python.org/dev/c-api/frame.html#c.PyFrame_GetLocals>`__. |
| 504 |
|
| 505 |
Not available on PyPy. |
| 506 |
|
| 507 |
.. c:function:: void PyThreadState_EnterTracing(PyThreadState *tstate) |
| 508 |
|
| 509 |
See `PyThreadState_EnterTracing() documentation <https://docs.python.org/dev/c-api/init.html#c.PyThreadState_EnterTracing>`__. |
| 510 |
|
| 511 |
Not available on PyPy. |
| 512 |
|
| 513 |
.. c:function:: void PyThreadState_LeaveTracing(PyThreadState *tstate) |
| 514 |
|
| 515 |
See `PyThreadState_LeaveTracing() documentation <https://docs.python.org/dev/c-api/init.html#c.PyThreadState_LeaveTracing>`__. |
| 516 |
|
| 517 |
Not available on PyPy |
| 518 |
|
| 519 |
.. c:function:: int PyFloat_Pack2(double x, unsigned char *p, int le) |
| 520 |
|
| 521 |
Pack a C double as the IEEE 754 binary16 half-precision format. |
| 522 |
|
| 523 |
Availability: Python 3.6 and newer. Not available on PyPy |
| 524 |
|
| 525 |
.. c:function:: int PyFloat_Pack4(double x, unsigned char *p, int le) |
| 526 |
|
| 527 |
Pack a C double as the IEEE 754 binary32 single precision format. |
| 528 |
|
| 529 |
Not available on PyPy |
| 530 |
|
| 531 |
.. c:function:: int PyFloat_Pack8(double x, unsigned char *p, int le) |
| 532 |
|
| 533 |
Pack a C double as the IEEE 754 binary64 double precision format. |
| 534 |
|
| 535 |
Not available on PyPy |
| 536 |
|
| 537 |
.. c:function:: double PyFloat_Unpack2(const unsigned char *p, int le) |
| 538 |
|
| 539 |
Unpack the IEEE 754 binary16 half-precision format as a C double. |
| 540 |
|
| 541 |
Availability: Python 3.6 and newer. Not available on PyPy |
| 542 |
|
| 543 |
.. c:function:: double PyFloat_Unpack4(const unsigned char *p, int le) |
| 544 |
|
| 545 |
Unpack the IEEE 754 binary32 single precision format as a C double. |
| 546 |
|
| 547 |
Not available on PyPy |
| 548 |
|
| 549 |
.. c:function:: double PyFloat_Unpack8(const unsigned char *p, int le) |
| 550 |
|
| 551 |
Unpack the IEEE 754 binary64 double precision format as a C double. |
| 552 |
|
| 553 |
Not available on PyPy |
| 554 |
|
| 555 |
Not supported: |
| 556 |
|
| 557 |
* ``PyType_GetModuleByDef()``. |
| 558 |
* ``PyType_GetName()``. |
| 559 |
* ``PyType_GetQualName()``. |
| 560 |
* ``Py_Version`` constant. |
| 561 |
* ``PyErr_GetHandledException()``, ``PyErr_SetHandledException()``. |
| 562 |
* ``PyFrame_GetGenerator()``. |
| 563 |
|
| 564 |
Python 3.10 |
| 565 |
----------- |
| 566 |
|
| 567 |
.. c:function:: PyObject* Py_NewRef(PyObject *obj) |
| 568 |
|
| 569 |
See `Py_NewRef() documentation <https://docs.python.org/dev/c-api/refcounting.html#c.Py_NewRef>`__. |
| 570 |
|
| 571 |
.. c:function:: PyObject* Py_XNewRef(PyObject *obj) |
| 572 |
|
| 573 |
See `Py_XNewRef() documentation <https://docs.python.org/dev/c-api/refcounting.html#c.Py_XNewRef>`__. |
| 574 |
|
| 575 |
.. c:function:: int Py_Is(PyObject *x, PyObject *y) |
| 576 |
|
| 577 |
See `Py_Is() documentation <https://docs.python.org/dev/c-api/structures.html#c.Py_Is>`__. |
| 578 |
|
| 579 |
.. c:function:: int Py_IsNone(PyObject *x) |
| 580 |
|
| 581 |
See `Py_IsNone() documentation <https://docs.python.org/dev/c-api/structures.html#c.Py_IsNone>`__. |
| 582 |
|
| 583 |
.. c:function:: int Py_IsTrue(PyObject *x) |
| 584 |
|
| 585 |
See `Py_IsTrue() documentation <https://docs.python.org/dev/c-api/structures.html#c.Py_IsTrue>`__. |
| 586 |
|
| 587 |
.. c:function:: int Py_IsFalse(PyObject *x) |
| 588 |
|
| 589 |
See `Py_IsFalse() documentation <https://docs.python.org/dev/c-api/structures.html#c.Py_IsFalse>`__. |
| 590 |
|
| 591 |
.. c:function:: int PyModule_AddObjectRef(PyObject *module, const char *name, PyObject *value) |
| 592 |
|
| 593 |
See `PyModule_AddObjectRef() documentation <https://docs.python.org/dev/c-api/module.html#c.PyModule_AddObjectRef>`__. |
| 594 |
|
| 595 |
Not supported: |
| 596 |
|
| 597 |
* ``PyCodec_Unregister()``. |
| 598 |
* ``PyDateTime_DATE_GET_TZINFO()``, ``PyDateTime_TIME_GET_TZINFO()``. |
| 599 |
* ``PyErr_SetInterruptEx()``. |
| 600 |
* ``PyGC_Enable()``, ``PyGC_Disable()`` and ``PyGC_IsEnabled()``. |
| 601 |
* ``PyIter_Send()``. |
| 602 |
* ``PySet_CheckExact()``. |
| 603 |
* ``Py_TPFLAGS_DISALLOW_INSTANTIATION`` constant. |
| 604 |
* ``Py_TPFLAGS_IMMUTABLETYPE`` constant. |
| 605 |
|
| 606 |
Python 3.9 |
| 607 |
---------- |
| 608 |
|
| 609 |
PyObject |
| 610 |
^^^^^^^^ |
| 611 |
|
| 612 |
.. c:function:: void Py_SET_REFCNT(PyObject *ob, Py_ssize_t refcnt) |
| 613 |
|
| 614 |
See `Py_SET_REFCNT() documentation <https://docs.python.org/dev/c-api/structures.html#c.Py_SET_REFCNT>`__. |
| 615 |
|
| 616 |
.. c:function:: void Py_SET_TYPE(PyObject *ob, PyTypeObject *type) |
| 617 |
|
| 618 |
See `Py_SET_TYPE() documentation <https://docs.python.org/dev/c-api/structures.html#c.Py_SET_TYPE>`__. |
| 619 |
|
| 620 |
.. c:function:: void Py_SET_SIZE(PyVarObject *ob, Py_ssize_t size) |
| 621 |
|
| 622 |
See `Py_SET_SIZE() documentation <https://docs.python.org/dev/c-api/structures.html#c.Py_SET_SIZE>`__. |
| 623 |
|
| 624 |
.. c:function:: int Py_IS_TYPE(const PyObject *ob, const PyTypeObject *type) |
| 625 |
|
| 626 |
See `Py_IS_TYPE() documentation <https://docs.python.org/dev/c-api/structures.html#c.Py_IS_TYPE>`__. |
| 627 |
|
| 628 |
.. c:function:: PyObject* PyObject_CallNoArgs(PyObject *func) |
| 629 |
|
| 630 |
See `PyObject_CallNoArgs() documentation <https://docs.python.org/dev/c-api/call.html#c.PyObject_CallNoArgs>`__. |
| 631 |
|
| 632 |
.. c:function:: PyObject* PyObject_CallOneArg(PyObject *func, PyObject *arg) |
| 633 |
|
| 634 |
See `PyObject_CallOneArg() documentation <https://docs.python.org/dev/c-api/call.html#c.PyObject_CallOneArg>`__. |
| 635 |
|
| 636 |
.. c:function:: PyObject* PyObject_Vectorcall(PyObject *callable, PyObject *const *args, size_t nargsf, PyObject *kwnames) |
| 637 |
|
| 638 |
See `PyObject_Vectorcall() documentation <https://docs.python.org/dev/c-api/call.html#c.PyObject_Vectorcall>`__. |
| 639 |
|
| 640 |
.. c:function:: Py_ssize_t PyVectorcall_NARGS(size_t nargsf) |
| 641 |
|
| 642 |
See `PyVectorcall_NARGS() documentation <https://docs.python.org/dev/c-api/call.html#c.PyVectorcall_NARGS>`__. |
| 643 |
|
| 644 |
.. c:macro:: PY_VECTORCALL_ARGUMENTS_OFFSET |
| 645 |
|
| 646 |
See `PY_VECTORCALL_ARGUMENTS_OFFSET documentation <https://docs.python.org/dev/c-api/call.html#PY_VECTORCALL_ARGUMENTS_OFFSET>`__. |
| 647 |
|
| 648 |
Not supported: |
| 649 |
|
| 650 |
* ``PyVectorcall_CallMethod()``. |
| 651 |
* ``PyType_FromModuleAndSpec()`` |
| 652 |
|
| 653 |
|
| 654 |
|
| 655 |
PyFrameObject |
| 656 |
^^^^^^^^^^^^^ |
| 657 |
|
| 658 |
.. c:function:: PyCodeObject* PyFrame_GetCode(PyFrameObject *frame) |
| 659 |
|
| 660 |
See `PyFrame_GetCode() documentation <https://docs.python.org/dev/c-api/reflection.html#c.PyFrame_GetCode>`__. |
| 661 |
|
| 662 |
.. c:function:: PyFrameObject* PyFrame_GetBack(PyFrameObject *frame) |
| 663 |
|
| 664 |
See `PyFrame_GetBack() documentation <https://docs.python.org/dev/c-api/reflection.html#c.PyFrame_GetBack>`__. |
| 665 |
|
| 666 |
Not available on PyPy |
| 667 |
|
| 668 |
|
| 669 |
PyThreadState |
| 670 |
^^^^^^^^^^^^^ |
| 671 |
|
| 672 |
.. c:function:: PyFrameObject* PyThreadState_GetFrame(PyThreadState *tstate) |
| 673 |
|
| 674 |
See `PyThreadState_GetFrame() documentation <https://docs.python.org/dev/c-api/init.html#c.PyThreadState_GetFrame>`__. |
| 675 |
|
| 676 |
Not available on PyPy |
| 677 |
|
| 678 |
.. c:function:: PyInterpreterState* PyThreadState_GetInterpreter(PyThreadState *tstate) |
| 679 |
|
| 680 |
See `PyThreadState_GetInterpreter() documentation <https://docs.python.org/dev/c-api/init.html#c.PyThreadState_GetInterpreter>`__. |
| 681 |
|
| 682 |
.. c:function:: uint64_t PyThreadState_GetID(PyThreadState *tstate) |
| 683 |
|
| 684 |
See `PyThreadState_GetID() documentation <https://docs.python.org/dev/c-api/init.html#c.PyThreadState_GetID>`__. |
| 685 |
|
| 686 |
Availability: Python 3.7. Not available on PyPy. |
| 687 |
|
| 688 |
PyInterpreterState |
| 689 |
^^^^^^^^^^^^^^^^^^ |
| 690 |
|
| 691 |
.. c:function:: PyInterpreterState* PyInterpreterState_Get(void) |
| 692 |
|
| 693 |
See `PyInterpreterState_Get() documentation <https://docs.python.org/dev/c-api/init.html#c.PyInterpreterState_Get>`__. |
| 694 |
|
| 695 |
|
| 696 |
GC protocol |
| 697 |
^^^^^^^^^^^ |
| 698 |
|
| 699 |
.. c:function:: int PyObject_GC_IsTracked(PyObject* obj) |
| 700 |
|
| 701 |
See `PyObject_GC_IsTracked() documentation <https://docs.python.org/dev/c-api/gcsupport.html#c.PyObject_GC_IsTracked>`__. |
| 702 |
|
| 703 |
Not available on PyPy. |
| 704 |
|
| 705 |
.. c:function:: int PyObject_GC_IsFinalized(PyObject *obj) |
| 706 |
|
| 707 |
See `PyObject_GC_IsFinalized() documentation <https://docs.python.org/dev/c-api/gcsupport.html#c.PyObject_GC_IsFinalized>`__. |
| 708 |
|
| 709 |
Availability: Python 3.4. Not available on PyPy. |
| 710 |
|
| 711 |
Module helper |
| 712 |
^^^^^^^^^^^^^ |
| 713 |
|
| 714 |
.. c:function:: int PyModule_AddType(PyObject *module, PyTypeObject *type) |
| 715 |
|
| 716 |
See `PyModule_AddType() documentation <https://docs.python.org/dev/c-api/module.html#c.PyModule_AddType>`__. |
| 717 |
|
| 718 |
Python 3.8 |
| 719 |
---------- |
| 720 |
|
| 721 |
Not supported: |
| 722 |
|
| 723 |
* ``PyCode_NewWithPosOnlyArgs()``. |
| 724 |
|
| 725 |
Python 3.7 |
| 726 |
---------- |
| 727 |
|
| 728 |
Not supported: |
| 729 |
|
| 730 |
* ``PyImport_GetModule()``. |
| 731 |
* ``PyInterpreterState_GetID()``. |
| 732 |
* ``PySlice_Unpack()``, ``PySlice_AdjustIndices()``. |
| 733 |
* ``PyTimeZone_FromOffset()``, ``PyTimeZone_FromOffsetAndName()``. |
| 734 |
* ``Py_RETURN_RICHCOMPARE()``. |
| 735 |
* ``Py_UNREACHABLE`` macro. |
| 736 |
|
| 737 |
Python 3.6 |
| 738 |
---------- |
| 739 |
|
| 740 |
Not supported: |
| 741 |
|
| 742 |
* ``PyErr_ResourceWarning()``. |
| 743 |
* ``PyErr_SetImportErrorSubclass()``. |
| 744 |
* ``PyOS_FSPath()``. |
| 745 |
* ``Py_FinalizeEx()``. |
| 746 |
|
| 747 |
Python 3.5.2 |
| 748 |
------------ |
| 749 |
|
| 750 |
.. c:macro:: Py_SETREF(op, op2) |
| 751 |
|
| 752 |
.. c:macro:: Py_XSETREF(op, op2) |
| 753 |
|
| 754 |
Not supported: |
| 755 |
|
| 756 |
* ``PyCodec_NameReplaceErrors()``. |
| 757 |
* ``PyErr_FormatV()``. |
| 758 |
* ``PyExc_RecursionError``. |
| 759 |
* ``PyModule_FromDefAndSpec()``, ``PyModule_FromDefAndSpec2()``, |
| 760 |
and ``PyModule_ExecDef()``. |
| 761 |
* ``PyNumber_MatrixMultiply()`` and ``PyNumber_InPlaceMatrixMultiply()``. |
| 762 |
|
| 763 |
Python 3.4 |
| 764 |
---------- |
| 765 |
|
| 766 |
.. c:macro:: Py_UNUSED(name) |
| 767 |
|
| 768 |
See `Py_UNUSED() documentation <https://docs.python.org/dev/c-api/intro.html#c.Py_UNUSED>`__. |
| 769 |
|
| 770 |
Python 3.2 |
| 771 |
---------- |
| 772 |
|
| 773 |
Not supported: |
| 774 |
|
| 775 |
* ``Py_VA_COPY``. |
| 776 |
* ``PySys_SetArgvEx()``. |
| 777 |
* ``PyLong_AsLongLongAndOverflow()``. |
| 778 |
* ``PyErr_NewExceptionWithDoc()``. |
| 779 |
|
| 780 |
Python 3.1 |
| 781 |
---------- |
| 782 |
|
| 783 |
Not supported: |
| 784 |
|
| 785 |
* ``PyOS_string_to_double()``. |
| 786 |
* ``PyCapsule`` API. |
| 787 |
|
| 788 |
Borrow variant |
| 789 |
-------------- |
| 790 |
|
| 791 |
To ease migration of C extensions to the new C API, a variant is provided |
| 792 |
to return borrowed references rather than strong references. |
| 793 |
|
| 794 |
These functions are only available in ``pythoncapi_compat.h`` and are not |
| 795 |
part of the Python C API. |
| 796 |
|
| 797 |
.. c:function:: PyObject* _Py_StealRef(PyObject *ob) |
| 798 |
|
| 799 |
Similar to ``Py_DECREF(ob); return ob;``. |
| 800 |
|
| 801 |
.. c:function:: PyObject* _Py_XStealRef(PyObject *ob) |
| 802 |
|
| 803 |
Similar to ``Py_XDECREF(ob); return ob;``. |
| 804 |
|
| 805 |
.. c:function:: PyFrameObject* _PyThreadState_GetFrameBorrow(PyThreadState *tstate) |
| 806 |
|
| 807 |
:c:func:`PyThreadState_GetFrame` variant. Not available on PyPy. |
| 808 |
|
| 809 |
.. c:function:: PyCodeObject* _PyFrame_GetCodeBorrow(PyFrameObject *frame) |
| 810 |
|
| 811 |
:c:func:`PyFrame_GetCode` variant. |
| 812 |
|
| 813 |
.. c:function:: PyFrameObject* _PyFrame_GetBackBorrow(PyFrameObject *frame) |
| 814 |
|
| 815 |
:c:func:`PyFrame_GetBack` variant Not available on PyPy. |
| 816 |
|
| 817 |
For example, ``tstate->frame`` can be replaced with |
| 818 |
``_PyThreadState_GetFrameBorrow(tstate)`` to avoid accessing directly |
| 819 |
``PyThreadState.frame`` member. |