X Tutup
The Wayback Machine - https://web.archive.org/web/20230217045845/https://github.com/python/cpython/issues/94296
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

Bad SIGINT handling behavior after creating tk.Tk object in interactive mode #94296

Open
chgnrdv opened this issue Jun 26, 2022 · 0 comments
Open
Labels
expert-tkinter type-bug An unexpected behavior, bug, or error

Comments

@chgnrdv
Copy link
Contributor

chgnrdv commented Jun 26, 2022

Interactive interpreter doesn't handle keyboard interrupt correctly if tk.Tk object has been created. No exception name or newline with prompt is printed; REPL waits for Enter key to be pressed and then prints traceback instead of exception name.

To reproduce the bug, run python in interactive mode, create new tk.Tk object, then do interrupt and press Enter:

>>> import tkinter as tk
>>> root = tk.Tk()
>>>   # Ctrl+C goes here, but no exception name or newline is printed, so hit Enter
Traceback (most recent call last):
  File "<stdin>", line -1, in <module>
KeyboardInterrupt
>>>

In 3.12.0a0, if user wrote any syntactically incorrect code before interrupting, exception object dump and 'lost sys.stderr' message will be printed:

>>> import tkinter as tk
>>> root = tk.Tk()
>>> def f   # Ctrl+C, then Enter
object address  : 0x7ff4eede5020
object refcount : 2
object type     : 0x5565abf3f260
object type name: SyntaxError
object repr     : SyntaxError("expected '('", ('<stdin>', 1, 6, 'def f', 1, 6))
lost sys.stderr
>>>

CPython versions tried: 3.10.3 and 3.12.0a0 on Linux (5.16.9-arch1-1), 3.9.2 on Windows 10.

@chgnrdv chgnrdv added the type-bug An unexpected behavior, bug, or error label Jun 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
expert-tkinter type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants
X Tutup