D4965: py3: encode JSON str to bytes
indygreg (Gregory Szorc)
phabricator at mercurial-scm.org
Fri Oct 12 08:09:06 UTC 2018
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
json.dumps() will emit UTF-8 str on Python 2 and 3. Use sysbytes to
force the .encode('utf-8') on Python 3 and no-op on Python 2.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D4965
AFFECTED FILES
tests/get-with-headers.py
CHANGE DETAILS
diff --git a/tests/get-with-headers.py b/tests/get-with-headers.py
--- a/tests/get-with-headers.py
+++ b/tests/get-with-headers.py
@@ -11,6 +11,7 @@
import sys
from mercurial import (
+ pycompat,
util,
)
@@ -90,7 +91,7 @@
data = json.loads(data)
lines = json.dumps(data, sort_keys=True, indent=2).splitlines()
for line in lines:
- bodyfh.write(line.rstrip())
+ bodyfh.write(pycompat.sysbytes(line.rstrip()))
bodyfh.write(b'\n')
else:
bodyfh.write(data)
To: indygreg, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list