policy: try and always have a bytes for module policy
authorAugie Fackler <raf@durin42.com>
Wed, 08 Mar 2017 18:11:41 -0500
changeset 31308 62939e0148f1
parent 31307 f8d41edd0357
child 31309 8908f985570c
policy: try and always have a bytes for module policy debuginstall now runs cleanly in Python 3.
mercurial/policy.py
setup.py
tests/test-check-py3-commands.t
--- a/mercurial/policy.py	Wed Mar 08 18:11:19 2017 -0500
+++ b/mercurial/policy.py	Wed Mar 08 18:11:41 2017 -0500
@@ -39,7 +39,7 @@
 # Our C extensions aren't yet compatible with Python 3. So use pure Python
 # on Python 3 for now.
 if sys.version_info[0] >= 3:
-    policy = 'py'
+    policy = b'py'
 
 # Environment variable can always force settings.
 policy = os.environ.get('HGMODULEPOLICY', policy)
--- a/setup.py	Wed Mar 08 18:11:19 2017 -0500
+++ b/setup.py	Wed Mar 08 18:11:41 2017 -0500
@@ -370,7 +370,7 @@
             modulepolicy = 'c'
         with open("mercurial/__modulepolicy__.py", "w") as f:
             f.write('# this file is autogenerated by setup.py\n')
-            f.write('modulepolicy = "%s"\n' % modulepolicy)
+            f.write('modulepolicy = b"%s"\n' % modulepolicy)
 
         build_py.run(self)
 
--- a/tests/test-check-py3-commands.t	Wed Mar 08 18:11:19 2017 -0500
+++ b/tests/test-check-py3-commands.t	Wed Mar 08 18:11:41 2017 -0500
@@ -11,7 +11,7 @@
   version
   warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
   debuginstall
-  TypeError: Can't convert 'bytes' object to str implicitly
+  no problems detected
 
   $ cat > included-hgrc <<EOF
   > [extensions]