changeset 30300:42af0590f4b9

py3: add os.fsdecode() as pycompat.fsdecode() We need to use os.fsdecode() but this was not present in Python 2. So added the function in pycompat.py
author Pulkit Goyal <7895pulkit@gmail.com>
date Sun, 06 Nov 2016 03:12:40 +0530
parents 1e5346313963
children 8321b083a83d
files mercurial/pycompat.py
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/pycompat.py	Fri Nov 04 20:22:37 2016 -0700
+++ b/mercurial/pycompat.py	Sun Nov 06 03:12:40 2016 +0530
@@ -36,6 +36,7 @@
     import functools
     import os
     fsencode = os.fsencode
+    fsdecode = os.fsdecode
 
     def sysstr(s):
         """Return a keyword str to be passed to Python functions such as
@@ -76,6 +77,11 @@
             raise TypeError(
                 "expect str, not %s" % type(filename).__name__)
 
+    # 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
+
 stringio = io.StringIO
 empty = _queue.Empty
 queue = _queue.Queue