[PATCH 08 of 12] policy: mark all string literals as sysstr or bytes

Yuya Nishihara yuya at tcha.org
Sat May 6 21:45:49 EDT 2017


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1493717709 -32400
#      Tue May 02 18:35:09 2017 +0900
# Node ID eb86791ad01c90493405b7968ebaec79b88081a7
# Parent  e94661437708d6bb34403b6a4139e2c41157ab34
policy: mark all string literals as sysstr or bytes

The policy module won't be imported early in future, which means string
literals will be processed by our Python 3 loader.

diff --git a/mercurial/policy.py b/mercurial/policy.py
--- a/mercurial/policy.py
+++ b/mercurial/policy.py
@@ -33,8 +33,8 @@ except ImportError:
 #
 # The canonical way to do this is to test platform.python_implementation().
 # But we don't import platform and don't bloat for it here.
-if '__pypy__' in sys.builtin_module_names:
-    policy = 'cffi'
+if r'__pypy__' in sys.builtin_module_names:
+    policy = b'cffi'
 
 # Our C extensions aren't yet compatible with Python 3. So use pure Python
 # on Python 3 for now.
@@ -43,7 +43,7 @@ if sys.version_info[0] >= 3:
 
 # Environment variable can always force settings.
 if sys.version_info[0] >= 3:
-    if 'HGMODULEPOLICY' in os.environ:
-        policy = os.environ['HGMODULEPOLICY'].encode('utf-8')
+    if r'HGMODULEPOLICY' in os.environ:
+        policy = os.environ[r'HGMODULEPOLICY'].encode(r'utf-8')
 else:
-    policy = os.environ.get('HGMODULEPOLICY', policy)
+    policy = os.environ.get(r'HGMODULEPOLICY', policy)


More information about the Mercurial-devel mailing list