diff --git a/src/utils/str.py b/src/utils/str.py index eb5561231..ff48e4739 100644 --- a/src/utils/str.py +++ b/src/utils/str.py @@ -120,7 +120,8 @@ def dqrepr(s): """Returns a repr() of s guaranteed to be in double quotes.""" # The wankers-that-be decided not to use double-quotes anymore in 2.3. # return '"' + repr("'\x00" + s)[6:] - return '"%s"' % s.encode('string_escape').replace('"', '\\"') + encoding = 'string_escape' if sys.version_info[0] < 3 else 'unicode_escape' + return '"%s"' % s.encode(encoding).decode().replace('"', '\\"') def quoted(s): """Returns a quoted s."""