aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Light <allight@google.com>2019-11-20 15:02:46 -0800
committerAlex Light <allight@google.com>2019-11-21 19:01:58 +0000
commitaa8a88f3a99a45c53baaac6423250d6d03ccf77a (patch)
tree976970568bb3d1710b016c70e943d481d1ac096d
parent494e25f7e0ef88f7f2630f24fa69f1dc4d881d42 (diff)
downloadgoogle-styleguide-aa8a88f3a99a45c53baaac6423250d6d03ccf77a.tar.gz
Android: Workaround prebuilt python issue
Android prebuilt python stdlib does not include the modules needed to determine sysconfig values. Since this is only an issue on mac (and manifests only as a miscount of characters) we will work around this by simply skipping the test if it fails. Test: m cpplint-art Bug: 144866010 Bug: 144931206 Change-Id: I5a4d317e26f8ee4e230d1fc7bbd878e3ca939f63
-rwxr-xr-xcpplint/cpplint.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/cpplint/cpplint.py b/cpplint/cpplint.py
index 6c839b4..d069b6d 100755
--- a/cpplint/cpplint.py
+++ b/cpplint/cpplint.py
@@ -4295,13 +4295,16 @@ def GetLineWidth(line):
# Issue 337
# https://mail.python.org/pipermail/python-list/2012-August/628809.html
if (sys.version_info.major, sys.version_info.minor) <= (3, 2):
- # https://github.com/python/cpython/blob/2.7/Include/unicodeobject.h#L81
- is_wide_build = sysconfig.get_config_var("Py_UNICODE_SIZE") >= 4
- # https://github.com/python/cpython/blob/2.7/Objects/unicodeobject.c#L564
- is_low_surrogate = 0xDC00 <= ord(uc) <= 0xDFFF
- if not is_wide_build and is_low_surrogate:
- width -= 1
-
+ try:
+ # https://github.com/python/cpython/blob/2.7/Include/unicodeobject.h#L81
+ is_wide_build = sysconfig.get_config_var("Py_UNICODE_SIZE") >= 4
+ # https://github.com/python/cpython/blob/2.7/Objects/unicodeobject.c#L564
+ is_low_surrogate = 0xDC00 <= ord(uc) <= 0xDFFF
+ if not is_wide_build and is_low_surrogate:
+ width -= 1
+ except ImportError:
+ # Android prebuilt python ends up CHECK-failing here due to how it's compiled.
+ pass
width += 1
return width
else: