mercurial/pycompat.py
changeset 44452 9d2b2df2c2ba
parent 43870 66af68d4c751
child 44651 00e0c5c06ed5
equal deleted inserted replaced
44449:ff72bd52d56a 44452:9d2b2df2c2ba
   332         """
   332         """
   333         Converts the keys of a python dictonary to str i.e. unicodes so that
   333         Converts the keys of a python dictonary to str i.e. unicodes so that
   334         they can be passed as keyword arguments as dictonaries with bytes keys
   334         they can be passed as keyword arguments as dictonaries with bytes keys
   335         can't be passed as keyword arguments to functions on Python 3.
   335         can't be passed as keyword arguments to functions on Python 3.
   336         """
   336         """
   337         dic = dict((k.decode('latin-1'), v) for k, v in dic.items())
   337         dic = {k.decode('latin-1'): v for k, v in dic.items()}
   338         return dic
   338         return dic
   339 
   339 
   340     def byteskwargs(dic):
   340     def byteskwargs(dic):
   341         """
   341         """
   342         Converts keys of python dictonaries to bytes as they were converted to
   342         Converts keys of python dictonaries to bytes as they were converted to
   343         str to pass that dictonary as a keyword argument on Python 3.
   343         str to pass that dictonary as a keyword argument on Python 3.
   344         """
   344         """
   345         dic = dict((k.encode('latin-1'), v) for k, v in dic.items())
   345         dic = {k.encode('latin-1'): v for k, v in dic.items()}
   346         return dic
   346         return dic
   347 
   347 
   348     # TODO: handle shlex.shlex().
   348     # TODO: handle shlex.shlex().
   349     def shlexsplit(s, comments=False, posix=True):
   349     def shlexsplit(s, comments=False, posix=True):
   350         """
   350         """