gh-112292 : Catch import error conditions with readline hooks (gh-112… · python/cpython@154f099 · GitHub
Skip to content

Commit 154f099

Browse files
authored
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.
1 parent 2e632fa commit 154f099

2 files changed

Lines changed: 71 additions & 22 deletions

File tree

Lines changed: 2 additions & 0 deletions

Modules/readline.c

Lines changed: 69 additions & 22 deletions

0 commit comments

Comments
 (0)