IMPALA-11977: Fix Python 3 broken imports and object model differences

Python 3 changed some object model methods:
 - __nonzero__ was removed in favor of __bool__
 - func_dict / func_name were removed in favor of __dict__ / __name__
 - The next() function was deprecated in favor of __next__
   (Code locations should use next(iter) rather than iter.next())
 - metaclasses are specified a different way
 - Locations that specify __eq__ should also specify __hash__

Python 3 also moved some packages around (urllib2, Queue, httplib,
etc), and this adapts the code to use the new locations (usually
handled on Python 2 via future). This also fixes the code to
avoid referencing exception variables outside the exception block
and variables outside of a comprehension. Several of these seem
like false positives, but it is better to avoid the warning.

This fixes these pylint warnings:
bad-python3-import
eq-without-hash
metaclass-assignment
next-method-called
nonzero-method
exception-escape
comprehension-escape

Testing:
 - Ran core tests
 - Ran release exhaustive tests

Change-Id: I988ae6c139142678b0d40f1f4170b892eabf25ee
Reviewed-on: http://gerrit.cloudera.org:8080/19592
Reviewed-by: Joe McDonnell <joemcdonnell@cloudera.com>
Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
This commit is contained in:
Joe McDonnell
2023-03-04 15:17:46 -08:00
parent aa4050b4d9
commit 0c7c6a335e
32 changed files with 210 additions and 153 deletions

View File

@@ -1538,11 +1538,11 @@ class TestAdmissionControllerWithACService(TestAdmissionController):
if self.exploration_strategy() != 'exhaustive':
pytest.skip('runs only in exhaustive')
if 'start_args' not in method.func_dict:
method.func_dict['start_args'] = list()
method.func_dict["start_args"].append("--enable_admission_service")
if "impalad_args" in method.func_dict:
method.func_dict["admissiond_args"] = method.func_dict["impalad_args"]
if 'start_args' not in method.__dict__:
method.__dict__['start_args'] = list()
method.__dict__["start_args"].append("--enable_admission_service")
if "impalad_args" in method.__dict__:
method.__dict__["admissiond_args"] = method.__dict__["impalad_args"]
super(TestAdmissionController, self).setup_method(method)
@SkipIfNotHdfsMinicluster.tuned_for_minicluster
@@ -2284,9 +2284,9 @@ class TestAdmissionControllerStressWithACService(TestAdmissionControllerStress):
def setup_method(self, method):
if self.exploration_strategy() != 'exhaustive':
pytest.skip('runs only in exhaustive')
if 'start_args' not in method.func_dict:
method.func_dict['start_args'] = list()
method.func_dict["start_args"].append("--enable_admission_service")
if "impalad_args" in method.func_dict:
method.func_dict["admissiond_args"] = method.func_dict["impalad_args"]
if 'start_args' not in method.__dict__:
method.__dict__['start_args'] = list()
method.__dict__["start_args"].append("--enable_admission_service")
if "impalad_args" in method.__dict__:
method.__dict__["admissiond_args"] = method.__dict__["impalad_args"]
super(TestAdmissionControllerStress, self).setup_method(method)