[PATCH 3 of 4] check-code: ignore re-exports of os.environ in encoding.py
Yuya Nishihara
yuya at tcha.org
Tue May 2 21:50:23 EDT 2017
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1493627028 -32400
# Mon May 01 17:23:48 2017 +0900
# Node ID 0bce0c9c98ac1140fbee92912cb18aaee86a7c61
# Parent e7aa3875549ca93c1220b62a933050295f4d4509
check-code: ignore re-exports of os.environ in encoding.py
These are valid uses of os.environ.
diff --git a/contrib/check-code.py b/contrib/check-code.py
--- a/contrib/check-code.py
+++ b/contrib/check-code.py
@@ -474,7 +474,7 @@ allfilespats = [
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 --git a/mercurial/encoding.py b/mercurial/encoding.py
--- a/mercurial/encoding.py
+++ b/mercurial/encoding.py
@@ -51,14 +51,14 @@ def hfsignoreclean(s):
# 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 @@ if not _nativeenviron:
# 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 --git a/tests/test-check-code.t b/tests/test-check-code.t
--- a/tests/test-check-code.t
+++ b/tests/test-check-code.t
@@ -13,18 +13,6 @@ New errors are not allowed. Warnings are
> 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)
More information about the Mercurial-devel
mailing list