Skip to content

Crash on Ctrl-Z #948

Closed
Closed

Description

@BenWiederhake

Hi! Thanks for bpython, I love it's versatility and ability to make sensible suggestions and show documentation on-the-fly.

One of my use-cases is using it alternatingly with the shell (e.g. bash), and switching with Ctrl-Z (SIGSTOP) and fg (shell-builtin to foreground bpython again).

This use-case became broken at some point.

Steps to reproduce:

  • Open a Terminal, e.g. xfce4-terminal 0.8.10 (shouldn't matter though), with some shell, e.g. bash 5.1.12(1)-release (shouldn't matter though)
  • Start bpython (I'm using 0.22.1 with Python 3.9.9, according to bpython)
  • Press Ctrl-Z (for some reason, SIGSTOP works as intended, and does not cause a crash.)

Expected behavior:

bash$ bpython
bpython Version 0.22.1 mit Python 3.9.9 /usr/bin/python3
>>> 
[2]+  Angehalten              bpython
[$? = 147]

bash$ jobs
[1]+  Angehalten              bpython

bash$

Actual behavior:

bash$ bpython
bpython Version 0.22.1 mit Python 3.9.9 /usr/bin/python3
>>> ^Z
Traceback (most recent call last):
  File "/usr/bin/bpython", line 33, in <module>
    sys.exit(load_entry_point('bpython==0.22.1', 'console_scripts', 'bpython')())
  File "/usr/lib/python3/dist-packages/bpython/curtsies.py", line 248, in main
    repl.mainloop(True, paste)
  File "/usr/lib/python3/dist-packages/bpython/curtsies.py", line 180, in mainloop
    for e in inputs:
  File "/usr/lib/python3/dist-packages/bpython/curtsies.py", line 261, in _combined_events
    e = event_provider.send(timeout)
  File "/usr/lib/python3/dist-packages/curtsies/input.py", line 212, in send
    return self._send(timeout)
  File "/usr/lib/python3/dist-packages/curtsies/input.py", line 264, in _send
    stdin_ready_for_read, event = self._wait_for_read_ready_or_timeout(
  File "/usr/lib/python3/dist-packages/curtsies/input.py", line 170, in _wait_for_read_ready_or_timeout
    (rs, _, _) = select.select(
  File "/usr/lib/python3/dist-packages/bpython/curtsiesfrontend/repl.py", line 613, in sigtstp_handler
    self.__exit__()
TypeError: __exit__() missing 3 required positional arguments: 'exc_type', 'exc_val', and 'exc_tb'
[$? = 1]

bash$ jobs

bash$

("Angehalten" is German for "Stopped".)

Activity

  1. BenWiederhake commented on Jan 8, 2022

    @BenWiederhake
    Author

    Holy crap that was fast. Thank you!

  2. added this to the release-0.23 milestone on Jan 9, 2022
  3. joshnatis commented on Oct 5, 2022

    @joshnatis

    Hi, I can reproduce this again :-(

    $ bpython
    bpython version 0.23 on top of Python 3.8.10 /usr/bin/python3
    >>>
    CTRL-Z
    [4]+  Stopped                 bpython
    
    $ fg
    Traceback (most recent call last):
      File "/home/josh/.local/bin/bpython", line 8, in <module>
        sys.exit(main())
      File "/home/josh/.local/lib/python3.8/site-packages/bpython/curtsies.py", line 248, in main
        repl.mainloop(True, paste)
      File "/home/josh/.local/lib/python3.8/site-packages/bpython/curtsies.py", line 180, in mainloop
        for e in inputs:
      File "/home/josh/.local/lib/python3.8/site-packages/bpython/curtsies.py", line 261, in _combined_events
        e = event_provider.send(timeout)
      File "/home/josh/.local/lib/python3.8/site-packages/curtsies/input.py", line 238, in send
        return self._send(timeout)
      File "/home/josh/.local/lib/python3.8/site-packages/curtsies/input.py", line 290, in _send
        stdin_ready_for_read, event = self._wait_for_read_ready_or_timeout(
      File "/home/josh/.local/lib/python3.8/site-packages/curtsies/input.py", line 198, in _wait_for_read_ready_or_timeout
        (rs, _, _) = select.select(
      File "/home/josh/.local/lib/python3.8/site-packages/bpython/curtsiesfrontend/repl.py", line 662, in sigtstp_handler
        self.after_suspend()
      File "/home/josh/.local/lib/python3.8/site-packages/bpython/curtsies.py", line 132, in after_suspend
        self.window.__enter__()
      File "/home/josh/.local/lib/python3.8/site-packages/curtsies/window.py", line 287, in __enter__
        self.cbreak.__enter__()
      File "/usr/lib/python3.8/contextlib.py", line 111, in __enter__
        del self.args, self.kwds, self.func
    AttributeError: args
  4. sebastinas commented on Oct 5, 2022

    @sebastinas
    Contributor

    This is a different issue. Please open a new bug.

  5. joshnatis commented on Oct 5, 2022

    @joshnatis

    Alright sure thing, thanks @sebastinas

  6. added a commit that references this issue on Feb 25, 2026
    60baf5e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions