Patchwork [1,of,2] py3: convert os.__file__ to bytes

login
register
mail settings
Submitter Pulkit Goyal
Date Feb. 8, 2017, 5:53 p.m.
Message ID <61c589c75ebbce625d70.1486576425@pulkit-goyal>
Download mbox | patch
Permalink /patch/18353/
State Accepted
Headers show

Comments

Pulkit Goyal - Feb. 8, 2017, 5:53 p.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1486487844 -19800
#      Tue Feb 07 22:47:24 2017 +0530
# Node ID 61c589c75ebbce625d7056297e122863b68acce9
# Parent  a68510b69f413545722c086eaeb840dd5e8305b4
py3: convert os.__file__ to bytes

os.__file__ returns unicode path on Python 3. We need to have bytespath. This
patch uses pycompat.fsencode() to encode unicode path to bytes path.

Patch

diff -r a68510b69f41 -r 61c589c75ebb mercurial/commands.py
--- a/mercurial/commands.py	Mon Feb 06 17:01:06 2017 -0800
+++ b/mercurial/commands.py	Tue Feb 07 22:47:24 2017 +0530
@@ -1903,7 +1903,7 @@ 
     fm.write('pythonver', _("checking Python version (%s)\n"),
              ("%d.%d.%d" % sys.version_info[:3]))
     fm.write('pythonlib', _("checking Python lib (%s)...\n"),
-             os.path.dirname(os.__file__))
+             os.path.dirname(pycompat.fsencode(os.__file__)))
 
     security = set(sslutil.supportedprotocols)
     if sslutil.hassni: