##// END OF EJS Templates
policy: mark all string literals as sysstr or bytes...
Yuya Nishihara -
r32205:56148133 default
parent child Browse files
Show More
@@ -1,49 +1,49 b''
1 # policy.py - module policy logic for Mercurial.
1 # policy.py - module policy logic for Mercurial.
2 #
2 #
3 # Copyright 2015 Gregory Szorc <gregory.szorc@gmail.com>
3 # Copyright 2015 Gregory Szorc <gregory.szorc@gmail.com>
4 #
4 #
5 # This software may be used and distributed according to the terms of the
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 from __future__ import absolute_import
8 from __future__ import absolute_import
9
9
10 import os
10 import os
11 import sys
11 import sys
12
12
13 # Rules for how modules can be loaded. Values are:
13 # Rules for how modules can be loaded. Values are:
14 #
14 #
15 # c - require C extensions
15 # c - require C extensions
16 # allow - allow pure Python implementation when C loading fails
16 # allow - allow pure Python implementation when C loading fails
17 # cffi - required cffi versions (implemented within pure module)
17 # cffi - required cffi versions (implemented within pure module)
18 # cffi-allow - allow pure Python implementation if cffi version is missing
18 # cffi-allow - allow pure Python implementation if cffi version is missing
19 # py - only load pure Python modules
19 # py - only load pure Python modules
20 #
20 #
21 # By default, require the C extensions for performance reasons.
21 # By default, require the C extensions for performance reasons.
22 policy = b'c'
22 policy = b'c'
23 policynoc = (b'cffi', b'cffi-allow', b'py')
23 policynoc = (b'cffi', b'cffi-allow', b'py')
24 policynocffi = (b'c', b'py')
24 policynocffi = (b'c', b'py')
25
25
26 try:
26 try:
27 from . import __modulepolicy__
27 from . import __modulepolicy__
28 policy = __modulepolicy__.modulepolicy
28 policy = __modulepolicy__.modulepolicy
29 except ImportError:
29 except ImportError:
30 pass
30 pass
31
31
32 # PyPy doesn't load C extensions.
32 # PyPy doesn't load C extensions.
33 #
33 #
34 # The canonical way to do this is to test platform.python_implementation().
34 # The canonical way to do this is to test platform.python_implementation().
35 # But we don't import platform and don't bloat for it here.
35 # But we don't import platform and don't bloat for it here.
36 if '__pypy__' in sys.builtin_module_names:
36 if r'__pypy__' in sys.builtin_module_names:
37 policy = 'cffi'
37 policy = b'cffi'
38
38
39 # Our C extensions aren't yet compatible with Python 3. So use pure Python
39 # Our C extensions aren't yet compatible with Python 3. So use pure Python
40 # on Python 3 for now.
40 # on Python 3 for now.
41 if sys.version_info[0] >= 3:
41 if sys.version_info[0] >= 3:
42 policy = b'py'
42 policy = b'py'
43
43
44 # Environment variable can always force settings.
44 # Environment variable can always force settings.
45 if sys.version_info[0] >= 3:
45 if sys.version_info[0] >= 3:
46 if 'HGMODULEPOLICY' in os.environ:
46 if r'HGMODULEPOLICY' in os.environ:
47 policy = os.environ['HGMODULEPOLICY'].encode('utf-8')
47 policy = os.environ[r'HGMODULEPOLICY'].encode(r'utf-8')
48 else:
48 else:
49 policy = os.environ.get('HGMODULEPOLICY', policy)
49 policy = os.environ.get(r'HGMODULEPOLICY', policy)
General Comments 0
You need to be logged in to leave comments. Login now