changeset 43425:be0f77fd274d stable

py3: fix handling of ctrl keys in crecord (issue6213) The "keypressed" value in handlekeypressed() is a key name obtained by curses's getkey(); this can be a multibyte string for special keys like CTRL keys. Calling curses.unctrl() with such a value fails on Python 3 with a TypeError as described in issue6213. (On Python 2, this does not crash, but I'm not sure the result is correct, though it does no matter here.) So instead of calling unctrl(), we compare "keypressed" with the expected "^L" obtained by curses.ascii.ctrl("L").
author Denis Laxalde <denis.laxalde@logilab.fr>
date Wed, 06 Nov 2019 16:54:34 +0100
parents 7cc913396f8c
children e513e87b0476 daade078f1f0
files mercurial/crecord.py
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/crecord.py	Wed Nov 06 16:53:01 2019 +0100
+++ b/mercurial/crecord.py	Wed Nov 06 16:54:34 2019 +0100
@@ -59,6 +59,7 @@
 
 try:
     import curses
+    import curses.ascii
 
     curses.error
 except ImportError:
@@ -1938,7 +1939,7 @@
             self.helpwindow()
             self.stdscr.clear()
             self.stdscr.refresh()
-        elif curses.unctrl(keypressed) in ["^L"]:
+        elif keypressed in [curses.ascii.ctrl("L")]:
             # scroll the current line to the top of the screen, and redraw
             # everything
             self.scrolllines(self.selecteditemstartline)