This is an automated email from the ASF dual-hosted git repository. joemcdonnell pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/impala.git
commit c1794023bc35062b041b76012bfd1b1f6078d036 Author: Joe McDonnell <[email protected]> AuthorDate: Sun Feb 26 14:05:05 2023 -0800 IMPALA-11952 (part 3): Fix raise syntax Python 3 does not support this old raise syntax: raise Exception, "message" Instead, it should be: raise Exception("message") This fixes all locations with the old raise syntax. Testing: - check-python-syntax.sh shows no errors from raise syntax Change-Id: I2722dcc2727fb65c7aedede12d73ca5b088326d7 Reviewed-on: http://gerrit.cloudera.org:8080/19553 Reviewed-by: Joe McDonnell <[email protected]> Reviewed-by: Michael Smith <[email protected]> Tested-by: Michael Smith <[email protected]> --- tests/beeswax/impala_beeswax.py | 2 +- tests/common/impala_test_suite.py | 2 +- tests/common/test_dimensions.py | 14 +++++++------- tests/common/test_result_verifier.py | 4 ++-- tests/common/test_vector.py | 2 +- tests/util/plugin_runner.py | 2 +- tests/util/test_file_parser.py | 16 ++++++++-------- 7 files changed, 21 insertions(+), 21 deletions(-) diff --git a/tests/beeswax/impala_beeswax.py b/tests/beeswax/impala_beeswax.py index 3edfb2584..201532dc9 100644 --- a/tests/beeswax/impala_beeswax.py +++ b/tests/beeswax/impala_beeswax.py @@ -136,7 +136,7 @@ class ImpalaBeeswaxClient(object): def set_query_options(self, query_option_dict): if query_option_dict is None: - raise ValueError, 'Cannot pass None value for query options' + raise ValueError('Cannot pass None value for query options') self.clear_query_options() for name, value in query_option_dict.iteritems(): self.set_query_option(name, value) diff --git a/tests/common/impala_test_suite.py b/tests/common/impala_test_suite.py index 033b0c4f4..0245b9330 100644 --- a/tests/common/impala_test_suite.py +++ b/tests/common/impala_test_suite.py @@ -1101,7 +1101,7 @@ class ImpalaTestSuite(BaseTestSuite): for workload_strategy in workload_strategies: workload_strategy = workload_strategy.split(':') if len(workload_strategy) != 2: - raise ValueError, 'Invalid workload:strategy format: %s' % workload_strategy + raise ValueError('Invalid workload:strategy format: %s' % workload_strategy) if cls.get_workload() == workload_strategy[0]: return workload_strategy[1] return default_strategy diff --git a/tests/common/test_dimensions.py b/tests/common/test_dimensions.py index 16a8c504c..869179402 100644 --- a/tests/common/test_dimensions.py +++ b/tests/common/test_dimensions.py @@ -60,14 +60,14 @@ class TableFormatInfo(object): def __validate(self): if self.file_format not in TableFormatInfo.KNOWN_FILE_FORMATS: - raise ValueError, 'Unknown file format: %s' % self.file_format + raise ValueError('Unknown file format: %s' % self.file_format) if self.compression_codec not in TableFormatInfo.KNOWN_COMPRESSION_CODECS: - raise ValueError, 'Unknown compression codec: %s' % self.compression_codec + raise ValueError('Unknown compression codec: %s' % self.compression_codec) if self.compression_type not in TableFormatInfo.KNOWN_COMPRESSION_TYPES: - raise ValueError, 'Unknown compression type: %s' % self.compression_type + raise ValueError('Unknown compression type: %s' % self.compression_type) if (self.compression_codec == 'none' or self.compression_type == 'none') and\ self.compression_codec != self.compression_type: - raise ValueError, 'Invalid combination of compression codec/type: %s' % str(self) + raise ValueError('Invalid combination of compression codec/type: %s' % str(self)) @staticmethod def create_from_string(dataset, table_format_string): @@ -79,11 +79,11 @@ class TableFormatInfo(object): or 'none' if the table is uncompressed. """ if table_format_string is None: - raise ValueError, 'Table format string cannot be None' + raise ValueError('Table format string cannot be None') format_parts = table_format_string.strip().split('/') if len(format_parts) not in range(2, 4): - raise ValueError, 'Invalid table format %s' % table_format_string + raise ValueError('Invalid table format %s' % table_format_string) file_format, compression_codec = format_parts[:2] if len(format_parts) == 3: @@ -288,7 +288,7 @@ def load_table_info_dimension(workload_name, exploration_strategy, file_formats= WORKLOAD_DIR, workload_name, '%s_%s.csv' % (workload_name, exploration_strategy)) if not os.path.isfile(test_vector_file): - raise RuntimeError, 'Vector file not found: ' + test_vector_file + raise RuntimeError('Vector file not found: ' + test_vector_file) vector_values = [] diff --git a/tests/common/test_result_verifier.py b/tests/common/test_result_verifier.py index 790b895fc..1532712c4 100644 --- a/tests/common/test_result_verifier.py +++ b/tests/common/test_result_verifier.py @@ -139,12 +139,12 @@ class ResultRow(object): if isinstance(key, basestring): for col in self.columns: if col.column_label == key.lower(): return col.value - raise IndexError, 'No column with label: ' + key + raise IndexError('No column with label: ' + key) elif isinstance(key, int): # If the key (column position) does not exist this will throw an IndexError when # indexing into the self.columns return str(self.columns[key]) - raise TypeError, 'Unsupported indexing key type: ' + type(key) + raise TypeError('Unsupported indexing key type: ' + type(key)) def __eq__(self, other): if not isinstance(other, self.__class__): diff --git a/tests/common/test_vector.py b/tests/common/test_vector.py index 05b49b936..005c35adb 100644 --- a/tests/common/test_vector.py +++ b/tests/common/test_vector.py @@ -129,7 +129,7 @@ class ImpalaTestMatrix(object): elif exploration_strategy in ['core', 'pairwise']: return self.__generate_pairwise_combinations() else: - raise ValueError, 'Unknown exploration strategy: %s' % exploration_strategy + raise ValueError('Unknown exploration strategy: %s' % exploration_strategy) def __generate_exhaustive_combinations(self): return [ImpalaTestVector(vec) for vec in product(*self.__extract_vector_values()) diff --git a/tests/util/plugin_runner.py b/tests/util/plugin_runner.py index a0f0d9014..2f2849f15 100644 --- a/tests/util/plugin_runner.py +++ b/tests/util/plugin_runner.py @@ -72,7 +72,7 @@ class PluginRunner(object): # If the user's entered a plugin that does not exist, raise an error. if len(plugins_not_found): msg = "Plugin(s) not found: %s" % (','.join(list(plugins_not_found))) - raise RuntimeError, msg + raise RuntimeError(msg) def __get_plugin_info(self, plugin_info): info = plugin_info.split(':') diff --git a/tests/util/test_file_parser.py b/tests/util/test_file_parser.py index e94e290da..26516600c 100644 --- a/tests/util/test_file_parser.py +++ b/tests/util/test_file_parser.py @@ -130,7 +130,7 @@ def parse_table_constraints(constraints_file): schema_exclude[table_name.lower()] +=\ map(parse_table_format_constraint, table_formats.split(',')) else: - raise ValueError, 'Unknown constraint type: %s' % constraint_type + raise ValueError('Unknown constraint type: %s' % constraint_type) return schema_include, schema_exclude, schema_only def parse_table_format_constraint(table_format_constraint): @@ -178,11 +178,11 @@ def parse_test_file_text(text, valid_section_names, skip_unknown_sections=True): # with what looks like a subsection. header = text[:match.start()] if re.match(r'^%s' % SUBSECTION_DELIMITER, header): - raise RuntimeError, dedent(""" + raise RuntimeError(dedent(""" Header must not start with '%s'. Everything before the first line matching '%s' is considered header information and will be ignored. However a header must not start with '%s' to prevent test cases from accidentally being ignored.""" % - (SUBSECTION_DELIMITER, SECTION_DELIMITER, SUBSECTION_DELIMITER)) + (SUBSECTION_DELIMITER, SECTION_DELIMITER, SUBSECTION_DELIMITER))) text = text[match.start():] # Split the test file up into sections. For each section, parse all subsections. @@ -215,7 +215,7 @@ def parse_test_file_text(text, valid_section_names, skip_unknown_sections=True): print('Unknown section \'%s\'' % subsection_name) continue else: - raise RuntimeError, 'Unknown subsection: %s' % subsection_name + raise RuntimeError('Unknown subsection: %s' % subsection_name) if subsection_name == 'QUERY' and subsection_comment: parsed_sections['QUERY_NAME'] = subsection_comment @@ -229,7 +229,7 @@ def parse_test_file_text(text, valid_section_names, skip_unknown_sections=True): elif comment.startswith('VERIFY'): parsed_sections['VERIFIER'] = comment else: - raise RuntimeError, 'Unknown subsection comment: %s' % comment + raise RuntimeError('Unknown subsection comment: %s' % comment) if subsection_name == 'CATCH': parsed_sections['CATCH'] = list() @@ -238,7 +238,7 @@ def parse_test_file_text(text, valid_section_names, skip_unknown_sections=True): elif subsection_comment == 'ANY_OF': parsed_sections['CATCH'].extend(lines_content) else: - raise RuntimeError, 'Unknown subsection comment: %s' % subsection_comment + raise RuntimeError('Unknown subsection comment: %s' % subsection_comment) for exception_str in parsed_sections['CATCH']: assert exception_str.strip(), "Empty exception string." continue @@ -251,8 +251,8 @@ def parse_test_file_text(text, valid_section_names, skip_unknown_sections=True): # not supported. if subsection_name == 'DML_RESULTS': if subsection_comment is None or subsection_comment == '': - raise RuntimeError, 'DML_RESULTS requires that the table is specified ' \ - 'in the comment.' + raise RuntimeError('DML_RESULTS requires that the table is specified ' \ + 'in the comment.') parsed_sections['DML_RESULTS_TABLE'] = subsection_comment parsed_sections['VERIFIER'] = 'VERIFY_IS_EQUAL_SORTED'
