changeset 40154:fe11fc7e541f

py3: encode JSON str to bytes 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. Differential Revision: https://phab.mercurial-scm.org/D4965
author Gregory Szorc <gregory.szorc@gmail.com>
date Thu, 11 Oct 2018 21:18:58 +0200
parents 0ae20d2141ed
children 0199fb5dde20
files tests/get-with-headers.py
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/tests/get-with-headers.py	Thu Oct 11 21:05:03 2018 +0200
+++ b/tests/get-with-headers.py	Thu Oct 11 21:18:58 2018 +0200
@@ -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)