# HG changeset patch # User Yuya Nishihara # Date 1493627028 -32400 # Node ID cf424dae5dc7e25f2a668405714942c4c854c965 # Parent 41d79475d440f5de510a9805338ec88c0fa8d339 check-code: ignore re-exports of os.environ in encoding.py These are valid uses of os.environ. diff -r 41d79475d440 -r cf424dae5dc7 contrib/check-code.py --- a/contrib/check-code.py Wed Apr 26 21:51:19 2017 +0900 +++ b/contrib/check-code.py Mon May 01 17:23:48 2017 +0900 @@ -474,7 +474,7 @@ py3pats = [ [ - (r'os\.environ', "use encoding.environ instead (py3)"), + (r'os\.environ', "use encoding.environ instead (py3)", r'#.*re-exports'), (r'os\.name', "use pycompat.osname instead (py3)"), (r'os\.getcwd', "use pycompat.getcwd instead (py3)"), (r'os\.sep', "use pycompat.ossep instead (py3)"), diff -r 41d79475d440 -r cf424dae5dc7 mercurial/encoding.py --- a/mercurial/encoding.py Wed Apr 26 21:51:19 2017 +0900 +++ b/mercurial/encoding.py Mon May 01 17:23:48 2017 +0900 @@ -51,14 +51,14 @@ # the process environment _nativeenviron = (not pycompat.ispy3 or os.supports_bytes_environ) if not pycompat.ispy3: - environ = os.environ + environ = os.environ # re-exports elif _nativeenviron: - environ = os.environb + environ = os.environb # re-exports else: # preferred encoding isn't known yet; use utf-8 to avoid unicode error # and recreate it once encoding is settled environ = dict((k.encode(u'utf-8'), v.encode(u'utf-8')) - for k, v in os.environ.items()) + for k, v in os.environ.items()) # re-exports def _getpreferredencoding(): ''' @@ -218,7 +218,7 @@ # now encoding and helper functions are available, recreate the environ # dict to be exported to other modules environ = dict((tolocal(k.encode(u'utf-8')), tolocal(v.encode(u'utf-8'))) - for k, v in os.environ.items()) + for k, v in os.environ.items()) # re-exports # How to treat ambiguous-width characters. Set to 'wide' to treat as wide. wide = (environ.get("HGENCODINGAMBIGUOUS", "narrow") == "wide" diff -r 41d79475d440 -r cf424dae5dc7 tests/test-check-code.t --- a/tests/test-check-code.t Wed Apr 26 21:51:19 2017 +0900 +++ b/tests/test-check-code.t Mon May 01 17:23:48 2017 +0900 @@ -13,18 +13,6 @@ > r.revision(r.node(x)) don't convert rev to node before passing to revision(nodeorrev) Skipping i18n/polib.py it has no-che?k-code (glob) - mercurial/encoding.py:54: - > environ = os.environ - use encoding.environ instead (py3) - mercurial/encoding.py:56: - > environ = os.environb - use encoding.environ instead (py3) - mercurial/encoding.py:61: - > for k, v in os.environ.items()) - use encoding.environ instead (py3) - mercurial/encoding.py:221: - > for k, v in os.environ.items()) - use encoding.environ instead (py3) Skipping mercurial/httpclient/__init__.py it has no-che?k-code (glob) Skipping mercurial/httpclient/_readers.py it has no-che?k-code (glob) Skipping mercurial/statprof.py it has no-che?k-code (glob)