yawpitch/spacedinvaders

Spaceinvaders asks me to press Ctrl+C, but doesn't catch KeyboardInterupt

Closed this issue · 2 comments

Not really a bug per se, but it looks ugly.

Steps to reproduce:

  1. Run game in terminal that's too small
  2. Observe instruction to either resize terminal or press "Ctrl + C"
  3. Press "Ctrl + C"

Expected results:

Game exits gracefully

Actual results

$ spacedinvaders
Traceback (most recent call last):
  File "/home/moggers/workspace/spacedinvaders/spacedinvaders/__init__.py", line 471, in resize_arena
    stdscr.mvwin(y_pad, x_pad)
_curses.error: mvwin() returned ERR

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/moggers/workspace/spacedinvaders/env/bin/spacedinvaders", line 33, in <module>
    sys.exit(load_entry_point('spacedinvaders', 'console_scripts', 'spacedinvaders')())
  File "/home/moggers/workspace/spacedinvaders/spacedinvaders/__init__.py", line 1483, in main
    curses.wrapper(partial(mainloop, use_sound=opts.use_sound))
  File "/usr/lib64/python3.9/curses/__init__.py", line 94, in wrapper
    return func(stdscr, *args, **kwds)
  File "/home/moggers/workspace/spacedinvaders/spacedinvaders/__init__.py", line 1431, in mainloop
    resize_arena(stdscr)
  File "/home/moggers/workspace/spacedinvaders/spacedinvaders/__init__.py", line 489, in resize_arena
    while stdscr.getch() != curses.KEY_RESIZE:
KeyboardInterrupt

Ahh, good catch, will get that fixed in the next commit.

Fixed by 8576766 ... one minor change, installation with sound now requires pip install spacedinvaders[SOUNDS], as simpleaudio isn't all that simple to install properly, it turns out.