From 705e35e5fd849482c961c9897cd554f92968ac5d Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Sun, 22 Nov 2020 11:16:49 -0700 Subject: [PATCH] bpo-32068: curses.textpad isn't handling the backspace key on some systems On some systems, ascii.DEL (127) is sent on the backspace key event. --- Lib/curses/textpad.py | 5 +++-- .../next/Library/2020-11-22-11-15-55.bpo-32068.SkGl0R.rst | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2020-11-22-11-15-55.bpo-32068.SkGl0R.rst diff --git a/Lib/curses/textpad.py b/Lib/curses/textpad.py index 2079953a066..e4b7084def2 100644 --- a/Lib/curses/textpad.py +++ b/Lib/curses/textpad.py @@ -102,7 +102,8 @@ class Textbox: self._insert_printable_char(ch) elif ch == curses.ascii.SOH: # ^a self.win.move(y, 0) - elif ch in (curses.ascii.STX,curses.KEY_LEFT, curses.ascii.BS,curses.KEY_BACKSPACE): + elif ch in (curses.ascii.STX, curses.KEY_LEFT, curses.ascii.BS, + curses.KEY_BACKSPACE, curses.ascii.DEL): if x > 0: self.win.move(y, x-1) elif y == 0: @@ -111,7 +112,7 @@ class Textbox: self.win.move(y-1, self._end_of_line(y-1)) else: self.win.move(y-1, self.maxx) - if ch in (curses.ascii.BS, curses.KEY_BACKSPACE): + if ch in (curses.ascii.BS, curses.KEY_BACKSPACE, curses.ascii.DEL): self.win.delch() elif ch == curses.ascii.EOT: # ^d self.win.delch() diff --git a/Misc/NEWS.d/next/Library/2020-11-22-11-15-55.bpo-32068.SkGl0R.rst b/Misc/NEWS.d/next/Library/2020-11-22-11-15-55.bpo-32068.SkGl0R.rst new file mode 100644 index 00000000000..5191078ad2b --- /dev/null +++ b/Misc/NEWS.d/next/Library/2020-11-22-11-15-55.bpo-32068.SkGl0R.rst @@ -0,0 +1,2 @@ +The :mod:`curses.textpad` module can now handle systems that send +``ascii.DEL`` (``127``) on the backspace key event.