Repository navigation
C API: Remove Include/errcode.h header file #107162
Description
Activity
- addedtype-featureA feature request or enhancementA feature request or enhancement
on Jul 23, 2023 It is the part of the C API. See
PyRun_InteractiveOneFlags()documentation.https://docs.python.org/dev/c-api/veryhigh.html#c.PyRun_InteractiveOneFlags
Oh! I looked for errcode.h usage and I couldn't find it. Thanks for pointing me to this function.
I didn't know that these constants are not only used by the tokenizer, but also by the "high-level" API.
Maybe we should just better document this header file. One concern is that constant names are not prefixed by
Py_orPY_. But since it's not included by Python, maybe it's not really an issue.I close this issue which is wrong: the
<errcode.h>header file is part of the Python C API and used by publicPyRun_InteractiveOneFlags()function. I wrote it directly the header file for future readers: 7516953- added a commit that references this issue
on Jul 24, 2023 I am sure that you can use
PyRun_InteractiveOneFlags()even withouterrcode.h. But if you want to get more details about parsing error, you can includeerrcode.h.Since
PyRun_InteractiveOneFlags()can also return-1and set an exception, we perhaps can get rid of these error codes and turn them into appropriate Python exceptions.errcode.hthen became obsolete.Since PyRun_InteractiveOneFlags() can also return -1 and set an exception, we perhaps can get rid of these error codes and turn them into appropriate Python exceptions. errcode.h then became obsolete.
Well, if you want to try that, you can propose a change :-)
Constants exported by the <errcode.h> header file cannot be used outside Python internals. There is no public C API to tokenize a Python source file. I propose to simply remove this header file (move it to the internal C API). It's not included by Python.h.
In Python 3.12, I removed <token.h > header file: see issue #92651.
In Python 3.10, I removed the C API related to AST and the parser, since it was not possible to use it outside Python internals. See: https://docs.python.org/dev/whatsnew/3.10.html#id4
Linked PRs