Skip to content
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

Replace Py_FatalError() with regular Python exceptions #82812

Closed
vstinner opened this issue Oct 29, 2019 · 21 comments
Closed

Replace Py_FatalError() with regular Python exceptions #82812

vstinner opened this issue Oct 29, 2019 · 21 comments
Labels
3.9 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@vstinner
Copy link
Member

BPO 38631
Nosy @vstinner, @ericsnowcurrently
PRs
  • bpo-38631: Avoid Py_FatalError() in readline #16998
  • bpo-38631: Avoid Py_FatalError() in float.__getformat__() #17232
  • bpo-38631: Avoid Py_FatalError() in _multibytecodec init #17233
  • bpo-38631: Avoid Py_FatalError() in handle_legacy_finalizers() #17266
  • bpo-38631: Avoid Py_FatalError() in GC collect() #18164
  • bpo-38631: Avoid Py_FatalError() in PyModule_Create2() #18212
  • bpo-38631: Avoid Py_FatalError() in _memory_release() #18214
  • bpo-38631: Avoid Py_FatalError() in PyCode_New() #18215
  • bpo-38631: Avoid Py_FatalError() in _PyCodecRegistry_Init() #18217
  • bpo-38631: Replace Py_FatalError() with _PyObject_ASSERT_FAILED_MSG() #18258
  • bpo-38631: Replace tp_new_wrapper() fatal error with SystemError #18262
  • bpo-38631: Avoid Py_FatalError() in init_slotdefs() #18263
  • bpo-38631: Add _Py_NO_RETURN to functions calling Py_FatalError() #18278
  • bpo-38631: Replace Py_FatalError() with assert() in ceval.c #18279
  • bpo-38631: Avoid Py_FatalError() in unicodeobject.c #18281
  • bpo-38631: _PyGILState_Init() returns PyStatus #18908
  • bpo-38631: Replace compiler fatal errors with exceptions #24369
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2020-01-27.22:38:21.495>
    created_at = <Date 2019-10-29.12:38:55.471>
    labels = ['interpreter-core', '3.9']
    title = 'Replace Py_FatalError() with regular Python exceptions'
    updated_at = <Date 2021-01-30.00:46:47.101>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2021-01-30.00:46:47.101>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-01-27.22:38:21.495>
    closer = 'vstinner'
    components = ['Interpreter Core']
    creation = <Date 2019-10-29.12:38:55.471>
    creator = 'vstinner'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 38631
    keywords = ['patch']
    message_count = 21.0
    messages = ['355651', '355721', '355821', '355848', '356879', '356880', '357009', '360631', '360806', '360807', '360811', '360812', '360817', '361017', '361018', '361019', '361039', '361040', '361050', '363858', '385962']
    nosy_count = 2.0
    nosy_names = ['vstinner', 'eric.snow']
    pr_nums = ['16998', '17232', '17233', '17266', '18164', '18212', '18214', '18215', '18217', '18258', '18262', '18263', '18278', '18279', '18281', '18908', '24369']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue38631'
    versions = ['Python 3.9']

    @vstinner
    Copy link
    Member Author

    I replaced dozens of Py_FatalError() calls with better error reporting, but there are still many places calling Py_FatalError().

    The problem of Py_FatalError() is when Python is embedded into an application: Python must not kill the whole process.

    Well, even in the "regular" Python (/usr/bin/python3), Python should not exit immediately on an error.

    For example, the readline module calls Py_FatalError() on memory allocation failure, whereas PyErr_NoMemory() could be used: PyErr_NoMemory() should work since it should not allocate memory.

    @vstinner vstinner added 3.9 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Oct 29, 2019
    @vstinner
    Copy link
    Member Author

    New changeset 1d8da61 by Victor Stinner in branch 'master':
    bpo-38631: Avoid Py_FatalError() in readline (GH-16998)
    1d8da61

    @ericsnowcurrently
    Copy link
    Member

    FWIW, I agree. :)

    @vstinner
    Copy link
    Member Author

    vstinner commented Nov 1, 2019

    (I have a few more functions that I would like to patch, so I keep the issue open as place holder.)

    @vstinner
    Copy link
    Member Author

    New changeset 04394df by Victor Stinner in branch 'master':
    bpo-38631: Avoid Py_FatalError() in float.__getformat__() (GH-17232)
    04394df

    @vstinner
    Copy link
    Member Author

    New changeset bc7d3aa by Victor Stinner in branch 'master':
    bpo-38631: Avoid Py_FatalError() in _multibytecodec init (GH-17233)
    bc7d3aa

    @vstinner
    Copy link
    Member Author

    New changeset 444b39b by Victor Stinner in branch 'master':
    bpo-38631: Avoid Py_FatalError() in handle_legacy_finalizers() (GH-17266)
    444b39b

    @vstinner
    Copy link
    Member Author

    New changeset 656c45e by Victor Stinner in branch 'master':
    bpo-38631: Avoid Py_FatalError() in GC collect() (GH-18164)
    656c45e

    @vstinner
    Copy link
    Member Author

    New changeset a94c6b6 by Victor Stinner in branch 'master':
    bpo-38631: Avoid Py_FatalError() in PyModule_Create2() (GH-18212)
    a94c6b6

    @vstinner
    Copy link
    Member Author

    New changeset 47ee8a6 by Victor Stinner in branch 'master':
    bpo-38631: Avoid Py_FatalError() in _memory_release() (GH-18214)
    47ee8a6

    @vstinner
    Copy link
    Member Author

    New changeset d3a1de2 by Victor Stinner in branch 'master':
    bpo-38631: Avoid Py_FatalError() in _PyCodecRegistry_Init() (GH-18217)
    d3a1de2

    @vstinner
    Copy link
    Member Author

    New changeset a278313 by Victor Stinner in branch 'master':
    bpo-38631: Avoid Py_FatalError() in PyCode_New() (GH-18215)
    a278313

    @vstinner
    Copy link
    Member Author

    There are still around 122 calls to Py_FatalError() in the master branch. But remaining ones are the hardest to remove. I close the issue, it's already better than previously.

    Compare this number to 285 calls in Python 3.6.

    @vstinner
    Copy link
    Member Author

    New changeset 5eb8bff by Victor Stinner in branch 'master':
    bpo-38631: Replace Py_FatalError() with _PyObject_ASSERT_FAILED_MSG() (GH-18258)
    5eb8bff

    @vstinner
    Copy link
    Member Author

    New changeset 7a1f6c2 by Victor Stinner in branch 'master':
    bpo-38631: Avoid Py_FatalError() in init_slotdefs() (GH-18263)
    7a1f6c2

    @vstinner
    Copy link
    Member Author

    New changeset 2bf127d by Victor Stinner in branch 'master':
    bpo-38631: Replace tp_new_wrapper() fatal error with SystemError (GH-18262)
    2bf127d

    @vstinner
    Copy link
    Member Author

    New changeset ec3c99c by Victor Stinner in branch 'master':
    bpo-38631: Avoid Py_FatalError() in unicodeobject.c (GH-18281)
    ec3c99c

    @vstinner
    Copy link
    Member Author

    New changeset 17c68b8 by Victor Stinner in branch 'master':
    bpo-38631: Replace Py_FatalError() with assert() in ceval.c (GH-18279)
    17c68b8

    @vstinner
    Copy link
    Member Author

    New changeset 2a4903f by Victor Stinner in branch 'master':
    bpo-38631: Add _Py_NO_RETURN to functions calling Py_FatalError() (GH-18278)
    2a4903f

    @vstinner
    Copy link
    Member Author

    New changeset 4e53abb by Victor Stinner in branch 'master':
    bpo-38631: _PyGILState_Init() returns PyStatus (GH-18908)
    4e53abb

    @vstinner
    Copy link
    Member Author

    New changeset ba7a99d by Victor Stinner in branch 'master':
    bpo-38631: Replace compiler fatal errors with exceptions (GH-24369)
    ba7a99d

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.9 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs)
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants