Comments
Patch
@@ -206,7 +206,7 @@
) and not hasattr( # hasattr-py3-only
s, u'__bytes__'
):
- s = str(s).encode(u'ascii')
+ s = str(s).encode('ascii')
return bytes.__new__(cls, s)
def __getitem__(self, key):
@@ -237,7 +237,7 @@
This never raises UnicodeEncodeError, but only ASCII characters
can be round-trip by sysstr(sysbytes(s)).
"""
- return s.encode(u'utf-8')
+ return s.encode('utf-8')
def sysstr(s):
"""Return a keyword str to be passed to Python functions such as
@@ -249,18 +249,18 @@
"""
if isinstance(s, builtins.str):
return s
- return s.decode(u'latin-1')
+ return s.decode('latin-1')
def strurl(url):
"""Converts a bytes url back to str"""
if isinstance(url, bytes):
- return url.decode(u'ascii')
+ return url.decode('ascii')
return url
def bytesurl(url):
"""Converts a str url to bytes by encoding in ascii"""
if isinstance(url, str):
- return url.encode(u'ascii')
+ return url.encode('ascii')
return url
def raisewithtb(exc, tb):
@@ -166,14 +166,6 @@
if arg1idx is not None:
_ensureunicode(arg1idx)
- # .encode() and .decode() on str/bytes/unicode don't accept
- # byte strings on Python 3.
- elif fn in ('encode', 'decode') and _isop(i - 1, '.'):
- for argn in range(2):
- argidx = _findargnofcall(argn)
- if argidx is not None:
- _ensureunicode(argidx)
-
# It changes iteritems/values to items/values as they are not
# present in Python 3 world.
elif fn in ('iteritems', 'itervalues') and not (
@@ -190,7 +182,7 @@
# ``replacetoken`` or any mechanism that changes semantics of module
# loading is changed. Otherwise cached bytecode may get loaded without
# the new transformation mechanisms applied.
- BYTECODEHEADER = b'HG\x00\x12'
+ BYTECODEHEADER = b'HG\x00\x13'
class hgloader(importlib.machinery.SourceFileLoader):
"""Custom module loader that transforms source code.
@@ -394,7 +394,7 @@
def encodestr(x):
if isinstance(x, pycompat.unicode):
- return x.encode(u'utf-8')
+ return x.encode('utf-8')
return x
return pycompat.rapply(encodestr, response)
@@ -49,7 +49,7 @@
def sysstr(s):
if isinstance(s, builtins.str):
return s
- return s.decode(u'latin-1')
+ return s.decode('latin-1')
def opentext(f):
return open(f, 'r')