Skip to content

gh-107162: Remove errcode.h header file #107163

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

Closed
wants to merge 1 commit into from
Closed
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
5 changes: 5 additions & 0 deletions Doc/whatsnew/3.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,11 @@ Removed
be used instead.
(Contributed by Serhiy Storchaka in :gh:`86493`.)

* Remove the ``errcode.h`` header file. There was never any public tokenizer C
API. The ``errcode.h`` header file was only designed to be used by Python
internals.
(Contributed by Victor Stinner in :gh:`107162`.)

Pending Removal in Python 3.14
------------------------------

Expand Down
19 changes: 11 additions & 8 deletions Include/errcode.h → Include/internal/pycore_errcode.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
#ifndef Py_ERRCODE_H
#define Py_ERRCODE_H
#ifdef __cplusplus
extern "C" {
#endif


/* Error codes passed around between file input, tokenizer, parser and
interpreter. This is necessary so we can turn them into Python
exceptions at a higher level. Note that some errors have a
Expand All @@ -13,6 +6,16 @@ extern "C" {
the parser only returns E_EOF when it hits EOF immediately, and it
never returns E_OK. */

#ifndef Py_INTERNAL_ERRCODE_H
#define Py_INTERNAL_ERRCODE_H
#ifdef __cplusplus
extern "C" {
#endif

#ifndef Py_BUILD_CORE
# error "this header requires Py_BUILD_CORE define"
#endif

#define E_OK 10 /* No error */
#define E_EOF 11 /* End Of File */
#define E_INTR 12 /* Interrupted */
Expand All @@ -35,4 +38,4 @@ extern "C" {
#ifdef __cplusplus
}
#endif
#endif /* !Py_ERRCODE_H */
#endif // !Py_INTERNAL_ERRCODE_H
4 changes: 2 additions & 2 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -1625,7 +1625,6 @@ PYTHON_HEADERS= \
$(srcdir)/Include/dictobject.h \
$(srcdir)/Include/dynamic_annotations.h \
$(srcdir)/Include/enumobject.h \
$(srcdir)/Include/errcode.h \
$(srcdir)/Include/fileobject.h \
$(srcdir)/Include/fileutils.h \
$(srcdir)/Include/floatobject.h \
Expand Down Expand Up @@ -1750,10 +1749,11 @@ PYTHON_HEADERS= \
$(srcdir)/Include/internal/pycore_complexobject.h \
$(srcdir)/Include/internal/pycore_condvar.h \
$(srcdir)/Include/internal/pycore_context.h \
$(srcdir)/Include/internal/pycore_descrobject.h \
$(srcdir)/Include/internal/pycore_dict.h \
$(srcdir)/Include/internal/pycore_dict_state.h \
$(srcdir)/Include/internal/pycore_descrobject.h \
$(srcdir)/Include/internal/pycore_dtoa.h \
$(srcdir)/Include/internal/pycore_errcode.h \
$(srcdir)/Include/internal/pycore_exceptions.h \
$(srcdir)/Include/internal/pycore_faulthandler.h \
$(srcdir)/Include/internal/pycore_fileutils.h \
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Remove the ``errcode.h`` header file. There was never any public tokenizer C
API. The ``errcode.h`` header file was only designed to be used by Python
internals. Patch by Victor Stinner.
2 changes: 1 addition & 1 deletion PCbuild/pythoncore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@
<ClInclude Include="..\Include\dictobject.h" />
<ClInclude Include="..\Include\dynamic_annotations.h" />
<ClInclude Include="..\Include\enumobject.h" />
<ClInclude Include="..\Include\errcode.h" />
<ClInclude Include="..\Include\fileobject.h" />
<ClInclude Include="..\Include\fileutils.h" />
<ClInclude Include="..\Include\floatobject.h" />
Expand Down Expand Up @@ -218,6 +217,7 @@
<ClInclude Include="..\Include\internal\pycore_dict.h" />
<ClInclude Include="..\Include\internal\pycore_dict_state.h" />
<ClInclude Include="..\Include\internal\pycore_dtoa.h" />
<ClInclude Include="..\Include\internal\pycore_errcode.h" />
<ClInclude Include="..\Include\internal\pycore_exceptions.h" />
<ClInclude Include="..\Include\internal\pycore_faulthandler.h" />
<ClInclude Include="..\Include\internal\pycore_fileutils.h" />
Expand Down
6 changes: 3 additions & 3 deletions PCbuild/pythoncore.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@
<ClInclude Include="..\Include\enumobject.h">
<Filter>Include</Filter>
</ClInclude>
<ClInclude Include="..\Include\errcode.h">
<Filter>Include</Filter>
</ClInclude>
<ClInclude Include="..\Include\fileobject.h">
<Filter>Include</Filter>
</ClInclude>
Expand Down Expand Up @@ -558,6 +555,9 @@
<ClInclude Include="..\Include\internal\pycore_dtoa.h">
<Filter>Include\internal</Filter>
</ClInclude>
<ClInclude Include="..\Include\internal\pycore_errcode.h">
<Filter>Include\internal</Filter>
</ClInclude>
<ClInclude Include="..\Include\internal\pycore_exceptions.h">
<Filter>Include\internal</Filter>
</ClInclude>
Expand Down
2 changes: 1 addition & 1 deletion Parser/pegen.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <Python.h>
#include "pycore_ast.h" // _PyAST_Validate(),
#include "pycore_errcode.h" // E_BADSINGLE
#include "pycore_pystate.h" // _PyThreadState_GET()
#include <errcode.h>

#include "tokenizer.h"
#include "pegen.h"
Expand Down
3 changes: 1 addition & 2 deletions Parser/pegen_errors.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include <Python.h>
#include <errcode.h>

#include "pycore_errcode.h" // E_TOKEN
#include "pycore_pyerrors.h" // _PyErr_ProgramDecodedTextObject()
#include "tokenizer.h"
#include "pegen.h"
Expand Down
2 changes: 1 addition & 1 deletion Parser/tokenizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

#include "Python.h"
#include "pycore_call.h" // _PyObject_CallNoArgs()
#include "pycore_errcode.h" // E_OK

#include <ctype.h>
#include <assert.h>

#include "tokenizer.h"
#include "errcode.h"

/* Alternate tab spacing */
#define ALTTABSIZE 1
Expand Down
2 changes: 1 addition & 1 deletion Python/Python-tokenize.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "Python.h"
#include "errcode.h"
#include "pycore_errcode.h" // E_TOKEN
#include "../Parser/tokenizer.h"
#include "../Parser/pegen.h" // _PyPegen_byte_offset_to_character_offset()
#include "../Parser/pegen.h" // _PyPegen_byte_offset_to_character_offset()
Expand Down
3 changes: 1 addition & 2 deletions Python/pythonrun.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
#include <stdbool.h>

#include "Python.h"

#include "pycore_ast.h" // PyAST_mod2obj
#include "pycore_ceval.h" // _Py_EnterRecursiveCall
#include "pycore_compile.h" // _PyAST_Compile()
#include "pycore_errcode.h" // E_EOF
#include "pycore_interp.h" // PyInterpreterState.importlib
#include "pycore_object.h" // _PyDebug_PrintTotalRefs()
#include "pycore_parser.h" // _PyParser_ASTFromString()
Expand All @@ -24,7 +24,6 @@
#include "pycore_sysmodule.h" // _PySys_Audit()
#include "pycore_traceback.h" // _PyTraceBack_Print_Indented()

#include "errcode.h" // E_EOF
#include "marshal.h" // PyMarshal_ReadLongFromFile()

#ifdef MS_WINDOWS
Expand Down