aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Light <allight@google.com>2019-11-21 13:32:14 -0800
committerandroid-build-merger <android-build-merger@google.com>2019-11-21 13:32:14 -0800
commit5a3fcff118a07214cec8906e5a3e77574a1dee49 (patch)
tree976970568bb3d1710b016c70e943d481d1ac096d
parentf4b59ee7bf2c627b4e4ceb85d25c34f212e6ae4a (diff)
parentc547d8f0b06e97aaae55eaac21d259bd475cadd5 (diff)
downloadgoogle-styleguide-5a3fcff118a07214cec8906e5a3e77574a1dee49.tar.gz
Android: Workaround prebuilt python issue am: aa8a88f3a9android-r-preview-4android-r-preview-3android-r-preview-2
am: c547d8f0b0 Change-Id: I9493a8a056c8fd765d9aafc6c2514d7ebcced1b2
-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: