[PATCH] py3: change encoding.localstr to a subclass of bytes, not str

Yuya Nishihara yuya at tcha.org
Mon Aug 14 07:53:19 UTC 2017


# HG changeset patch
# User Yuya Nishihara <yuya at 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

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):


More information about the Mercurial-devel mailing list