policy: mark all string literals as sysstr or bytes
authorYuya Nishihara <yuya@tcha.org>
Tue, 02 May 2017 18:35:09 +0900
changeset 32210 56148133ef36
parent 32209 85dc5a25f1fc
child 32211 c48583859e04
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.
mercurial/policy.py
--- a/mercurial/policy.py	Wed Apr 26 23:30:52 2017 +0900
+++ b/mercurial/policy.py	Tue May 02 18:35:09 2017 +0900
@@ -33,8 +33,8 @@
 #
 # 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 @@
 
 # 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)