Patchwork D6105: py3: convert indexes into bytes when enumerating lists in urlencodenested

login
register
mail settings
Submitter phabricator
Date March 9, 2019, 3:01 a.m.
Message ID <differential-rev-PHID-DREV-ccohngyqie66cipeg3ln-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/39159/
State Superseded
Headers show

Comments

phabricator - March 9, 2019, 3:01 a.m.
Kwan created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Otherwise it'll try to insert them them into a %s slot in a b'' later and fail.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/phabricator.py

CHANGE DETAILS




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

Patch

diff --git a/hgext/phabricator.py b/hgext/phabricator.py
--- a/hgext/phabricator.py
+++ b/hgext/phabricator.py
@@ -160,7 +160,8 @@ 
     def process(prefix, obj):
         if isinstance(obj, bool):
             obj = {True: b'true', False: b'false'}[obj]  # Python -> PHP form
-        items = {list: enumerate, dict: lambda x: x.items()}.get(type(obj))
+        lister = lambda l: [(b'%d' % k, v) for k, v in enumerate(l)]
+        items = {list: lister, dict: lambda x: x.items()}.get(type(obj))
         if items is None:
             flatparams[prefix] = obj
         else: