[Updated] D9375: ui: ensure `getpass()` returns bytes

mharbison72 (Matt Harbison) phabricator at mercurial-scm.org
Thu Nov 26 13:16:34 UTC 2020


Closed by commit rHG87e7dd8e7734: ui: ensure `getpass()` returns bytes (authored by mharbison72).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D9375?vs=23632&id=23698

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D9375/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D9375

AFFECTED FILES
  mercurial/debugcommands.py
  mercurial/mail.py
  mercurial/ui.py

CHANGE DETAILS

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -1741,7 +1741,7 @@
                         raise EOFError
                     return l.rstrip(b'\n')
                 else:
-                    return getpass.getpass('')
+                    return encoding.strtolocal(getpass.getpass(''))
         except EOFError:
             raise error.ResponseExpected()
 
diff --git a/mercurial/mail.py b/mercurial/mail.py
--- a/mercurial/mail.py
+++ b/mercurial/mail.py
@@ -157,6 +157,8 @@
             password = encoding.strfromlocal(password)
         else:
             password = ui.getpass()
+            if password is not None:
+                password = encoding.strfromlocal(password)
     if username and password:
         ui.note(_(b'(authenticating to mail server as %s)\n') % username)
         username = encoding.strfromlocal(username)
diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -3792,6 +3792,10 @@
 def debuguigetpass(ui, prompt=b''):
     """show prompt to type password"""
     r = ui.getpass(prompt)
+    if r is not None:
+        r = encoding.strtolocal(r)
+    else:
+        r = b"<default response>"
     ui.writenoi18n(b'response: %s\n' % r)
 
 



To: mharbison72, #hg-reviewers, pulkit
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20201126/d30a71d9/attachment-0002.html>


More information about the Mercurial-patches mailing list