IMPALA-11976: Fix use of deprecated functions/fields removed in Python 3

Python 3 moved several things around or removed deprecated
functions / fields:
 - sys.maxint was removed, but sys.maxsize provides similar functionality
 - long was removed, but int provides the same range
 - file() was removed, but open() already provided the same functionality
 - Exception.message was removed, but str(exception) is equivalent
 - Some encodings (like hex) were moved to codecs.encode()
 - string.letters -> string.ascii_letters
 - string.lowercase -> string.ascii_lowercase
 - string.strip was removed

This fixes all of those locations. Python 3 also has slightly different
rounding behavior from round(), so this changes round() to use future's
builtins.round() to get the Python 3 behavior.

This fixes the following pylint warnings:
 - file-builtin
- long-builtin
- invalid-str-codec
- round-builtin
- deprecated-string-function
- sys-max-int
- exception-message-attribute

Testing:
 - Ran cores tests

Change-Id: I094cd7fd06b0d417fc875add401d18c90d7a792f
Reviewed-on: http://gerrit.cloudera.org:8080/19591
Reviewed-by: Joe McDonnell <joemcdonnell@cloudera.com>
Tested-by: Joe McDonnell <joemcdonnell@cloudera.com>
This commit is contained in:
Joe McDonnell
2023-03-04 10:21:59 -08:00
parent c233634d74
commit aa4050b4d9
27 changed files with 64 additions and 53 deletions

View File

@@ -75,10 +75,10 @@ while time.time() - now < TIMEOUT_SECONDS:
print("HiveServer2 service is up at %s." % options.hs2_hostport)
exit(0)
except Exception as e:
if "SASL" in e.message: # Bail out on SASL failures
if "SASL" in str(e): # Bail out on SASL failures
print("SASL failure when attempting connection:")
raise
if "GSS" in e.message: # Other GSSAPI failures
if "GSS" in str(e): # Other GSSAPI failures
print("GSS failure when attempting connection:")
raise
print("Waiting for HiveServer2 at %s..." % options.hs2_hostport)