PythonMonkey   v1.0.1 (dev)
Loading...
Searching...
No Matches
pyshim.hh File Reference

Python's C APIs are constantly changing in different versions of CPython. PythonMonkey has a wide variety of CPython versions' support. (Currently Python 3.8-3.13) This file helps our Python API calls work with different Python versions in the same code base. More...

#include <Python.h>
Include dependency graph for pyshim.hh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define Py_IsFinalizing   _Py_IsFinalizing
 _Py_IsFinalizing becomes a stable API in Python 3.13, and renames to Py_IsFinalizing
 
#define Py_SET_SIZE(ob, size)   _Py_SET_SIZE((PyVarObject *)(ob), size)
 

Functions

PyObject * PyDictView_New (PyObject *dict, PyTypeObject *type)
 _PyDictViewObject type definition moved from Python's public API to the internal header file internal/pycore_dict.h in Python 3.13.
 
void PyErr_SetKeyError (PyObject *key)
 Shim for _PyErr_SetKeyError. Since Python 3.13, _PyErr_SetKeyError function became an internal API.
 
PyObject * PyObject_CallOneArg (PyObject *func, PyObject *arg)
 Shim for PyObject_CallOneArg. PyObject_CallOneArg is not available in Python < 3.9.
 
int PyLong_AsByteArray (PyLongObject *v, unsigned char *bytes, size_t n, bool little_endian, bool is_signed)
 Shim for _PyLong_AsByteArray. Python 3.13.0a4 added a new public API PyLong_AsNativeBytes() to replace the private _PyLong_AsByteArray(). But this change also modified the function signature of _PyLong_AsByteArray().
 

Detailed Description

Python's C APIs are constantly changing in different versions of CPython. PythonMonkey has a wide variety of CPython versions' support. (Currently Python 3.8-3.13) This file helps our Python API calls work with different Python versions in the same code base.

Author
Tom Tang (xmade.nosp@m.r@di.nosp@m.strib.nosp@m.utiv.nosp@m.e.net.nosp@m.work)
Date
2024-09-20

Macro Definition Documentation

◆ Py_IsFinalizing

#define Py_IsFinalizing   _Py_IsFinalizing

_Py_IsFinalizing becomes a stable API in Python 3.13, and renames to Py_IsFinalizing

◆ Py_SET_SIZE

#define Py_SET_SIZE (   ob,
  size 
)    _Py_SET_SIZE((PyVarObject *)(ob), size)

Function Documentation

◆ PyDictView_New()

PyObject * PyDictView_New ( PyObject *  dict,
PyTypeObject *  type 
)

_PyDictViewObject type definition moved from Python's public API to the internal header file internal/pycore_dict.h in Python 3.13.

See also
https://github.com/python/cpython/blob/v3.13.0rc1/Include/internal/pycore_dict.h#L64-L72

Shim for _PyArg_CheckPositional. Since Python 3.13, _PyArg_CheckPositional function became an internal API.

See also
Modified from https://github.com/python/cpython/blob/v3.13.0rc1/Python/getargs.c#L2738-L2780

Shim for _PyDictView_New. Since Python 3.13, _PyDictView_New function became an internal API.

See also
Modified from https://github.com/python/cpython/blob/v3.13.0rc1/Objects/dictobject.c#L5806-L5827

◆ PyErr_SetKeyError()

void PyErr_SetKeyError ( PyObject *  key)

Shim for _PyErr_SetKeyError. Since Python 3.13, _PyErr_SetKeyError function became an internal API.

◆ PyLong_AsByteArray()

int PyLong_AsByteArray ( PyLongObject *  v,
unsigned char *  bytes,
size_t  n,
bool  little_endian,
bool  is_signed 
)

Shim for _PyLong_AsByteArray. Python 3.13.0a4 added a new public API PyLong_AsNativeBytes() to replace the private _PyLong_AsByteArray(). But this change also modified the function signature of _PyLong_AsByteArray().

See also
https://github.com/python/cpython/issues/111140

◆ PyObject_CallOneArg()

PyObject * PyObject_CallOneArg ( PyObject *  func,
PyObject *  arg 
)

Shim for PyObject_CallOneArg. PyObject_CallOneArg is not available in Python < 3.9.