# HG changeset patch # User Yuya Nishihara # Date 2017-03-15 14:28:39 # Node ID 3b7a6941a6efcca57c6d13bc356adee99adb7ff1 # Parent 52dabcc4996828e940d5e7d76fb07a9b84e49d26 py3: call codecs.escape_encode() directly string_escape doesn't exist on Python 3, but fortunately the undocumented codecs.escape_encode() function exists on CPython 2.6, 2.7, 3.5 and PyPy 5.6. So let's use it for now. http://stackoverflow.com/a/23151714 diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -17,6 +17,7 @@ from __future__ import absolute_import import bz2 import calendar +import codecs import collections import datetime import errno @@ -2131,7 +2132,9 @@ bytecount = unitcountfn( ) def escapestr(s): - return s.encode('string_escape') + # call underlying function of s.encode('string_escape') directly for + # Python 3 compatibility + return codecs.escape_encode(s)[0] def uirepr(s): # Avoid double backslash in Windows path repr()