Patchwork [2,of,3,py3] py3: don't pass bytes to array.array()

login
register
mail settings
Submitter Yuya Nishihara
Date Sept. 16, 2017, 2:32 p.m.
Message ID <320bcaa9820502e56d8b.1505572371@mimosa>
Download mbox | patch
Permalink /patch/23945/
State Accepted
Headers show

Comments

Yuya Nishihara - Sept. 16, 2017, 2:32 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1505569339 -32400
#      Sat Sep 16 22:42:19 2017 +0900
# Node ID 320bcaa9820502e56d8b54a5b470ecc8e1fda463
# Parent  9835dada78098e86e057cf20ee0ee5ec2efe3dab
py3: don't pass bytes to array.array()

Patch

diff --git a/mercurial/pure/charencode.py b/mercurial/pure/charencode.py
--- a/mercurial/pure/charencode.py
+++ b/mercurial/pure/charencode.py
@@ -74,6 +74,6 @@  def jsonescapeu8fallback(u8chars, parano
     else:
         jm = _jsonmap
     # non-BMP char is represented as UTF-16 surrogate pair
-    u16codes = array.array('H', u8chars.decode('utf-8').encode('utf-16'))
+    u16codes = array.array(r'H', u8chars.decode('utf-8').encode('utf-16'))
     u16codes.pop(0)  # drop BOM
     return ''.join(jm[x] if x < 128 else '\\u%04x' % x for x in u16codes)