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
--- a/mercurial/util.py Wed Mar 15 23:21:30 2017 +0900
+++ b/mercurial/util.py Wed Mar 15 23:28:39 2017 +0900
@@ -17,6 +17,7 @@
import bz2
import calendar
+import codecs
import collections
import datetime
import errno
@@ -2131,7 +2132,9 @@
)
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()