Skip to content

input() is blocking exceptions at some phase during execution #112585

Open
@wh-timme

Description

@wh-timme

Bug report

Bug description:

The following loop will soon stuck at some value, due to some phase of built-in input() itself is blocking exceptions and will not pass the exception to upper scope until an ENTER is hit on keyboard.

import os, signal, threading

cnt = [0]

def interrupter(cnt):
	local_cnt = 0
	while 1:
		if local_cnt != cnt[0]:
			local_cnt = cnt[0]
			os.kill(os.getpid(), signal.SIGINT)

threading.Thread(target=interrupter, args=(cnt,), daemon=True).start()

while 1:
	cnt[0] += 1
	try:
		input(">")
	except KeyboardInterrupt:
		print(cnt[0])

CPython versions tested on:

3.8

Operating systems tested on:

macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions