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

@@ -451,6 +451,9 @@ class ArrayColumn(CollectionColumn):
return True
return self.name == other.name and self.owner.identifier == other.owner.identifier
def __hash__(self):
return hash((self.name, self.owner.identifier))
def __deepcopy__(self, memo):
other = ArrayColumn(
owner=self.owner,
@@ -480,6 +483,9 @@ class MapColumn(CollectionColumn):
return True
return self.name == other.name and self.owner.identifier == other.owner.identifier
def __hash__(self):
return hash((self.name, self.owner.identifier))
def __deepcopy__(self, memo):
other = MapColumn(
owner=self.owner,