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

Error traceback when interrupting+terminating python #132017

Open
smurfix opened this issue Apr 2, 2025 · 1 comment
Open

Error traceback when interrupting+terminating python #132017

smurfix opened this issue Apr 2, 2025 · 1 comment
Labels
3.13 bugs and security fixes 3.14 new features, bugs and security fixes stdlib Python modules in the Lib dir topic-repl Related to the interactive shell type-bug An unexpected behavior, bug, or error

Comments

@smurfix
Copy link

smurfix commented Apr 2, 2025

Bug report

Bug description:

How to reproduce:

  • start python3
  • interrupt with ^Z
  • resume with fg
  • immediately press ^D (EOF)
$ python3
>>> ^Z
Stopped
$ fg
^D

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/lib/python3.13/_pyrepl/__main__.py", line 6, in <module>
    __pyrepl_interactive_console()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/lib/python3.13/_pyrepl/main.py", line 59, in interactive_console
    run_multiline_interactive_console(console)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/usr/lib/python3.13/_pyrepl/simple_interact.py", line 142, in run_multiline_interactive_console
    statement = multiline_input(more_lines, ps1, ps2)
  File "/usr/lib/python3.13/_pyrepl/readline.py", line 389, in multiline_input
    return reader.readline()
           ~~~~~~~~~~~~~~~^^
  File "/usr/lib/python3.13/_pyrepl/reader.py", line 803, in readline
    self.handle1()
    ~~~~~~~~~~~~^^
  File "/usr/lib/python3.13/_pyrepl/reader.py", line 759, in handle1
    event = self.console.get_event(block=False)
  File "/usr/lib/python3.13/_pyrepl/unix_console.py", line 406, in get_event
    self.push_char(self.__read(1))
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/_pyrepl/unix_console.py", line 388, in push_char
    self.event_queue.push(char)
    ~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/usr/lib/python3.13/_pyrepl/unix_eventqueue.py", line 120, in push
    ord_char = char if isinstance(char, int) else ord(char)
                                                  ~~~^^^^^^
TypeError: ord() expected a character, but string of length 0 found
$

Also + likely related: resuming Python doesn't restore the >>> prompt (nor command-line editing) until I press Enter, presumably due to the interactive interpreter not listening to SIGCONT.

CPython versions tested on:

3.13

Operating systems tested on:

Linux

@smurfix smurfix added the type-bug An unexpected behavior, bug, or error label Apr 2, 2025
@StanFromIreland
Copy link
Contributor

StanFromIreland commented Apr 2, 2025

Can recreate on 3.14

$ python3.14
Python 3.14.0a6+ (heads/main:d260631be06, Mar 28 2025, 17:05:59) [GCC 14.2.1 20250110 (Red Hat 14.2.1-7)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 
[1]+  Stopped                 python3.14
$ fg
python3.14
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/local/lib/python3.14/_pyrepl/__main__.py", line 6, in <module>
    __pyrepl_interactive_console()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/local/lib/python3.14/_pyrepl/main.py", line 59, in interactive_console
    run_multiline_interactive_console(console)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/usr/local/lib/python3.14/_pyrepl/simple_interact.py", line 137, in run_multiline_interactive_console
    statement = multiline_input(more_lines, ps1, ps2)
  File "/usr/local/lib/python3.14/_pyrepl/readline.py", line 389, in multiline_input
    return reader.readline()
           ~~~~~~~~~~~~~~~^^
  File "/usr/local/lib/python3.14/_pyrepl/reader.py", line 750, in readline
    self.handle1()
    ~~~~~~~~~~~~^^
  File "/usr/local/lib/python3.14/_pyrepl/reader.py", line 706, in handle1
    event = self.console.get_event(block=False)
  File "/usr/local/lib/python3.14/_pyrepl/unix_console.py", line 406, in get_event
    self.push_char(self.__read(1))
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.14/_pyrepl/unix_console.py", line 388, in push_char
    self.event_queue.push(char)
    ~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/usr/local/lib/python3.14/_pyrepl/base_eventqueue.py", line 76, in push
    ord_char = char if isinstance(char, int) else ord(char)
                                                  ~~~^^^^^^
TypeError: ord() expected a character, but string of length 0 found
$ python3.14
Python 3.14.0a6+ (heads/main:d260631be06, Mar 28 2025, 17:05:59) [GCC 14.2.1 20250110 (Red Hat 14.2.1-7)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print("hello")
hello
>>> 
[1]+  Stopped                 python3.14
$ fg
python3.14
1+1
>>> 1+1
2
>>> 
$ 

It exits cleanly if it is not the first input.

@tomasr8 tomasr8 added 3.13 bugs and security fixes 3.14 new features, bugs and security fixes topic-repl Related to the interactive shell labels Apr 2, 2025
@picnixz picnixz added the stdlib Python modules in the Lib dir label Apr 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.13 bugs and security fixes 3.14 new features, bugs and security fixes stdlib Python modules in the Lib dir topic-repl Related to the interactive shell type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

4 participants