Skip to content

bpo-35134: Move non-limited C API files to Include/cpython/ #24561

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Doc/whatsnew/3.10.rst
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,14 @@ Porting to Python 3.10
bugs like ``if (PyList_SET_ITEM (a, b, c) < 0) ...`` test.
(Contributed by Zackery Spytz and Victor Stinner in :issue:`30459`.)

* The non-limited API files ``odictobject.h``, ``parser_interface.h``,
``picklebufobject.h``, ``pyarena.h``, ``pyctype.h``, ``pydebug.h``,
``pyfpe.h``, and ``pytime.h`` have been moved to the ``Include/cpython``
directory. These files must not be included directly, as they are already
included in ``Python.h``: :ref:`Include Files <api-includes>`. If they have
been included directly, consider including ``Python.h`` instead.
(Contributed by Nicholas Sim in :issue:`35134`)

Deprecated
----------

Expand Down
10 changes: 5 additions & 5 deletions Include/Python.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
#include "typeslots.h"
#include "pyhash.h"

#include "pydebug.h"
#include "cpython/pydebug.h"

#include "bytearrayobject.h"
#include "bytesobject.h"
Expand All @@ -104,7 +104,7 @@
#include "tupleobject.h"
#include "listobject.h"
#include "dictobject.h"
#include "odictobject.h"
#include "cpython/odictobject.h"
#include "enumobject.h"
#include "setobject.h"
#include "methodobject.h"
Expand All @@ -126,7 +126,7 @@
#include "weakrefobject.h"
#include "structseq.h"
#include "namespaceobject.h"
#include "picklebufobject.h"
#include "cpython/picklebufobject.h"
#include "cpython/pytime.h"

#include "codecs.h"
Expand All @@ -141,7 +141,7 @@
#include "modsupport.h"
#include "compile.h"
#include "pythonrun.h"
#include "parser_interface.h"
#include "cpython/parser_interface.h"
#include "pylifecycle.h"
#include "ceval.h"
#include "sysmodule.h"
Expand All @@ -158,7 +158,7 @@
#include "pystrtod.h"
#include "pystrcmp.h"
#include "fileutils.h"
#include "pyfpe.h"
#include "cpython/pyfpe.h"
#include "tracemalloc.h"

#endif /* !Py_PYTHON_H */
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ PEGEN_OBJS= \


PEGEN_HEADERS= \
$(srcdir)/Include/parser_interface.h \
$(srcdir)/Include/cpython/parser_interface.h \
$(srcdir)/Parser/pegen.h \
$(srcdir)/Parser/string_parser.h

Expand Down Expand Up @@ -1051,17 +1051,13 @@ PYTHON_HEADERS= \
$(srcdir)/Include/namespaceobject.h \
$(srcdir)/Include/object.h \
$(srcdir)/Include/objimpl.h \
$(srcdir)/Include/odictobject.h \
$(srcdir)/Include/opcode.h \
$(srcdir)/Include/osdefs.h \
$(srcdir)/Include/osmodule.h \
$(srcdir)/Include/patchlevel.h \
$(srcdir)/Include/picklebufobject.h \
$(srcdir)/Include/pycapsule.h \
$(srcdir)/Include/pydebug.h \
$(srcdir)/Include/pydtrace.h \
$(srcdir)/Include/pyerrors.h \
$(srcdir)/Include/pyfpe.h \
$(srcdir)/Include/pyframe.h \
$(srcdir)/Include/pyhash.h \
$(srcdir)/Include/pylifecycle.h \
Expand Down Expand Up @@ -1111,9 +1107,13 @@ PYTHON_HEADERS= \
$(srcdir)/Include/cpython/methodobject.h \
$(srcdir)/Include/cpython/object.h \
$(srcdir)/Include/cpython/objimpl.h \
$(srcdir)/Include/cpython/odictobject.h \
$(srcdir)/Include/cpython/picklebufobject.h \
$(srcdir)/Include/cpython/pyarena.h \
$(srcdir)/Include/cpython/pyctype.h \
$(srcdir)/Include/cpython/pydebug.h \
$(srcdir)/Include/cpython/pyerrors.h \
$(srcdir)/Include/cpython/pyfpe.h \
$(srcdir)/Include/cpython/pylifecycle.h \
$(srcdir)/Include/cpython/pymem.h \
$(srcdir)/Include/cpython/pystate.h \
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Move odictobject.h, parser_interface.h, picklebufobject.h, pydebug.h, and
pyfpe.h into the cpython/ directory. They must not be included directly, as
they are already included by Python.h: :ref:`Include Files <api-includes>`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hum. If we move more header files, the risk of breaking 3rd C extensions is higher. I'm still supportive of this change, but please document it also at C API > Porting to Python 3.10:
https://docs.python.org/dev/whatsnew/3.10.html#id2

In What's New in Python 3.10, document also the other header files that you already moved.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated. I assume the main concern is if they have been included directly? I've worded my note with that in mind, but let me know if I should add anything else.

I've taken a quick look at the remaining files: there are still more than 10 header files that could be moved into cpython/ wholesale, and about the same number which require some surgery. Would you support making these changes (hopefully to close bpo-35134 entirely) within 3.10?

10 changes: 5 additions & 5 deletions PCbuild/pythoncore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,14 @@
<ClInclude Include="..\Include\cpython\methodobject.h" />
<ClInclude Include="..\Include\cpython\object.h" />
<ClInclude Include="..\Include\cpython\objimpl.h" />
<ClInclude Include="..\Include\cpython\odictobject.h" />
<ClInclude Include="..\Include\cpython\parser_interface.h" />
<ClInclude Include="..\Include\cpython\picklebufobject.h" />
<ClInclude Include="..\Include\cpython\pyarena.h" />
<ClInclude Include="..\Include\cpython\pyctype.h" />
<ClInclude Include="..\Include\cpython\pydebug.h" />
<ClInclude Include="..\Include\cpython\pyerrors.h" />
<ClInclude Include="..\Include\cpython\pyfpe.h" />
<ClInclude Include="..\Include\cpython\pylifecycle.h" />
<ClInclude Include="..\Include\cpython\pymem.h" />
<ClInclude Include="..\Include\cpython\pystate.h" />
Expand Down Expand Up @@ -220,19 +225,14 @@
<ClInclude Include="..\Include\namespaceobject.h" />
<ClInclude Include="..\Include\object.h" />
<ClInclude Include="..\Include\objimpl.h" />
<ClInclude Include="..\Include\odictobject.h" />
<ClInclude Include="..\Include\opcode.h" />
<ClInclude Include="..\Include\osdefs.h" />
<ClInclude Include="..\Include\osmodule.h" />
<ClInclude Include="..\Include\patchlevel.h" />
<ClInclude Include="..\Include\parser_interface.h" />
<ClInclude Include="..\Include\picklebufobject.h" />
<ClInclude Include="..\Include\py_curses.h" />
<ClInclude Include="..\Include\pycapsule.h" />
<ClInclude Include="..\Include\pydebug.h" />
<ClInclude Include="..\Include\pyerrors.h" />
<ClInclude Include="..\Include\pyexpat.h" />
<ClInclude Include="..\Include\pyfpe.h" />
<ClInclude Include="..\Include\pyframe.h" />
<ClInclude Include="..\Include\pyhash.h" />
<ClInclude Include="..\Include\pylifecycle.h" />
Expand Down
30 changes: 15 additions & 15 deletions PCbuild/pythoncore.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -171,27 +171,18 @@
<ClInclude Include="..\Include\patchlevel.h">
<Filter>Include</Filter>
</ClInclude>
<ClInclude Include="..\Include\picklebufobject.h">
<Filter>Include</Filter>
</ClInclude>
<ClInclude Include="..\Include\py_curses.h">
<Filter>Include</Filter>
</ClInclude>
<ClInclude Include="..\Include\pycapsule.h">
<Filter>Include</Filter>
</ClInclude>
<ClInclude Include="..\Include\pydebug.h">
<Filter>Include</Filter>
</ClInclude>
<ClInclude Include="..\Include\pyerrors.h">
<Filter>Include</Filter>
</ClInclude>
<ClInclude Include="..\Include\pyexpat.h">
<Filter>Include</Filter>
</ClInclude>
<ClInclude Include="..\Include\pyfpe.h">
<Filter>Include</Filter>
</ClInclude>
<ClInclude Include="..\Include\pylifecycle.h">
<Filter>Include</Filter>
</ClInclude>
Expand Down Expand Up @@ -378,9 +369,6 @@
<ClInclude Include="..\Modules\hashtable.h">
<Filter>Modules</Filter>
</ClInclude>
<ClInclude Include="..\Include\odictobject.h">
<Filter>Include</Filter>
</ClInclude>
<ClInclude Include="..\Parser\pegen.h">
<Filter>Parser</Filter>
</ClInclude>
Expand Down Expand Up @@ -420,6 +408,9 @@
<ClInclude Include="..\Include\cpython\listobject.h">
<Filter>Include\cpython</Filter>
</ClInclude>
<ClInclude Include="..\Include\cpython\odictobject.h">
<Filter>Include</Filter>
</ClInclude>
<ClInclude Include="..\Include\cpython\unicodeobject.h">
<Filter>Include\cpython</Filter>
</ClInclude>
Expand All @@ -432,15 +423,27 @@
<ClInclude Include="..\Include\cpython\object.h">
<Filter>Include\cpython</Filter>
</ClInclude>
<ClInclude Include="..\Include\cpython\parser_interface.h">
<Filter>Include</Filter>
</ClInclude>
<ClInclude Include="..\Include\cpython\picklebufobject.h">
<Filter>Include</Filter>
</ClInclude>
<ClInclude Include="..\Include\cpython\pyarena.h">
<Filter>Include</Filter>
</ClInclude>
<ClInclude Include="..\Include\cpython\pyctype.h">
<Filter>Include</Filter>
</ClInclude>
<ClInclude Include="..\Include\cpython\pydebug.h">
<Filter>Include</Filter>
</ClInclude>
<ClInclude Include="..\Include\cpython\pyerrors.h">
<Filter>Include\cpython</Filter>
</ClInclude>
<ClInclude Include="..\Include\cpython\pyfpe.h">
<Filter>Include</Filter>
</ClInclude>
<ClInclude Include="..\Include\cpython\pymem.h">
<Filter>Include\cpython</Filter>
</ClInclude>
Expand Down Expand Up @@ -474,9 +477,6 @@
<ClInclude Include="..\Include\cpython\initconfig.h">
<Filter>Include\cpython</Filter>
</ClInclude>
<ClInclude Include="..\Include\parser_interface.h">
<Filter>Include</Filter>
</ClInclude>
<ClInclude Include="..\Include\internal\pycore_warnings.h">
<Filter>Include\internal</Filter>
</ClInclude>
Expand Down
2 changes: 1 addition & 1 deletion Parser/peg_api.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "parser_interface.h"
#include "Python.h"

#include "tokenizer.h"
#include "pegen.h"
Expand Down
2 changes: 0 additions & 2 deletions Python/pythonrun.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
#include "symtable.h" // PySymtable_BuildObject()
#include "marshal.h" // PyMarshal_ReadLongFromFile()

#include "parser_interface.h" // PyParser_ASTFrom*

#ifdef MS_WINDOWS
# include "malloc.h" // alloca()
#endif
Expand Down
1 change: 0 additions & 1 deletion Tools/scripts/stable_abi.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"longintrepr.h",
"parsetok.h",
"pyatomic.h",
"pydebug.h",
"pytime.h",
"symtable.h",
"token.h",
Expand Down