diff options
author | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2019-04-16 14:33:43 -0400 |
---|---|---|
committer | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2019-04-16 14:33:43 -0400 |
commit | 286c0312647aae2261885da3c350f2cf24ea717d (patch) | |
tree | d2c026d07af31d046f276dac29cc9f468a6fa4b9 /buildscripts/errorcodes.py | |
parent | f87a44a7433199caf1f8e7b7b16238ed87f3f60a (diff) | |
download | mongo-286c0312647aae2261885da3c350f2cf24ea717d.tar.gz |
SERVER-40559 Python linters do not run after upgrade to Python 3
Diffstat (limited to 'buildscripts/errorcodes.py')
-rwxr-xr-x | buildscripts/errorcodes.py | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/buildscripts/errorcodes.py b/buildscripts/errorcodes.py index 82324c04113..d56fadb009a 100755 --- a/buildscripts/errorcodes.py +++ b/buildscripts/errorcodes.py @@ -5,9 +5,6 @@ Parses .cpp files for assertions and verifies assertion codes are distinct. Optionally replaces zero codes in source code with new distinct values. """ - - - import bisect import os.path import sys @@ -45,21 +42,21 @@ list_files = False # pylint: disable=invalid-name def parse_source_files(callback): """Walk MongoDB sourcefiles and invoke a callback for each AssertLocation found.""" - quick = [b"assert", b"Exception", b"ErrorCodes::Error"] + quick = [r"assert", r"Exception", r"ErrorCodes::Error"] patterns = [ - re.compile(b"(?:u|m(?:sg)?)asser(?:t|ted)(?:NoTrace)?\s*\(\s*(\d+)", re.MULTILINE), - re.compile(b"(?:DB|Assertion)Exception\s*[({]\s*(\d+)", re.MULTILINE), - re.compile(b"fassert(?:Failed)?(?:WithStatus)?(?:NoTrace)?(?:StatusOK)?\s*\(\s*(\d+)", + re.compile(r"(?:u|m(?:sg)?)asser(?:t|ted)(?:NoTrace)?\s*\(\s*(\d+)", re.MULTILINE), + re.compile(r"(?:DB|Assertion)Exception\s*[({]\s*(\d+)", re.MULTILINE), + re.compile(r"fassert(?:Failed)?(?:WithStatus)?(?:NoTrace)?(?:StatusOK)?\s*\(\s*(\d+)", re.MULTILINE), - re.compile(b"ErrorCodes::Error\s*[({]\s*(\d+)", re.MULTILINE) + re.compile(r"ErrorCodes::Error\s*[({]\s*(\d+)", re.MULTILINE) ] for source_file in utils.get_all_source_files(prefix='src/mongo/'): if list_files: print('scanning file: ' + source_file) - with open(source_file, 'rb') as fh: + with open(source_file, 'r', encoding='utf-8') as fh: text = fh.read() if not any([zz in text for zz in quick]): |