This is an automated email from the ASF dual-hosted git repository. bbannier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mesos.git
commit 2af339668fd90212999bae06a050a05824f2971e Author: Benjamin Bannier <[email protected]> AuthorDate: Wed Sep 18 11:37:18 2019 +0200 Revert "Updated cpplint to be compatible with Python 3." This reverts commit 89db66e3df831eaa50fffb4149a3894097505c14. This patch was necessary when we were running cpplint in the python3 environment used e.g., also for bindings and other scripts. With pre-commit we have freedom to choose the Python environment needed so we can undo our adjustments here to stay closer to upstream. Review: https://reviews.apache.org/r/71208/ --- support/cpplint.py | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/support/cpplint.py b/support/cpplint.py index 5671873..4f551dd 100755 --- a/support/cpplint.py +++ b/support/cpplint.py @@ -62,24 +62,6 @@ try: xrange # Python 2 except NameError: xrange = range # Python 3 - unicode = str - def iteritems(d): - return d.items() - def itervalues(d): - return d.values() -else: - # Python 2 - def iteritems(d): - return d.iteritems() - def itervalues(d): - return d.itervalues() - # Change stderr to write with replacement characters so we don't die - # if we try to print something containing non-ASCII characters. - sys.stderr = codecs.StreamReaderWriter(sys.stderr, - codecs.getreader('utf8'), - codecs.getwriter('utf8'), - 'replace') - _USAGE = """ @@ -975,7 +957,7 @@ class _CppLintState(object): def PrintErrorCounts(self): """Print a summary of errors by category, and the total.""" - for category, count in iteritems(self.errors_by_category): + for category, count in self.errors_by_category.iteritems(): sys.stderr.write('Category \'%s\' errors found: %d\n' % (category, count)) sys.stdout.write('Total errors found: %d\n' % self.error_count) @@ -4640,7 +4622,7 @@ def _GetTextInside(text, start_pattern): # Give opening punctuations to get the matching close-punctuations. matching_punctuation = {'(': ')', '{': '}', '[': ']'} - closing_punctuation = set(itervalues(matching_punctuation)) + closing_punctuation = set(matching_punctuation.itervalues()) # Find the position to start extracting text. match = re.search(start_pattern, text, re.M) @@ -5588,7 +5570,7 @@ def CheckForIncludeWhatYouUse(filename, clean_lines, include_state, error, # include_dict is modified during iteration, so we iterate over a copy of # the keys. - header_keys = list(include_dict) + header_keys = include_dict.keys() for header in header_keys: (same_module, common_path) = FilesBelongToSameModule(abs_filename, header) fullpath = common_path + header @@ -6241,6 +6223,13 @@ def ParseArguments(args): def main(): filenames = ParseArguments(sys.argv[1:]) + # Change stderr to write with replacement characters so we don't die + # if we try to print something containing non-ASCII characters. + sys.stderr = codecs.StreamReaderWriter(sys.stderr, + codecs.getreader('utf8'), + codecs.getwriter('utf8'), + 'replace') + _cpplint_state.ResetErrorCounts() for filename in filenames: ProcessFile(filename, _cpplint_state.verbose_level)
