Skip to content

Error traceback when interrupting+terminating python #132017

Open
@smurfix

Description

@smurfix

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

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13bugs and security fixes3.14new features, bugs and security fixesstdlibPython modules in the Lib dirtopic-replRelated to the interactive shelltype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions