D3635: py3: add support for NoneType in stringutil.pprint()

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Sun May 20 09:39:35 EDT 2018


pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  There are some places in codebase where we try to print the value None, however
  `'%s' % None` is invalid on Python 3. So it will be good to have support in
  stringutil.pprint()

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/utils/stringutil.py

CHANGE DETAILS

diff --git a/mercurial/utils/stringutil.py b/mercurial/utils/stringutil.py
--- a/mercurial/utils/stringutil.py
+++ b/mercurial/utils/stringutil.py
@@ -29,6 +29,8 @@
         if bprefix:
             return "b'%s'" % escapestr(o)
         return "'%s'" % escapestr(o)
+    elif o is None:
+        return 'None'
     elif isinstance(o, bytearray):
         # codecs.escape_encode() can't handle bytearray, so escapestr fails
         # without coercion.



To: pulkit, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list