mercurial/pycompat.py
changeset 31777 7d2cbe11ae48
parent 31579 55c6788c54e2
child 31778 8181f378b073
--- a/mercurial/pycompat.py	Sun Apr 02 02:29:51 2017 -0400
+++ b/mercurial/pycompat.py	Wed Mar 29 21:13:55 2017 +0900
@@ -30,6 +30,9 @@
     import socketserver
     import xmlrpc.client as xmlrpclib
 
+def identity(a):
+    return a
+
 if ispy3:
     import builtins
     import functools
@@ -206,9 +209,7 @@
     bytechr = chr
     bytestr = str
     iterbytestr = iter
-
-    def sysstr(s):
-        return s
+    sysstr = identity
 
     # Partial backport from os.py in Python 3, which only accepts bytes.
     # In Python 2, our paths should only ever be bytes, a unicode path
@@ -222,17 +223,13 @@
 
     # In Python 2, fsdecode() has a very chance to receive bytes. So it's
     # better not to touch Python 2 part as it's already working fine.
-    def fsdecode(filename):
-        return filename
+    fsdecode = identity
 
     def getoptb(args, shortlist, namelist):
         return getopt.getopt(args, shortlist, namelist)
 
-    def strkwargs(dic):
-        return dic
-
-    def byteskwargs(dic):
-        return dic
+    strkwargs = identity
+    byteskwargs = identity
 
     osname = os.name
     ospathsep = os.pathsep