This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Replace Py_FatalError() with regular Python exceptions
Type: Stage: resolved
Components: Interpreter Core Versions: Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: eric.snow, vstinner
Priority: normal Keywords: patch

Created on 2019-10-29 12:38 by vstinner, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 16998 merged vstinner, 2019-10-30 15:03
PR 17232 merged vstinner, 2019-11-18 16:11
PR 17233 merged vstinner, 2019-11-18 16:13
PR 17266 merged vstinner, 2019-11-19 23:56
PR 18164 merged vstinner, 2020-01-24 10:54
PR 18212 merged vstinner, 2020-01-27 20:59
PR 18214 merged vstinner, 2020-01-27 21:03
PR 18215 merged vstinner, 2020-01-27 21:34
PR 18217 merged vstinner, 2020-01-27 22:00
PR 18258 merged vstinner, 2020-01-29 23:36
PR 18262 merged vstinner, 2020-01-29 23:41
PR 18263 merged vstinner, 2020-01-29 23:54
PR 18278 merged vstinner, 2020-01-30 08:48
PR 18279 merged vstinner, 2020-01-30 08:57
PR 18281 merged vstinner, 2020-01-30 09:32
PR 18908 merged vstinner, 2020-03-10 22:21
PR 24369 merged vstinner, 2021-01-29 17:07
Messages (21)
msg355651 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-10-29 12:38
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.
msg355721 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-10-30 15:39
New changeset 1d8da61f5ad26274556e0bbce260ce292d0402a1 by Victor Stinner in branch 'master':
bpo-38631: Avoid Py_FatalError() in readline (GH-16998)
https://github.com/python/cpython/commit/1d8da61f5ad26274556e0bbce260ce292d0402a1
msg355821 - (view) Author: Eric Snow (eric.snow) * (Python committer) Date: 2019-11-01 14:54
FWIW, I agree. :)
msg355848 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-11-01 22:10
(I have a few more functions that I would like to patch, so I keep the issue open as place holder.)
msg356879 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-11-18 16:39
New changeset 04394df74b3d0783893da7dafa7803a003516402 by Victor Stinner in branch 'master':
bpo-38631: Avoid Py_FatalError() in float.__getformat__() (GH-17232)
https://github.com/python/cpython/commit/04394df74b3d0783893da7dafa7803a003516402
msg356880 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-11-18 16:40
New changeset bc7d3aa6d74b718699b7a6bced9b0dfdfbf95c13 by Victor Stinner in branch 'master':
bpo-38631: Avoid Py_FatalError() in _multibytecodec init (GH-17233)
https://github.com/python/cpython/commit/bc7d3aa6d74b718699b7a6bced9b0dfdfbf95c13
msg357009 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-11-20 00:18
New changeset 444b39bb64aa894d3f1831210a8ce40042a5a532 by Victor Stinner in branch 'master':
bpo-38631: Avoid Py_FatalError() in handle_legacy_finalizers() (GH-17266)
https://github.com/python/cpython/commit/444b39bb64aa894d3f1831210a8ce40042a5a532
msg360631 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-01-24 17:05
New changeset 656c45ec9a9dc2e94cec199ebde553a6979e0e05 by Victor Stinner in branch 'master':
bpo-38631: Avoid Py_FatalError() in GC collect() (GH-18164)
https://github.com/python/cpython/commit/656c45ec9a9dc2e94cec199ebde553a6979e0e05
msg360806 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-01-27 21:37
New changeset a94c6b61aa5c09237b8105e5aee638cd54197b6f by Victor Stinner in branch 'master':
bpo-38631: Avoid Py_FatalError() in PyModule_Create2() (GH-18212)
https://github.com/python/cpython/commit/a94c6b61aa5c09237b8105e5aee638cd54197b6f
msg360807 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-01-27 21:37
New changeset 47ee8a6063c22ec272fe7a2d95d12f7811ebb48b by Victor Stinner in branch 'master':
bpo-38631: Avoid Py_FatalError() in _memory_release() (GH-18214)
https://github.com/python/cpython/commit/47ee8a6063c22ec272fe7a2d95d12f7811ebb48b
msg360811 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-01-27 22:23
New changeset d3a1de22705cc79d7e8a0f44c4f00255e58c8b20 by Victor Stinner in branch 'master':
bpo-38631: Avoid Py_FatalError() in _PyCodecRegistry_Init() (GH-18217)
https://github.com/python/cpython/commit/d3a1de22705cc79d7e8a0f44c4f00255e58c8b20
msg360812 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-01-27 22:24
New changeset a27831351873bd7eff10863353d475c29fb0d7bb by Victor Stinner in branch 'master':
bpo-38631: Avoid Py_FatalError() in PyCode_New() (GH-18215)
https://github.com/python/cpython/commit/a27831351873bd7eff10863353d475c29fb0d7bb
msg360817 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-01-27 22:38
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.
msg361017 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-01-30 08:01
New changeset 5eb8bff7e4aa7e4d8580a30323641388c8ff59a5 by Victor Stinner in branch 'master':
bpo-38631: Replace Py_FatalError() with _PyObject_ASSERT_FAILED_MSG() (GH-18258)
https://github.com/python/cpython/commit/5eb8bff7e4aa7e4d8580a30323641388c8ff59a5
msg361018 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-01-30 08:02
New changeset 7a1f6c2da46a04d0ff0acc01542f30bfeaf0e0c7 by Victor Stinner in branch 'master':
bpo-38631: Avoid Py_FatalError() in init_slotdefs() (GH-18263)
https://github.com/python/cpython/commit/7a1f6c2da46a04d0ff0acc01542f30bfeaf0e0c7
msg361019 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-01-30 08:02
New changeset 2bf127d97bd1d60ead7c20d429b0c61ef61fc554 by Victor Stinner in branch 'master':
bpo-38631: Replace tp_new_wrapper() fatal error with SystemError (GH-18262)
https://github.com/python/cpython/commit/2bf127d97bd1d60ead7c20d429b0c61ef61fc554
msg361039 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-01-30 11:18
New changeset ec3c99c8a73650d7833189bd973ec492564aa479 by Victor Stinner in branch 'master':
bpo-38631: Avoid Py_FatalError() in unicodeobject.c (GH-18281)
https://github.com/python/cpython/commit/ec3c99c8a73650d7833189bd973ec492564aa479
msg361040 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-01-30 11:20
New changeset 17c68b8107e348aeaaa05f7ac5072cacff916022 by Victor Stinner in branch 'master':
bpo-38631: Replace Py_FatalError() with assert() in ceval.c (GH-18279)
https://github.com/python/cpython/commit/17c68b8107e348aeaaa05f7ac5072cacff916022
msg361050 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-01-30 12:09
New changeset 2a4903fcce54c25807d362dbbbcfb32d0b494f9f by Victor Stinner in branch 'master':
bpo-38631: Add _Py_NO_RETURN to functions calling Py_FatalError() (GH-18278)
https://github.com/python/cpython/commit/2a4903fcce54c25807d362dbbbcfb32d0b494f9f
msg363858 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-03-10 22:49
New changeset 4e53abb0f4773e1cce68a4f41ddbb43e74364c5f by Victor Stinner in branch 'master':
bpo-38631: _PyGILState_Init() returns PyStatus (GH-18908)
https://github.com/python/cpython/commit/4e53abb0f4773e1cce68a4f41ddbb43e74364c5f
msg385962 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-01-30 00:46
New changeset ba7a99ddb52a45c8dec1f7e9f1648add0ace82ab by Victor Stinner in branch 'master':
bpo-38631: Replace compiler fatal errors with exceptions (GH-24369)
https://github.com/python/cpython/commit/ba7a99ddb52a45c8dec1f7e9f1648add0ace82ab
History
Date User Action Args
2022-04-11 14:59:22adminsetgithub: 82812
2021-01-30 00:46:47vstinnersetmessages: + msg385962
2021-01-29 17:07:03vstinnersetpull_requests: + pull_request23193
2020-03-10 22:49:20vstinnersetmessages: + msg363858
2020-03-10 22:21:35vstinnersetpull_requests: + pull_request18263
2020-01-30 12:09:18vstinnersetmessages: + msg361050
2020-01-30 11:20:54vstinnersetmessages: + msg361040
2020-01-30 11:18:39vstinnersetmessages: + msg361039
2020-01-30 09:32:27vstinnersetpull_requests: + pull_request17656
2020-01-30 08:57:55vstinnersetpull_requests: + pull_request17654
2020-01-30 08:48:20vstinnersetpull_requests: + pull_request17653
2020-01-30 08:02:55vstinnersetmessages: + msg361019
2020-01-30 08:02:20vstinnersetmessages: + msg361018
2020-01-30 08:01:22vstinnersetmessages: + msg361017
2020-01-29 23:54:53vstinnersetpull_requests: + pull_request17640
2020-01-29 23:41:16vstinnersetpull_requests: + pull_request17639
2020-01-29 23:36:26vstinnersetpull_requests: + pull_request17638
2020-01-27 22:38:21vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg360817

stage: patch review -> resolved
2020-01-27 22:24:17vstinnersetmessages: + msg360812
2020-01-27 22:23:18vstinnersetmessages: + msg360811
2020-01-27 22:00:39vstinnersetpull_requests: + pull_request17597
2020-01-27 21:37:47vstinnersetmessages: + msg360807
2020-01-27 21:37:09vstinnersetmessages: + msg360806
2020-01-27 21:34:10vstinnersetpull_requests: + pull_request17595
2020-01-27 21:03:42vstinnersetpull_requests: + pull_request17594
2020-01-27 20:59:29vstinnersetpull_requests: + pull_request17591
2020-01-24 17:05:27vstinnersetmessages: + msg360631
2020-01-24 10:54:53vstinnersetpull_requests: + pull_request17551
2019-11-20 00:18:14vstinnersetmessages: + msg357009
2019-11-19 23:56:40vstinnersetpull_requests: + pull_request16758
2019-11-18 16:40:11vstinnersetmessages: + msg356880
2019-11-18 16:39:51vstinnersetmessages: + msg356879
2019-11-18 16:13:40vstinnersetpull_requests: + pull_request16733
2019-11-18 16:11:14vstinnersetpull_requests: + pull_request16732
2019-11-01 22:10:08vstinnersetmessages: + msg355848
2019-11-01 14:54:38eric.snowsetnosy: + eric.snow
messages: + msg355821
2019-10-30 15:39:30vstinnersetmessages: + msg355721
2019-10-30 15:03:02vstinnersetkeywords: + patch
stage: patch review
pull_requests: + pull_request16525
2019-10-29 12:38:55vstinnercreate