Fix sanity tests that are failing with LC_ALL set (#58604)

pull/58683/head
Matt Martz 5 years ago committed by GitHub
parent a9fcd1d197
commit 0e9cfd3ee8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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:

@ -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)

Loading…
Cancel
Save