]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-112292 : Catch import error conditions with readline hooks (gh-112313)
authorAnthony Shaw <anthony.p.shaw@gmail.com>
Tue, 28 Nov 2023 01:58:53 +0000 (12:58 +1100)
committerGitHub <noreply@github.com>
Tue, 28 Nov 2023 01:58:53 +0000 (18:58 -0700)
commit154f099e611cea74daa755c77df3b8003861cc76
treea46ac82eab33ba99842613f95886faea1a01f846
parent2e632fa07d13a58be62f59be4e656ad58b378f9b
gh-112292 : Catch import error conditions with readline hooks (gh-112313)

Prevents a segmentation fault in registered hooks for the readline library, but only when the readline module is loaded inside an isolated sub interpreter.  The module is single-phase init so loading it fails, but not until the module init function has already run, where the readline hooks get registered.

The readlinestate_global macro was error-prone to PyImport_FindModule returning NULL and crashing in about 18 places.  I could reproduce 1 easily, but this PR replaces the macro with a function and adds error conditions to the other functions.
Misc/NEWS.d/next/Library/2023-11-22-19-43-54.gh-issue-112292.5nDU87.rst [new file with mode: 0644]
Modules/readline.c