Skip to content

Commit c144a62

Browse files
committed
Weaken contract of PyUnstable_InterpreterFrame_GetCode to return PyObject*.
1 parent 37a96e2 commit c144a62

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

Doc/c-api/frame.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ Unless using PEP 523, you will not need this.
143143
The interpreter's internal frame representation.
144144
145145
146-
.. c:function:: PyCodeObject* PyUnstable_InterpreterFrame_GetCode(struct _PyInterpreterFrame *frame);
146+
.. c:function:: PyObject* PyUnstable_InterpreterFrame_GetCode(struct _PyInterpreterFrame *frame);
147147
148148
Return a :term:`strong reference` to the code object for the frame.
149149

Include/cpython/frameobject.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ PyAPI_FUNC(void) PyFrame_FastToLocals(PyFrameObject *);
3535

3636
/* Returns the code object of the frame (strong reference).
3737
* Does not raise an exception. */
38-
PyAPI_FUNC(PyCodeObject *) PyUnstable_InterpreterFrame_GetCode(struct _PyInterpreterFrame *frame);
38+
PyAPI_FUNC(PyObject *) PyUnstable_InterpreterFrame_GetCode(struct _PyInterpreterFrame *frame);
3939

4040
/* Returns a byte ofsset into the last executed instruction.
4141
* Does not raise an exception. */

Python/frame.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,10 @@ _PyFrame_ClearExceptCode(_PyInterpreterFrame *frame)
146146

147147
/* Unstable API functions */
148148

149-
PyCodeObject *
149+
PyObject *
150150
PyUnstable_InterpreterFrame_GetCode(struct _PyInterpreterFrame *frame)
151151
{
152-
PyCodeObject *code = frame->f_code;
152+
PyObject *code = (PyObject *)frame->f_code;
153153
Py_INCREF(code);
154154
return code;
155155
}

0 commit comments

Comments
 (0)