Skip to content

Commit 0cef34e

Browse files
committed
gh-107162: Remove errcode.h header file
Rename Include/errcode.h to Include/internal/pycore_errcode.h.
1 parent 1e50112 commit 0cef34e

File tree

11 files changed

+30
-21
lines changed

11 files changed

+30
-21
lines changed

Doc/whatsnew/3.13.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,11 @@ Removed
981981
be used instead.
982982
(Contributed by Serhiy Storchaka in :gh:`86493`.)
983983

984+
* Remove the ``errcode.h`` header file. There was never any public tokenizer C
985+
API. The ``errcode.h`` header file was only designed to be used by Python
986+
internals.
987+
(Contributed by Victor Stinner in :gh:`107162`.)
988+
984989
Pending Removal in Python 3.14
985990
------------------------------
986991

Include/errcode.h renamed to Include/internal/pycore_errcode.h

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
#ifndef Py_ERRCODE_H
2-
#define Py_ERRCODE_H
3-
#ifdef __cplusplus
4-
extern "C" {
5-
#endif
6-
7-
81
/* Error codes passed around between file input, tokenizer, parser and
92
interpreter. This is necessary so we can turn them into Python
103
exceptions at a higher level. Note that some errors have a
@@ -13,6 +6,16 @@ extern "C" {
136
the parser only returns E_EOF when it hits EOF immediately, and it
147
never returns E_OK. */
158

9+
#ifndef Py_INTERNAL_ERRCODE_H
10+
#define Py_INTERNAL_ERRCODE_H
11+
#ifdef __cplusplus
12+
extern "C" {
13+
#endif
14+
15+
#ifndef Py_BUILD_CORE
16+
# error "this header requires Py_BUILD_CORE define"
17+
#endif
18+
1619
#define E_OK 10 /* No error */
1720
#define E_EOF 11 /* End Of File */
1821
#define E_INTR 12 /* Interrupted */
@@ -35,4 +38,4 @@ extern "C" {
3538
#ifdef __cplusplus
3639
}
3740
#endif
38-
#endif /* !Py_ERRCODE_H */
41+
#endif // !Py_INTERNAL_ERRCODE_H

Makefile.pre.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,7 +1625,6 @@ PYTHON_HEADERS= \
16251625
$(srcdir)/Include/dictobject.h \
16261626
$(srcdir)/Include/dynamic_annotations.h \
16271627
$(srcdir)/Include/enumobject.h \
1628-
$(srcdir)/Include/errcode.h \
16291628
$(srcdir)/Include/fileobject.h \
16301629
$(srcdir)/Include/fileutils.h \
16311630
$(srcdir)/Include/floatobject.h \
@@ -1750,10 +1749,11 @@ PYTHON_HEADERS= \
17501749
$(srcdir)/Include/internal/pycore_complexobject.h \
17511750
$(srcdir)/Include/internal/pycore_condvar.h \
17521751
$(srcdir)/Include/internal/pycore_context.h \
1752+
$(srcdir)/Include/internal/pycore_descrobject.h \
17531753
$(srcdir)/Include/internal/pycore_dict.h \
17541754
$(srcdir)/Include/internal/pycore_dict_state.h \
1755-
$(srcdir)/Include/internal/pycore_descrobject.h \
17561755
$(srcdir)/Include/internal/pycore_dtoa.h \
1756+
$(srcdir)/Include/internal/pycore_errcode.h \
17571757
$(srcdir)/Include/internal/pycore_exceptions.h \
17581758
$(srcdir)/Include/internal/pycore_faulthandler.h \
17591759
$(srcdir)/Include/internal/pycore_fileutils.h \
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Remove the ``errcode.h`` header file. There was never any public tokenizer C
2+
API. The ``errcode.h`` header file was only designed to be used by Python
3+
internals. Patch by Victor Stinner.

PCbuild/pythoncore.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@
188188
<ClInclude Include="..\Include\dictobject.h" />
189189
<ClInclude Include="..\Include\dynamic_annotations.h" />
190190
<ClInclude Include="..\Include\enumobject.h" />
191-
<ClInclude Include="..\Include\errcode.h" />
192191
<ClInclude Include="..\Include\fileobject.h" />
193192
<ClInclude Include="..\Include\fileutils.h" />
194193
<ClInclude Include="..\Include\floatobject.h" />
@@ -218,6 +217,7 @@
218217
<ClInclude Include="..\Include\internal\pycore_dict.h" />
219218
<ClInclude Include="..\Include\internal\pycore_dict_state.h" />
220219
<ClInclude Include="..\Include\internal\pycore_dtoa.h" />
220+
<ClInclude Include="..\Include\internal\pycore_errcode.h" />
221221
<ClInclude Include="..\Include\internal\pycore_exceptions.h" />
222222
<ClInclude Include="..\Include\internal\pycore_faulthandler.h" />
223223
<ClInclude Include="..\Include\internal\pycore_fileutils.h" />

PCbuild/pythoncore.vcxproj.filters

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,6 @@
8181
<ClInclude Include="..\Include\enumobject.h">
8282
<Filter>Include</Filter>
8383
</ClInclude>
84-
<ClInclude Include="..\Include\errcode.h">
85-
<Filter>Include</Filter>
86-
</ClInclude>
8784
<ClInclude Include="..\Include\fileobject.h">
8885
<Filter>Include</Filter>
8986
</ClInclude>
@@ -558,6 +555,9 @@
558555
<ClInclude Include="..\Include\internal\pycore_dtoa.h">
559556
<Filter>Include\internal</Filter>
560557
</ClInclude>
558+
<ClInclude Include="..\Include\internal\pycore_errcode.h">
559+
<Filter>Include\internal</Filter>
560+
</ClInclude>
561561
<ClInclude Include="..\Include\internal\pycore_exceptions.h">
562562
<Filter>Include\internal</Filter>
563563
</ClInclude>

Parser/pegen.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include <Python.h>
22
#include "pycore_ast.h" // _PyAST_Validate(),
3+
#include "pycore_errcode.h" // E_BADSINGLE
34
#include "pycore_pystate.h" // _PyThreadState_GET()
4-
#include <errcode.h>
55

66
#include "tokenizer.h"
77
#include "pegen.h"

Parser/pegen_errors.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include <Python.h>
2-
#include <errcode.h>
3-
2+
#include "pycore_errcode.h" // E_TOKEN
43
#include "pycore_pyerrors.h" // _PyErr_ProgramDecodedTextObject()
54
#include "tokenizer.h"
65
#include "pegen.h"

Parser/tokenizer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33

44
#include "Python.h"
55
#include "pycore_call.h" // _PyObject_CallNoArgs()
6+
#include "pycore_errcode.h" // E_OK
67

78
#include <ctype.h>
89
#include <assert.h>
910

1011
#include "tokenizer.h"
11-
#include "errcode.h"
1212

1313
/* Alternate tab spacing */
1414
#define ALTTABSIZE 1

Python/Python-tokenize.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "Python.h"
2-
#include "errcode.h"
2+
#include "pycore_errcode.h" // E_TOKEN
33
#include "../Parser/tokenizer.h"
44
#include "../Parser/pegen.h" // _PyPegen_byte_offset_to_character_offset()
55
#include "../Parser/pegen.h" // _PyPegen_byte_offset_to_character_offset()

0 commit comments

Comments
 (0)