This is an archive of the discontinued Mercurial Phabricator instance.

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

Authored by pulkit on May 20 2018, 9:39 AM.

Details

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()

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

pulkit created this revision.May 20 2018, 9:39 AM
indygreg accepted this revision.May 21 2018, 2:30 PM
This revision is now accepted and ready to land.May 21 2018, 2:30 PM
This revision was automatically updated to reflect the committed changes.
yuja added a subscriber: yuja.May 22 2018, 7:23 AM
  • 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'

Should be handled by b'%r' % o.

yuja added a comment.May 22 2018, 7:41 AM
  • 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'

Should be handled by b'%r' % o.

Dropped this patch from hg-committed before sinking deep.