From 0e9cfd3ee8c36f5e15aa5069398f288fc9ff7b94 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Tue, 2 Jul 2019 10:56:12 -0500 Subject: [PATCH] Fix sanity tests that are failing with LC_ALL set (#58604) --- test/sanity/code-smell/boilerplate.py | 8 ++++---- test/sanity/compile/compile.py | 7 +++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/test/sanity/code-smell/boilerplate.py b/test/sanity/code-smell/boilerplate.py index 867e37b4d14..2acf830040f 100755 --- a/test/sanity/code-smell/boilerplate.py +++ b/test/sanity/code-smell/boilerplate.py @@ -41,7 +41,7 @@ def main(): if any(path.startswith(p) for p in prune): continue - with open(path, 'r') as path_fd: + with open(path, 'rb') as path_fd: future_ok = None metaclass_ok = None @@ -51,11 +51,11 @@ def main(): continue for line, text in enumerate(lines): - if text in ('from __future__ import (absolute_import, division, print_function)', - 'from __future__ import absolute_import, division, print_function'): + if text in (b'from __future__ import (absolute_import, division, print_function)', + b'from __future__ import absolute_import, division, print_function'): future_ok = line - if text == '__metaclass__ = type': + if text == b'__metaclass__ = type': metaclass_ok = line if future_ok and metaclass_ok: diff --git a/test/sanity/compile/compile.py b/test/sanity/compile/compile.py index 0641c693988..87d2ee9ddab 100755 --- a/test/sanity/compile/compile.py +++ b/test/sanity/compile/compile.py @@ -9,8 +9,11 @@ def main(): status = 0 for path in sys.argv[1:] or sys.stdin.read().splitlines(): - with open(path, 'r') as source_fd: - source = source_fd.read() + with open(path, 'rb') as source_fd: + if sys.version_info[0] == 3: + source = source_fd.read().decode('utf-8') + else: + source = source_fd.read() try: parser.suite(source)