Closed
Labels
topic-replRelated to the interactive shellRelated to the interactive shelltype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
We are currently not calling PyOS_InputHook if is set before blocking for input in the new REPL
Linked PRs
Metadata
Metadata
Assignees
Labels
topic-replRelated to the interactive shellRelated to the interactive shelltype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Projects
- StatusShow more project fieldsDone
Activity
pythongh-119842: Honor PyOS_InputHook in the new REPL
pythongh-119842: Honor PyOS_InputHook in the new REPL
mdboom commentedon May 31, 2024
Here's a good reproducer to ensure your changes are working (on Linux):
(
make installis required to getpkgconfigworking for all the dependencies).If working, a window should appear with a plot in it, and it should respond to mouse events etc. It seems that on CPython main, this is broken, but works with
PYTHON_BASIC_REPL=1set.Cc: @tacaswell, do I have this right? IIUC this works due to Tkinter's built-in use of PyOS_InputHook, matplotlib itself doesn't touch it.
EDIT: See a simpler reproducer below
mdboom commentedon May 31, 2024
With #119843 (currently), this fails with:
mdboom commentedon May 31, 2024
Here's a much easier reproducer with no external dependencies:
Current behavior I'm seeing:
CPython main: No window
CPython main / PYTHON_BASIC_REPL=1: Window is displayed, updated automatically with each line of entry (matches 3.12)
#119843:
Fatal Python error: _PyThreadState_Attach: non-NULL old thread state#119843 / PYTHON_BASIC_REPL=1: Window is displayed, updated automatically with each line of entry (matches 3.12)
tacaswell commentedon May 31, 2024
@mdboom Correct. PyQt, wxpython, and the gtk bindings all provide their own verision of
PyOS_InputHookas well and mpl provides one for macOSX.To be 100% sure the event loop is running as expected also add a "print on click" callback:
pythongh-119842: Honor PyOS_InputHook in the new REPL
pythongh-119842: Honor PyOS_InputHook in the new REPL
pythongh-119842: Honor PyOS_InputHook in the new REPL
pythongh-119842: Honor PyOS_InputHook in the new REPL
Merge branch 'main' into pythongh-119842
Merge branch 'main' into pythongh-119842
gh-119842: Honor PyOS_InputHook in the new REPL (GH-119843)
[3.13] pythongh-119842: Honor PyOS_InputHook in the new REPL (pythonG…
[3.13] gh-119842: Honor PyOS_InputHook in the new REPL (GH-119843) (G…
pythongh-119842: Honor PyOS_InputHook in the new REPL (pythonGH-119843)
pythongh-119842: Honor PyOS_InputHook in the new REPL (pythonGH-119843)