Patchwork D1135: webutil: use pycompat.bytestr() instead of str()

login
register
mail settings
Submitter phabricator
Date Oct. 17, 2017, 2:56 a.m.
Message ID <differential-rev-PHID-DREV-o6oqbqdin54ohooxxm7c-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/25072/
State Superseded
Headers show

Comments

phabricator - Oct. 17, 2017, 2:56 a.m.
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Stops us from choking the templater on Python 3. With this patch
  applied, much of hgweb works correctly in Python 3. The notable
  exception is the graph page, which chokes because it gets node IDs as
  str instead of bytes.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/hgweb/webutil.py

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-devel
phabricator - Oct. 17, 2017, 12:20 p.m.
ryanmce added inline comments.

INLINE COMMENTS

> webutil.py:593-596
> +            yield {'name': key,
> +                   'value': pycompat.bytestr(value),
> +                   'separator': separator,
> +            }

Buhhhhh, this looks ugly as sin. Can we drop 'name' to the next line please? (I can do that in-flight, actually)

REPOSITORY
  rHG Mercurial

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

To: durin42, #hg-reviewers, pulkit
Cc: ryanmce, mercurial-devel
phabricator - Oct. 17, 2017, 12:39 p.m.
ryanmce accepted this revision.
ryanmce added a comment.
This revision is now accepted and ready to land.


  queued

REPOSITORY
  rHG Mercurial

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

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

Patch

diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py
--- a/mercurial/hgweb/webutil.py
+++ b/mercurial/hgweb/webutil.py
@@ -30,6 +30,7 @@ 
     mdiff,
     patch,
     pathutil,
+    pycompat,
     templatefilters,
     ui as uimod,
     util,
@@ -589,7 +590,10 @@ 
     def __iter__(self):
         separator = self.start
         for key, value in sorted(self.vars.iteritems()):
-            yield {'name': key, 'value': str(value), 'separator': separator}
+            yield {'name': key,
+                   'value': pycompat.bytestr(value),
+                   'separator': separator,
+            }
             separator = '&'
 
 class wsgiui(uimod.ui):