Patchwork [STABLE] ui: remove excessive strtolocal() from debuguigetpass

login
register
mail settings
Submitter Yuya Nishihara
Date Dec. 3, 2020, 10:06 a.m.
Message ID <074a20823c4be85d4b98.1606989967@lemosa>
Download mbox | patch
Permalink /patch/47796/
State Accepted
Headers show

Comments

Yuya Nishihara - Dec. 3, 2020, 10:06 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1606988543 -32400
#      Thu Dec 03 18:42:23 2020 +0900
# Branch stable
# Node ID 074a20823c4be85d4b98a76c2ba961ff640cc80e
# Parent  27c23c8f14da48a24a0896b588721c0139e92560
ui: remove excessive strtolocal() from debuguigetpass

ui.getpass() returns Optional[bytes], and strtolocal(bytes) would crash.
Follows up 07b0a687c01a "ui: ensure `getpass()` returns bytes."
Augie Fackler - Dec. 4, 2020, 10:26 p.m.
queued for stable, thanks

> On Dec 3, 2020, at 05:06, Yuya Nishihara <yuya@tcha.org> wrote:
> 
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1606988543 -32400
> #      Thu Dec 03 18:42:23 2020 +0900
> # Branch stable
> # Node ID 074a20823c4be85d4b98a76c2ba961ff640cc80e
> # Parent  27c23c8f14da48a24a0896b588721c0139e92560
> ui: remove excessive strtolocal() from debuguigetpass
> 
> ui.getpass() returns Optional[bytes], and strtolocal(bytes) would crash.
> Follows up 07b0a687c01a "ui: ensure `getpass()` returns bytes."
> 
> diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
> --- a/mercurial/debugcommands.py
> +++ b/mercurial/debugcommands.py
> @@ -3787,9 +3787,7 @@ def debugtemplate(ui, repo, tmpl, **opts
> def debuguigetpass(ui, prompt=b''):
>     """show prompt to type password"""
>     r = ui.getpass(prompt)
> -    if r is not None:
> -        r = encoding.strtolocal(r)
> -    else:
> +    if r is None:
>         r = b"<default response>"
>     ui.writenoi18n(b'response: %s\n' % r)
> 
> 
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -3787,9 +3787,7 @@  def debugtemplate(ui, repo, tmpl, **opts
 def debuguigetpass(ui, prompt=b''):
     """show prompt to type password"""
     r = ui.getpass(prompt)
-    if r is not None:
-        r = encoding.strtolocal(r)
-    else:
+    if r is None:
         r = b"<default response>"
     ui.writenoi18n(b'response: %s\n' % r)