[PATCH 3 of 3 STABLE] py3: fix handling of ctrl keys in crecord (issue6213)

Yuya Nishihara yuya at tcha.org
Thu Nov 7 18:28:40 EST 2019


On Wed, 06 Nov 2019 17:23:29 +0100, Denis Laxalde wrote:
> # HG changeset patch
> # User Denis Laxalde <denis.laxalde at logilab.fr>
> # Date 1573055674 -3600
> #      Wed Nov 06 16:54:34 2019 +0100
> # Branch stable
> # Node ID f4415c4f24f879845f5dc631d592440e88d2afee
> # Parent  5802765e3828e3b3f1396b92ed7ef18a1eca6456
> 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").
> 
> diff --git a/mercurial/crecord.py b/mercurial/crecord.py
> --- a/mercurial/crecord.py
> +++ b/mercurial/crecord.py
> @@ -59,6 +59,7 @@ patchhelptext = _(
>  
>  try:
>      import curses
> +    import curses.ascii
>  
>      curses.error
>  except ImportError:

Maybe need to import wcurses.ascii? I don't know if that works, though.


More information about the Mercurial-devel mailing list