mercurial/pycompat.py
changeset 35944 fc44c2657dc5
parent 35943 1a31111e6239
child 36083 04984f2e50ae
--- a/mercurial/pycompat.py	Sat Jan 27 17:31:25 2018 +0900
+++ b/mercurial/pycompat.py	Sat Jan 27 17:46:37 2018 +0900
@@ -161,6 +161,12 @@
         """Iterate bytes as if it were a str object of Python 2"""
         return map(bytechr, s)
 
+    def maybebytestr(s):
+        """Promote bytes to bytestr"""
+        if isinstance(s, bytes):
+            return bytestr(s)
+        return s
+
     def sysbytes(s):
         """Convert an internal str (e.g. keyword, __doc__) back to bytes
 
@@ -267,6 +273,7 @@
     bytechr = chr
     bytestr = str
     iterbytestr = iter
+    maybebytestr = identity
     sysbytes = identity
     sysstr = identity
     strurl = identity