comparison mercurial/encoding.py @ 32231:cf424dae5dc7

check-code: ignore re-exports of os.environ in encoding.py These are valid uses of os.environ.
author Yuya Nishihara <yuya@tcha.org>
date Mon, 01 May 2017 17:23:48 +0900
parents 6c0ae9683437
children 1a3a08b5d4d5
comparison
equal deleted inserted replaced
32230:41d79475d440 32231:cf424dae5dc7
49 49
50 # encoding.environ is provided read-only, which may not be used to modify 50 # encoding.environ is provided read-only, which may not be used to modify
51 # the process environment 51 # the process environment
52 _nativeenviron = (not pycompat.ispy3 or os.supports_bytes_environ) 52 _nativeenviron = (not pycompat.ispy3 or os.supports_bytes_environ)
53 if not pycompat.ispy3: 53 if not pycompat.ispy3:
54 environ = os.environ 54 environ = os.environ # re-exports
55 elif _nativeenviron: 55 elif _nativeenviron:
56 environ = os.environb 56 environ = os.environb # re-exports
57 else: 57 else:
58 # preferred encoding isn't known yet; use utf-8 to avoid unicode error 58 # preferred encoding isn't known yet; use utf-8 to avoid unicode error
59 # and recreate it once encoding is settled 59 # and recreate it once encoding is settled
60 environ = dict((k.encode(u'utf-8'), v.encode(u'utf-8')) 60 environ = dict((k.encode(u'utf-8'), v.encode(u'utf-8'))
61 for k, v in os.environ.items()) 61 for k, v in os.environ.items()) # re-exports
62 62
63 def _getpreferredencoding(): 63 def _getpreferredencoding():
64 ''' 64 '''
65 On darwin, getpreferredencoding ignores the locale environment and 65 On darwin, getpreferredencoding ignores the locale environment and
66 always returns mac-roman. http://bugs.python.org/issue6202 fixes this 66 always returns mac-roman. http://bugs.python.org/issue6202 fixes this
216 216
217 if not _nativeenviron: 217 if not _nativeenviron:
218 # now encoding and helper functions are available, recreate the environ 218 # now encoding and helper functions are available, recreate the environ
219 # dict to be exported to other modules 219 # dict to be exported to other modules
220 environ = dict((tolocal(k.encode(u'utf-8')), tolocal(v.encode(u'utf-8'))) 220 environ = dict((tolocal(k.encode(u'utf-8')), tolocal(v.encode(u'utf-8')))
221 for k, v in os.environ.items()) 221 for k, v in os.environ.items()) # re-exports
222 222
223 # How to treat ambiguous-width characters. Set to 'wide' to treat as wide. 223 # How to treat ambiguous-width characters. Set to 'wide' to treat as wide.
224 wide = (environ.get("HGENCODINGAMBIGUOUS", "narrow") == "wide" 224 wide = (environ.get("HGENCODINGAMBIGUOUS", "narrow") == "wide"
225 and "WFA" or "WF") 225 and "WFA" or "WF")
226 226