From d337aeed4e189d185b9834df41c0409d59dcd3e9 Mon Sep 17 00:00:00 2001
From: Yann Leboulanger <asterix@lagaule.org>
Date: Mon, 30 Dec 2013 21:19:15 +0100
Subject: [PATCH] py2 -> py3

---
 src/common/connection_handlers_events.py | 2 +-
 src/common/crypto.py                     | 7 ++++---
 src/common/jingle_content.py             | 4 ++--
 src/common/jingle_ft.py                  | 2 +-
 src/common/jingle_xtls.py                | 2 +-
 src/common/socks5.py                     | 2 +-
 src/gui_interface.py                     | 2 +-
 7 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/src/common/connection_handlers_events.py b/src/common/connection_handlers_events.py
index e6e55c8684..8945c92d01 100644
--- a/src/common/connection_handlers_events.py
+++ b/src/common/connection_handlers_events.py
@@ -1216,7 +1216,7 @@ class GcInvitationReceivedEvent(nec.NetworkIncomingEvent):
             self.is_continued = False
             if invite_tag.getAttr('continue') == 'true':
                 self.is_continued = True
-        else
+        else:
             self.room_jid = self.msg_obj.fjid
             item = self.msg_obj.invite_tag.getTag('invite')
             try:
diff --git a/src/common/crypto.py b/src/common/crypto.py
index 0b45cbac13..e8ee300a59 100644
--- a/src/common/crypto.py
+++ b/src/common/crypto.py
@@ -87,7 +87,7 @@ def add_entropy_sources_OpenSSL():
         os.environ, os.getcwd(), os.getpid()]
 
     for s in sources:
-        OpenSSL.rand.add(str(s), 0.01)
+        OpenSSL.rand.add(str(s).encode('utf-8'), 0.01)
 
     # On Windows add the current contents of the screen to the PRNG state.
     if os.name == 'nt':
@@ -99,12 +99,13 @@ def add_entropy_sources_OpenSSL():
         for d in dirs:
             if os.access(d, os.R_OK):
                for filename in os.listdir(d):
-                  OpenSSL.rand.add(filename, 0)
+                  OpenSSL.rand.add(filename.encode('utf-8'), 0)
                   try:
                      with open(d + os.sep + filename, "r") as fp:
                          # Limit the ammount of read bytes, in case a memory
                          # file was opened
-                         OpenSSL.rand.add(str(fp.read(5000)), 0.01)
+                         OpenSSL.rand.add(str(fp.read(5000)).encode('utf-8'),
+                             0.01)
                   except:
                       # Ignore all read and access errors
                       pass
diff --git a/src/common/jingle_content.py b/src/common/jingle_content.py
index c417f704dd..2634957c64 100644
--- a/src/common/jingle_content.py
+++ b/src/common/jingle_content.py
@@ -21,8 +21,8 @@ import os
 from common import gajim
 import nbxmpp
 from common.jingle_transport import JingleTransportIBB
-from jingle_xtls import SELF_SIGNED_CERTIFICATE
-from jingle_xtls import load_cert_file
+from .jingle_xtls import SELF_SIGNED_CERTIFICATE
+from .jingle_xtls import load_cert_file
 
 contents = {}
 
diff --git a/src/common/jingle_ft.py b/src/common/jingle_ft.py
index 54f5eb9190..edd1d3284d 100644
--- a/src/common/jingle_ft.py
+++ b/src/common/jingle_ft.py
@@ -22,7 +22,7 @@ Handles  Jingle File Transfer (XEP 0234)
 import hashlib
 from common import gajim
 import nbxmpp
-import jingle_xtls
+from . import jingle_xtls
 from common.jingle_content import contents, JingleContent
 from common.jingle_transport import *
 from common import helpers
diff --git a/src/common/jingle_xtls.py b/src/common/jingle_xtls.py
index b238cf7351..caf0331b6d 100644
--- a/src/common/jingle_xtls.py
+++ b/src/common/jingle_xtls.py
@@ -286,7 +286,7 @@ def make_certs(filepath, CN):
     req = createCertRequest(key, CN=CN)
     cert = createCertificate(req, req, key, 0, 0, 60*60*24*365*5) # five years
     with open(filepath + '.pkey', 'wb') as f:
-        os.chmod(filepath + '.pkey', 0600)
+        os.chmod(filepath + '.pkey', 0o600)
         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).decode(
diff --git a/src/common/socks5.py b/src/common/socks5.py
index 9ccfa92c2b..86a5518235 100644
--- a/src/common/socks5.py
+++ b/src/common/socks5.py
@@ -494,7 +494,7 @@ class Socks5(object):
             self._sock.connect(self._server)
             self._send=self._sock.send
             self._recv=self._sock.recv
-        except (OpenSSL.SSL.WantReadError, OpenSSL.SSL.WantWriteError), e:
+        except (OpenSSL.SSL.WantReadError, OpenSSL.SSL.WantWriteError) as e:
             pass
         except Exception as ee:
             errnum = ee.errno
diff --git a/src/gui_interface.py b/src/gui_interface.py
index 9a314be611..319ab6994c 100644
--- a/src/gui_interface.py
+++ b/src/gui_interface.py
@@ -1971,7 +1971,7 @@ class Interface:
                 import imp
                 imp.reload(emoticons)
             emots = emoticons.emoticons
-         except Exception, e:
+        except Exception as e:
             return True
         for emot_filename in emots:
             emot_file = os.path.join(path, emot_filename)
-- 
GitLab