Patchwork py3: change encoding.localstr to a subclass of bytes, not str

login
register
mail settings
Submitter Yuya Nishihara
Date Aug. 14, 2017, 7:53 a.m.
Message ID <3852cbe06ef50c23d5c6.1502697199@mimosa>
Download mbox | patch
Permalink /patch/22967/
State Accepted
Headers show

Comments

Yuya Nishihara - Aug. 14, 2017, 7:53 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1502693440 -32400
#      Mon Aug 14 15:50:40 2017 +0900
# Node ID 3852cbe06ef50c23d5c6d25b4ad9b40885e47201
# Parent  8af5c6fc8ce4c53b43900c6bfb565daa285b8af1
py3: change encoding.localstr to a subclass of bytes, not str
Augie Fackler - Aug. 15, 2017, 7:53 p.m.
On Mon, Aug 14, 2017 at 04:53:19PM +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1502693440 -32400
> #      Mon Aug 14 15:50:40 2017 +0900
> # Node ID 3852cbe06ef50c23d5c6d25b4ad9b40885e47201
> # Parent  8af5c6fc8ce4c53b43900c6bfb565daa285b8af1
> py3: change encoding.localstr to a subclass of bytes, not str

queued, thanks

Patch

diff --git a/mercurial/encoding.py b/mercurial/encoding.py
--- a/mercurial/encoding.py
+++ b/mercurial/encoding.py
@@ -78,11 +78,11 @@  except locale.Error:
 encodingmode = environ.get("HGENCODINGMODE", "strict")
 fallbackencoding = 'ISO-8859-1'
 
-class localstr(str):
+class localstr(bytes):
     '''This class allows strings that are unmodified to be
     round-tripped to the local encoding and back'''
     def __new__(cls, u, l):
-        s = str.__new__(cls, l)
+        s = bytes.__new__(cls, l)
         s._utf8 = u
         return s
     def __hash__(self):