Add PyFrame_GetLasti() function · python/pythoncapi-compat@dac4f8c · GitHub
Skip to content

Commit dac4f8c

Browse files
committed
Add PyFrame_GetLasti() function
1 parent 03a4830 commit dac4f8c

4 files changed

Lines changed: 25 additions & 5 deletions

File tree

docs/api.rst

Lines changed: 6 additions & 0 deletions

docs/changelog.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Changelog
22
=========
33

4-
* 2022-04-07: Add functions ``PyFrame_GetLocals()``, ``PyFrame_GetGlobals()``
5-
and ``PyFrame_GetBuiltins()``.
4+
* 2022-04-08: Add functions ``PyFrame_GetLocals()``, ``PyFrame_GetGlobals()``
5+
``PyFrame_GetBuiltins()``, and ``PyFrame_GetLasti()``.
66
* 2022-03-12: Add functions ``PyFloat_Pack2()``, ``PyFloat_Pack4()``,
77
``PyFloat_Pack8()``, ``PyFloat_Unpack2()``, ``PyFloat_Unpack4()`` and
88
``PyFloat_Unpack8()``.

pythoncapi_compat.h

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ _PyFrame_GetBackBorrow(PyFrameObject *frame)
207207

208208
// bpo-40421 added PyFrame_GetLocals() to Python 3.11.0a7
209209
#if PY_VERSION_HEX < 0x030B00A7 && !defined(PYPY_VERSION)
210-
PyObject*
210+
PYCAPI_COMPAT_STATIC_INLINE(PyObject*)
211211
PyFrame_GetLocals(PyFrameObject *frame)
212212
{
213213
#if PY_VERSION_HEX >= 0x030400B1
@@ -224,7 +224,7 @@ PyFrame_GetLocals(PyFrameObject *frame)
224224

225225
// bpo-40421 added PyFrame_GetGlobals() to Python 3.11.0a7
226226
#if PY_VERSION_HEX < 0x030B00A7 && !defined(PYPY_VERSION)
227-
PyObject*
227+
PYCAPI_COMPAT_STATIC_INLINE(PyObject*)
228228
PyFrame_GetGlobals(PyFrameObject *frame)
229229
{
230230
return Py_NewRef(frame->f_globals);
@@ -234,14 +234,24 @@ PyFrame_GetGlobals(PyFrameObject *frame)
234234

235235
// bpo-40421 added PyFrame_GetBuiltins() to Python 3.11.0a7
236236
#if PY_VERSION_HEX < 0x030B00A7 && !defined(PYPY_VERSION)
237-
PyObject*
237+
PYCAPI_COMPAT_STATIC_INLINE(PyObject*)
238238
PyFrame_GetBuiltins(PyFrameObject *frame)
239239
{
240240
return Py_NewRef(frame->f_builtins);
241241
}
242242
#endif
243243

244244

245+
// bpo-40421 added PyFrame_GetLasti() to Python 3.11.0b1
246+
#if PY_VERSION_HEX < 0x030B00A7 && !defined(PYPY_VERSION)
247+
PYCAPI_COMPAT_STATIC_INLINE(int)
248+
PyFrame_GetLasti(PyFrameObject *frame)
249+
{
250+
return frame->f_lasti;
251+
}
252+
#endif
253+
254+
245255
// bpo-39947 added PyThreadState_GetInterpreter() to Python 3.9.0a5
246256
#if PY_VERSION_HEX < 0x030900A5
247257
PYCAPI_COMPAT_STATIC_INLINE(PyInterpreterState *)

tests/test_pythoncapi_compat_cext.c

Lines changed: 4 additions & 0 deletions

0 commit comments

Comments
 (0)