summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Doc/whatsnew/3.11.rst16
-rw-r--r--Include/cpython/frameobject.h13
-rw-r--r--Include/cpython/pyframe.h17
-rw-r--r--Include/pyframe.h6
-rw-r--r--Makefile.pre.in1
-rw-r--r--Misc/NEWS.d/next/C API/2022-06-17-13-41-38.gh-issue-93937.uKVTEh.rst14
-rw-r--r--Modules/_ctypes/callbacks.c1
-rw-r--r--Modules/_testcapimodule.c1
-rw-r--r--Modules/_xxsubinterpretersmodule.c1
-rw-r--r--Modules/faulthandler.c2
-rw-r--r--Modules/pyexpat.c1
-rw-r--r--Objects/object.c1
-rw-r--r--Objects/typeobject.c1
-rw-r--r--PCbuild/pythoncore.vcxproj1
-rw-r--r--PCbuild/pythoncore.vcxproj.filters3
-rw-r--r--Python/_warnings.c1
-rw-r--r--Python/ceval.c1
-rw-r--r--Python/frame.c2
-rw-r--r--Python/suggestions.c1
-rw-r--r--Python/sysmodule.c2
-rw-r--r--Python/traceback.c3
21 files changed, 61 insertions, 28 deletions
diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst
index 33ea8bf..0275b44 100644
--- a/Doc/whatsnew/3.11.rst
+++ b/Doc/whatsnew/3.11.rst
@@ -1757,6 +1757,21 @@ Porting to Python 3.11
which are not available in the limited C API.
(Contributed by Victor Stinner in :issue:`46007`.)
+* The following frame functions and type are now directly available with
+ ``#include <Python.h>``, it's no longer needed to add
+ ``#include <frameobject.h>``:
+
+ * :c:func:`PyFrame_Check`
+ * :c:func:`PyFrame_GetBack`
+ * :c:func:`PyFrame_GetBuiltins`
+ * :c:func:`PyFrame_GetGenerator`
+ * :c:func:`PyFrame_GetGlobals`
+ * :c:func:`PyFrame_GetLasti`
+ * :c:func:`PyFrame_GetLocals`
+ * :c:type:`PyFrame_Type`
+
+ (Contributed by Victor Stinner in :gh:`93937`.)
+
.. _pyframeobject-3.11-hiding:
* The :c:type:`PyFrameObject` structure members have been removed from the
@@ -1893,7 +1908,6 @@ Porting to Python 3.11
paths and then modify them, finish initialization and use :c:func:`PySys_GetObject`
to retrieve :data:`sys.path` as a Python list object and modify it directly.
-
Deprecated
----------
diff --git a/Include/cpython/frameobject.h b/Include/cpython/frameobject.h
index 9cd711e..4e19535 100644
--- a/Include/cpython/frameobject.h
+++ b/Include/cpython/frameobject.h
@@ -6,10 +6,6 @@
/* Standard object interface */
-PyAPI_DATA(PyTypeObject) PyFrame_Type;
-
-#define PyFrame_Check(op) Py_IS_TYPE(op, &PyFrame_Type)
-
PyAPI_FUNC(PyFrameObject *) PyFrame_New(PyThreadState *, PyCodeObject *,
PyObject *, PyObject *);
@@ -31,12 +27,3 @@ PyAPI_FUNC(int) _PyFrame_IsEntryFrame(PyFrameObject *frame);
PyAPI_FUNC(int) PyFrame_FastToLocalsWithError(PyFrameObject *f);
PyAPI_FUNC(void) PyFrame_FastToLocals(PyFrameObject *);
-
-PyAPI_FUNC(PyFrameObject *) PyFrame_GetBack(PyFrameObject *frame);
-PyAPI_FUNC(PyObject *) PyFrame_GetLocals(PyFrameObject *frame);
-
-PyAPI_FUNC(PyObject *) PyFrame_GetGlobals(PyFrameObject *frame);
-PyAPI_FUNC(PyObject *) PyFrame_GetBuiltins(PyFrameObject *frame);
-
-PyAPI_FUNC(PyObject *) PyFrame_GetGenerator(PyFrameObject *frame);
-PyAPI_FUNC(int) PyFrame_GetLasti(PyFrameObject *frame);
diff --git a/Include/cpython/pyframe.h b/Include/cpython/pyframe.h
new file mode 100644
index 0000000..1dc634c
--- /dev/null
+++ b/Include/cpython/pyframe.h
@@ -0,0 +1,17 @@
+#ifndef Py_CPYTHON_PYFRAME_H
+# error "this header file must not be included directly"
+#endif
+
+PyAPI_DATA(PyTypeObject) PyFrame_Type;
+
+#define PyFrame_Check(op) Py_IS_TYPE((op), &PyFrame_Type)
+
+PyAPI_FUNC(PyFrameObject *) PyFrame_GetBack(PyFrameObject *frame);
+PyAPI_FUNC(PyObject *) PyFrame_GetLocals(PyFrameObject *frame);
+
+PyAPI_FUNC(PyObject *) PyFrame_GetGlobals(PyFrameObject *frame);
+PyAPI_FUNC(PyObject *) PyFrame_GetBuiltins(PyFrameObject *frame);
+
+PyAPI_FUNC(PyObject *) PyFrame_GetGenerator(PyFrameObject *frame);
+PyAPI_FUNC(int) PyFrame_GetLasti(PyFrameObject *frame);
+
diff --git a/Include/pyframe.h b/Include/pyframe.h
index feac16f..13d5231 100644
--- a/Include/pyframe.h
+++ b/Include/pyframe.h
@@ -14,6 +14,12 @@ PyAPI_FUNC(int) PyFrame_GetLineNumber(PyFrameObject *);
PyAPI_FUNC(PyCodeObject *) PyFrame_GetCode(PyFrameObject *frame);
+#ifndef Py_LIMITED_API
+# define Py_CPYTHON_PYFRAME_H
+# include "cpython/pyframe.h"
+# undef Py_CPYTHON_PYFRAME_H
+#endif
+
#ifdef __cplusplus
}
#endif
diff --git a/Makefile.pre.in b/Makefile.pre.in
index 803b75bd..3b5f394 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -1576,6 +1576,7 @@ PYTHON_HEADERS= \
$(srcdir)/Include/cpython/pydebug.h \
$(srcdir)/Include/cpython/pyerrors.h \
$(srcdir)/Include/cpython/pyfpe.h \
+ $(srcdir)/Include/cpython/pyframe.h \
$(srcdir)/Include/cpython/pylifecycle.h \
$(srcdir)/Include/cpython/pymem.h \
$(srcdir)/Include/cpython/pystate.h \
diff --git a/Misc/NEWS.d/next/C API/2022-06-17-13-41-38.gh-issue-93937.uKVTEh.rst b/Misc/NEWS.d/next/C API/2022-06-17-13-41-38.gh-issue-93937.uKVTEh.rst
new file mode 100644
index 0000000..c0a0745
--- /dev/null
+++ b/Misc/NEWS.d/next/C API/2022-06-17-13-41-38.gh-issue-93937.uKVTEh.rst
@@ -0,0 +1,14 @@
+The following frame functions and type are now directly available with
+``#include <Python.h>``, it's no longer needed to add ``#include
+<frameobject.h>``:
+
+* :c:func:`PyFrame_Check`
+* :c:func:`PyFrame_GetBack`
+* :c:func:`PyFrame_GetBuiltins`
+* :c:func:`PyFrame_GetGenerator`
+* :c:func:`PyFrame_GetGlobals`
+* :c:func:`PyFrame_GetLasti`
+* :c:func:`PyFrame_GetLocals`
+* :c:type:`PyFrame_Type`
+
+Patch by Victor Stinner.
diff --git a/Modules/_ctypes/callbacks.c b/Modules/_ctypes/callbacks.c
index e1e0225..95b0912 100644
--- a/Modules/_ctypes/callbacks.c
+++ b/Modules/_ctypes/callbacks.c
@@ -10,7 +10,6 @@
#endif
#include "pycore_call.h" // _PyObject_CallNoArgs()
-#include "frameobject.h"
#include <stdbool.h>
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index a2d9ac8..1d557fe 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -21,7 +21,6 @@
#define PY_SSIZE_T_CLEAN
#include "Python.h"
-#include "frameobject.h" // PyFrame_Check()
#include "datetime.h" // PyDateTimeAPI
#include "marshal.h" // PyMarshal_WriteLongToFile
#include "structmember.h" // PyMemberDef
diff --git a/Modules/_xxsubinterpretersmodule.c b/Modules/_xxsubinterpretersmodule.c
index d1df001..e5b96be 100644
--- a/Modules/_xxsubinterpretersmodule.c
+++ b/Modules/_xxsubinterpretersmodule.c
@@ -6,7 +6,6 @@
#endif
#include "Python.h"
-#include "frameobject.h"
#include "pycore_frame.h"
#include "pycore_pystate.h" // _PyThreadState_GET()
#include "pycore_interpreteridobject.h"
diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c
index 08c4083..3026bb6 100644
--- a/Modules/faulthandler.c
+++ b/Modules/faulthandler.c
@@ -5,8 +5,6 @@
#include "pycore_signal.h" // Py_NSIG
#include "pycore_traceback.h" // _Py_DumpTracebackThreads
-#include "frameobject.h"
-
#include <object.h>
#include <signal.h>
#include <signal.h>
diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c
index ad8148a..12319ee 100644
--- a/Modules/pyexpat.c
+++ b/Modules/pyexpat.c
@@ -2,7 +2,6 @@
#include <ctype.h>
#include "structmember.h" // PyMemberDef
-#include "frameobject.h"
#include "expat.h"
#include "pyexpat.h"
diff --git a/Objects/object.c b/Objects/object.c
index 303a22b..d9fa779 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -16,7 +16,6 @@
#include "pycore_symtable.h" // PySTEntry_Type
#include "pycore_typeobject.h" // _PyTypes_InitSlotDefs()
#include "pycore_unionobject.h" // _PyUnion_Type
-#include "frameobject.h" // PyFrame_Type
#include "pycore_interpreteridobject.h" // _PyInterpreterID_Type
#ifdef Py_LIMITED_API
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index d95b850..1fcc045 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -11,7 +11,6 @@
#include "pycore_pystate.h" // _PyThreadState_GET()
#include "pycore_typeobject.h" // struct type_cache
#include "pycore_unionobject.h" // _Py_union_type_or
-#include "frameobject.h" // PyFrameObject
#include "pycore_frame.h" // _PyInterpreterFrame
#include "opcode.h" // MAKE_CELL
#include "structmember.h" // PyMemberDef
diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj
index 3ce116d..a380401 100644
--- a/PCbuild/pythoncore.vcxproj
+++ b/PCbuild/pythoncore.vcxproj
@@ -167,6 +167,7 @@
<ClInclude Include="..\Include\cpython\pydebug.h" />
<ClInclude Include="..\Include\cpython\pyerrors.h" />
<ClInclude Include="..\Include\cpython\pyfpe.h" />
+ <ClInclude Include="..\Include\cpython\pyframe.h" />
<ClInclude Include="..\Include\cpython\pylifecycle.h" />
<ClInclude Include="..\Include\cpython\pymem.h" />
<ClInclude Include="..\Include\cpython\pystate.h" />
diff --git a/PCbuild/pythoncore.vcxproj.filters b/PCbuild/pythoncore.vcxproj.filters
index 542d551..e3fe927 100644
--- a/PCbuild/pythoncore.vcxproj.filters
+++ b/PCbuild/pythoncore.vcxproj.filters
@@ -435,6 +435,9 @@
<ClInclude Include="..\Include\cpython\pymem.h">
<Filter>Include\cpython</Filter>
</ClInclude>
+ <ClInclude Include="..\Include\cpython\pyframe.h">
+ <Filter>Include\cpython</Filter>
+ </ClInclude>
<ClInclude Include="..\Include\cpython\pylifecycle.h">
<Filter>Include\cpython</Filter>
</ClInclude>
diff --git a/Python/_warnings.c b/Python/_warnings.c
index 942308b..4e22400 100644
--- a/Python/_warnings.c
+++ b/Python/_warnings.c
@@ -4,7 +4,6 @@
#include "pycore_long.h" // _PyLong_GetZero()
#include "pycore_pyerrors.h"
#include "pycore_pystate.h" // _PyThreadState_GET()
-#include "frameobject.h" // PyFrame_GetBack()
#include "pycore_frame.h"
#include "clinic/_warnings.c.h"
diff --git a/Python/ceval.c b/Python/ceval.c
index b8b27a8..03c7489 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -26,7 +26,6 @@
#include "pycore_dict.h"
#include "dictobject.h"
-#include "frameobject.h"
#include "pycore_frame.h"
#include "opcode.h"
#include "pydtrace.h"
diff --git a/Python/frame.c b/Python/frame.c
index c2da123..b6674ed 100644
--- a/Python/frame.c
+++ b/Python/frame.c
@@ -1,7 +1,7 @@
#include "Python.h"
#include "frameobject.h"
-#include "pycore_code.h" // stats
+#include "pycore_code.h" // stats
#include "pycore_frame.h"
#include "pycore_object.h" // _PyObject_GC_UNTRACK()
#include "opcode.h"
diff --git a/Python/suggestions.c b/Python/suggestions.c
index b84acaa..c336ec8 100644
--- a/Python/suggestions.c
+++ b/Python/suggestions.c
@@ -1,5 +1,4 @@
#include "Python.h"
-#include "frameobject.h"
#include "pycore_frame.h"
#include "pycore_pyerrors.h"
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index 4f8b4cc..7698641 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -31,7 +31,7 @@ Data members:
#include "pycore_structseq.h" // _PyStructSequence_InitType()
#include "pycore_tuple.h" // _PyTuple_FromArray()
-#include "frameobject.h" // PyFrame_GetBack()
+#include "frameobject.h" // PyFrame_FastToLocalsWithError()
#include "pydtrace.h"
#include "osdefs.h" // DELIM
#include "stdlib_module_names.h" // _Py_stdlib_module_names
diff --git a/Python/traceback.c b/Python/traceback.c
index 3ec0618..0c49a8c 100644
--- a/Python/traceback.c
+++ b/Python/traceback.c
@@ -3,7 +3,6 @@
#include "Python.h"
-#include "frameobject.h" // PyFrame_GetBack()
#include "pycore_ast.h" // asdl_seq_*
#include "pycore_call.h" // _PyObject_CallMethodFormat()
#include "pycore_compile.h" // _PyAST_Optimize
@@ -15,7 +14,9 @@
#include "pycore_pyerrors.h" // _PyErr_Fetch()
#include "pycore_pystate.h" // _PyThreadState_GET()
#include "pycore_traceback.h" // EXCEPTION_TB_HEADER
+
#include "../Parser/pegen.h" // _PyPegen_byte_offset_to_character_offset()
+#include "frameobject.h" // PyFrame_New()
#include "structmember.h" // PyMemberDef
#include "osdefs.h" // SEP
#ifdef HAVE_FCNTL_H