Skip to content

C API: Remove Include/errcode.h header file #107162

Description

@vstinner

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

Activity

  1. added 2 commits that reference this issue on Jul 23, 2023
  2. serhiy-storchaka commented on Jul 24, 2023

    @serhiy-storchaka
    Member

    It is the part of the C API. See PyRun_InteractiveOneFlags() documentation.

  3. vstinner commented on Jul 24, 2023

    @vstinner
    MemberAuthor

    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_ or PY_. But since it's not included by Python, maybe it's not really an issue.

  4. added 3 commits that reference this issue on Jul 24, 2023
  5. added a commit that references this issue on Jul 24, 2023
  6. vstinner commented on Jul 24, 2023

    @vstinner
    MemberAuthor

    I close this issue which is wrong: the <errcode.h> header file is part of the Python C API and used by public PyRun_InteractiveOneFlags() function. I wrote it directly the header file for future readers: 7516953

  7. added a commit that references this issue on Jul 24, 2023
  8. serhiy-storchaka commented on Jul 25, 2023

    @serhiy-storchaka
    Member

    I am sure that you can use PyRun_InteractiveOneFlags() even without errcode.h. But if you want to get more details about parsing error, you can include errcode.h.

    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.

  9. vstinner commented on Jul 25, 2023

    @vstinner
    MemberAuthor

    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 :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions