From 54c3f9acaa1fc95678c8bb200b84af0c5b406edf Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Mon, 30 Dec 2013 20:56:09 +0100 Subject: [PATCH] py2 -> py3 --- src/common/connection.py | 8 ++++---- src/common/connection_handlers_events.py | 4 ++-- src/common/jingle_xtls.py | 3 ++- src/gajim.py | 4 ++-- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/common/connection.py b/src/common/connection.py index 794a5616a..81bfedbe6 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -1395,15 +1395,15 @@ class Connection(CommonConnection, ConnectionHandlers): text += _('\nSSL Error: %s') % ssl_error[errnum] else: text += _('\nUnknown SSL error: %d') % errnum - fingerprint = cert.digest('sha1') + fingerprint = cert.digest('sha1').decode('utf-8') pem = OpenSSL.crypto.dump_certificate(OpenSSL.crypto.FILETYPE_PEM, - cert) + cert).decode('utf-8') gajim.nec.push_incoming_event(SSLErrorEvent(None, conn=self, error_text=text, error_num=errnum, cert=pem, fingerprint=fingerprint, certificate=cert)) return True if cert: - fingerprint = cert.digest('sha1') + fingerprint = cert.digest('sha1').decode('utf-8') saved_fingerprint = gajim.config.get_per('accounts', self.name, 'ssl_fingerprint_sha1') if saved_fingerprint: @@ -1420,7 +1420,7 @@ class Connection(CommonConnection, ConnectionHandlers): '100' not in gajim.config.get_per('accounts', self.name, 'ignore_ssl_errors').split(): pem = OpenSSL.crypto.dump_certificate( - OpenSSL.crypto.FILETYPE_PEM, cert) + OpenSSL.crypto.FILETYPE_PEM, cert).decode('utf-8') txt = _('The authenticity of the %s certificate could be ' 'invalid.\nThe certificate does not cover this domain.') %\ hostname diff --git a/src/common/connection_handlers_events.py b/src/common/connection_handlers_events.py index 51f3848d1..e6e55c868 100644 --- a/src/common/connection_handlers_events.py +++ b/src/common/connection_handlers_events.py @@ -1639,8 +1639,8 @@ class NewAccountConnectedEvent(nec.NetworkIncomingEvent): if self.conn.connection.Connection.ssl_certificate: cert = self.conn.connection.Connection.ssl_certificate self.ssl_cert = OpenSSL.crypto.dump_certificate( - OpenSSL.crypto.FILETYPE_PEM, cert) - self.ssl_fingerprint = cert.digest('sha1') + OpenSSL.crypto.FILETYPE_PEM, cert).decode('utf-8') + self.ssl_fingerprint = cert.digest('sha1').decode('utf-8') return True class NewAccountNotConnectedEvent(nec.NetworkIncomingEvent): diff --git a/src/common/jingle_xtls.py b/src/common/jingle_xtls.py index 164805fbd..b238cf735 100644 --- a/src/common/jingle_xtls.py +++ b/src/common/jingle_xtls.py @@ -289,7 +289,8 @@ def make_certs(filepath, CN): os.chmod(filepath + '.pkey', 0600) f.write(crypto.dump_privatekey(crypto.FILETYPE_PEM, key)) with open(filepath + '.cert', 'wb') as f: - f.write(crypto.dump_certificate(crypto.FILETYPE_PEM, cert)) + f.write(crypto.dump_certificate(crypto.FILETYPE_PEM, cert).decode( + 'utf-8')) if __name__ == '__main__': diff --git a/src/gajim.py b/src/gajim.py index ad20cf2d4..8f55214b8 100644 --- a/src/gajim.py +++ b/src/gajim.py @@ -71,10 +71,10 @@ except ImportError: try: from distutils.version import LooseVersion as V if V(nbxmpp.__version__) < V("0.3"): - print 'Gajim needs python-nbxmpp > 0.3 to run. Quiting...' + print('Gajim needs python-nbxmpp > 0.3 to run. Quiting...') sys.exit() except: - print 'Gajim needs python-nbxmpp > 0.3 to run. Quiting...' + print('Gajim needs python-nbxmpp > 0.3 to run. Quiting...') sys.exit() #from common import demandimport