13#ifndef PythonMonkey_py_version_shim_
14#define PythonMonkey_py_version_shim_
22#if PY_VERSION_HEX >= 0x030d0000
23 #define Py_IsFinalizing Py_IsFinalizing
25 #define Py_IsFinalizing _Py_IsFinalizing
34#if PY_VERSION_HEX >= 0x030d0000
37 PyDictObject *dv_dict;
46#if PY_VERSION_HEX >= 0x030d0000
47inline int _PyArg_CheckPositional(
const char *
name, Py_ssize_t nargs, Py_ssize_t min, Py_ssize_t max) {
49 name =
"unpacked tuple";
55 "%.200s expected %s%zd argument%s, got %zd",
56 name, (min == max ?
"" :
"at least "), min, min == 1 ?
"" :
"s", nargs);
67 "%.200s expected %s%zd argument%s, got %zd",
68 name, (min == max ?
"" :
"at most "), max, max == 1 ?
"" :
"s", nargs);
82#if PY_VERSION_HEX < 0x030d0000
83 return _PyDictView_New(dict, type);
85 _PyDictViewObject *dv;
86 dv = PyObject_GC_New(_PyDictViewObject, type);
90 dv->dv_dict = (PyDictObject *)dict;
91 PyObject_GC_Track(dv);
92 return (PyObject *)dv;
103#if PY_VERSION_HEX < 0x030d0000
104 return _PyErr_SetKeyError(key);
106 return PyErr_SetObject(PyExc_KeyError, key);
115static inline void _Py_SET_SIZE(PyVarObject *ob, Py_ssize_t size) {
118#define Py_SET_SIZE(ob, size) _Py_SET_SIZE((PyVarObject *)(ob), size)
125#if PY_VERSION_HEX < 0x03090000
127 return PyObject_CallFunction(func,
"O", arg);
137inline int PyLong_AsByteArray(PyLongObject *v,
unsigned char *bytes,
size_t n,
bool little_endian,
bool is_signed) {
138#if PY_VERSION_HEX >= 0x030d0000
139 return _PyLong_AsByteArray(v, bytes, n, little_endian, is_signed,
false);
141 return _PyLong_AsByteArray(v, bytes, n, little_endian, is_signed);
readonly name
Definition dom-exception.d.ts:24
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 replac...
Definition pyshim.hh:137
void PyErr_SetKeyError(PyObject *key)
Shim for _PyErr_SetKeyError. Since Python 3.13, _PyErr_SetKeyError function became an internal API.
Definition pyshim.hh:100
PyObject * PyDictView_New(PyObject *dict, PyTypeObject *type)
_PyDictViewObject type definition moved from Python's public API to the internal header file internal...
Definition pyshim.hh:81
PyObject * PyObject_CallOneArg(PyObject *func, PyObject *arg)
Shim for PyObject_CallOneArg. PyObject_CallOneArg is not available in Python < 3.9.
Definition pyshim.hh:126