changeset 32537:044f3d7eb9ae

encoding: make sure "wide" variable never be referenced from other modules Better to not expose (maybe-) unicode objects.
author Yuya Nishihara <yuya@tcha.org>
date Mon, 29 May 2017 21:57:51 +0900
parents aa333c1982ab
children 2dd8d4108249
files mercurial/encoding.py
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/encoding.py	Sun May 28 21:29:58 2017 -0400
+++ b/mercurial/encoding.py	Mon May 29 21:57:51 2017 +0900
@@ -194,8 +194,8 @@
                    for k, v in os.environ.items())  # re-exports
 
 # How to treat ambiguous-width characters. Set to 'wide' to treat as wide.
-wide = _sysstr(environ.get("HGENCODINGAMBIGUOUS", "narrow") == "wide"
-               and "WFA" or "WF")
+_wide = _sysstr(environ.get("HGENCODINGAMBIGUOUS", "narrow") == "wide"
+                and "WFA" or "WF")
 
 def colwidth(s):
     "Find the column width of a string for display in the local encoding"
@@ -205,7 +205,7 @@
     "Find the column width of a Unicode string for display"
     eaw = getattr(unicodedata, 'east_asian_width', None)
     if eaw is not None:
-        return sum([eaw(c) in wide and 2 or 1 for c in d])
+        return sum([eaw(c) in _wide and 2 or 1 for c in d])
     return len(d)
 
 def getcols(s, start, c):