You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by mi...@apache.org on 2023/03/21 16:24:56 UTC

[impala] branch master updated: IMPALA-11997: Switch encodestring to encodebytes in Python 3

This is an automated email from the ASF dual-hosted git repository.

michaelsmith pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git


The following commit(s) were added to refs/heads/master by this push:
     new 86f9e881a IMPALA-11997: Switch encodestring to encodebytes in Python 3
86f9e881a is described below

commit 86f9e881a45942abfde65b4da72c551c97f69449
Author: Michael Smith <mi...@cloudera.com>
AuthorDate: Mon Mar 20 11:24:46 2023 -0700

    IMPALA-11997: Switch encodestring to encodebytes in Python 3
    
    encodestring has been a deprecated alias to encodebytes since Python
    3.1. It was removed in Python 3.9. However encodebytes was only added in
    Python 3.1, so we need to test and use the appropriate call for each
    version.
    
    Change-Id: If802eafa984a980d4442c4891876140ff9708096
    Reviewed-on: http://gerrit.cloudera.org:8080/19635
    Reviewed-by: Abhishek Rawat <ar...@cloudera.com>
    Tested-by: Michael Smith <mi...@cloudera.com>
---
 shell/impala_client.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/shell/impala_client.py b/shell/impala_client.py
index af6739cd0..e678dad55 100755
--- a/shell/impala_client.py
+++ b/shell/impala_client.py
@@ -418,7 +418,11 @@ class ImpalaClient(object):
     if self.use_ldap:
       # Set the BASIC authorization
       user_passwd = "{0}:{1}".format(self.user, self.ldap_password)
-      auth = base64.encodestring(user_passwd.encode()).decode().strip('\n')
+      if sys.version_info.major < 3 or \
+          sys.version_info.major == 3 and sys.version_info.minor == 0:
+        auth = base64.encodestring(user_passwd.encode()).decode().strip('\n')
+      else:
+        auth = base64.encodebytes(user_passwd.encode()).decode().strip('\n')
       transport.setLdapAuth(auth)
     elif self.use_kerberos or self.kerberos_host_fqdn:
       # Set the Kerberos service