Patchwork D2259: py3: use pycompat.bytestr to convert int/bytes to bytes

login
register
mail settings
Submitter phabricator
Date Feb. 14, 2018, 11:25 a.m.
Message ID <differential-rev-PHID-DREV-jlwxlgkb3rkit7ufbhpv-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/27893/
State New
Headers show

Comments

phabricator - Feb. 14, 2018, 11:25 a.m.
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The item value can be integer or can be bytes, so cannot use "%d" here.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/worker.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-devel
phabricator - Feb. 14, 2018, 1:14 p.m.
yuja requested changes to this revision.
yuja added a comment.
This revision now requires changes to proceed.


  > The item value can be integer or can be bytes, so cannot use "%d" here.
  
  Sounds like a bug. IIUC, the item should be a byte string because it is
  passed to `ui.progress(item=)`. Can you take a look?

REPOSITORY
  rHG Mercurial

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

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

Patch

diff --git a/mercurial/worker.py b/mercurial/worker.py
--- a/mercurial/worker.py
+++ b/mercurial/worker.py
@@ -156,7 +156,7 @@ 
                 def workerfunc():
                     os.close(rfd)
                     for i, item in func(*(staticargs + (pargs,))):
-                        os.write(wfd, '%d %s\n' % (i, item))
+                        os.write(wfd, '%d %s\n' % (i, pycompat.bytestr(item)))
                     return 0
 
                 ret = scmutil.callcatch(ui, workerfunc)