Patchwork [1,of,2,STABLE] ui: fix echo back of ui.prompt() to not concatenate None as bytes

login
register
mail settings
Submitter Yuya Nishihara
Date Oct. 23, 2020, 12:17 p.m.
Message ID <15e5d72561363a7e83ea.1603455432@mimosa>
Download mbox | patch
Permalink /patch/47513/
State New
Headers show

Comments

Yuya Nishihara - Oct. 23, 2020, 12:17 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1603451417 -32400
#      Fri Oct 23 20:10:17 2020 +0900
# Branch stable
# Node ID 15e5d72561363a7e83ea9a7c70d85db760bc57e8
# Parent  b713e4cae2d76e5930925c32d3ae2ae1b5a2601d
ui: fix echo back of ui.prompt() to not concatenate None as bytes

Spotted while writing tests for the issue6425. The default value may be
None.

Patch

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -1659,7 +1659,9 @@  class ui(object):
             if not r:
                 r = default
             if self.configbool(b'ui', b'promptecho'):
-                self._writemsg(self._fmsgout, r, b"\n", type=b'promptecho')
+                self._writemsg(
+                    self._fmsgout, r or b'', b"\n", type=b'promptecho'
+                )
             return r
         except EOFError:
             raise error.ResponseExpected()