[PATCH 2 of 8] py3: add os.fsdecode() as pycompat.fsdecode()
Pulkit Goyal
7895pulkit at gmail.com
Sat Nov 5 19:16:19 EDT 2016
# HG changeset patch
# User Pulkit Goyal <7895pulkit at gmail.com>
# Date 1478382160 -19800
# Sun Nov 06 03:12:40 2016 +0530
# Node ID 972b0c0175fc402ffe8beac276b737b32ce0df0b
# Parent 2d456de3a41ab961da8ae71dfefccdc9d7febe78
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
diff -r 2d456de3a41a -r 972b0c0175fc mercurial/pycompat.py
--- a/mercurial/pycompat.py Sun Nov 06 02:59:43 2016 +0530
+++ 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() have a very chances to recieve bytes. So it's
+ # better not to touch Python 2 part as its already working fine.
+ def fsdecode(filename):
+ return filename
+
stringio = io.StringIO
empty = _queue.Empty
queue = _queue.Queue
More information about the Mercurial-devel
mailing list