Commit d2759107 authored by Yann Leboulanger's avatar Yann Leboulanger

fix exception handling

parent 069bddbb
......@@ -508,7 +508,7 @@ if dbus_support.supported:
def prefs_store(self):
try:
gajim.interface.save_config()
except Exception, e:
except Exception as e:
return DBUS_BOOLEAN(False)
return DBUS_BOOLEAN(True)
......
......@@ -165,7 +165,7 @@ class Command(object):
# command or name attributes set. They will be set to a
# corresponding values right here in case if they was not set by
# the one who raised an exception.
except CommandError, error:
except CommandError as error:
if not error.command and not error.name:
raise CommandError(error.message, self)
raise
......
......@@ -62,13 +62,13 @@ class ChatCommandProcessor(CommandProcessor):
try:
parents = super(ChatCommandProcessor, self)
parents.execute_command(name, arguments)
except NoCommandError, error:
except NoCommandError as error:
details = dict(name=error.name, message=error.message)
message = "%(name)s: %(message)s\n" % details
message += "Try using the //%(name)s or /say /%(name)s " % details
message += "construct if you intended to send it as a text."
self.echo_error(message)
except CommandError, error:
except CommandError as error:
self.echo_error("%s: %s" % (error.name, error.message))
except Exception:
self.echo_error(_("Error during command execution!"))
......
......@@ -161,7 +161,7 @@ def split_db():
con.commit()
cur.executescript('DROP TABLE %s;' % table)
con.commit()
except sqlite.OperationalError, e:
except sqlite.OperationalError as e:
print('error moving table %s to cache.db: %s' % (table, str(e)),
file=sys.stderr)
con.close()
......
......@@ -161,7 +161,7 @@ class ConfigPaths:
windowsify('plugins')))
try:
self.add('TMP', None, fse(tempfile.gettempdir()))
except IOError, e:
except IOError as e:
print('Error opening tmp folder: %s\nUsing %s' % (str(e),
os.path.expanduser('~')), file=sys.stderr)
self.add('TMP', None, fse(os.path.expanduser('~')))
......
......@@ -455,7 +455,7 @@ class CommonConnection:
log_msg = '<body xmlns="%s">%s</body>' % (
nbxmpp.NS_XHTML, xhtml)
gajim.logger.write(kind, jid, log_msg)
except exceptions.PysqliteOperationalError, e:
except exceptions.PysqliteOperationalError as e:
self.dispatch('DB_ERROR', (_('Disk Write Error'),
str(e)))
except exceptions.DatabaseMalformed:
......
......@@ -331,7 +331,7 @@ class ConnectionVcard:
fil = open(path_to_file, 'w')
fil.write(str(card))
fil.close()
except IOError, e:
except IOError as e:
gajim.nec.push_incoming_event(InformationEvent(None, conn=self,
level='error', pri_txt=_('Disk Write Error'), sec_txt=str(e)))
......@@ -947,7 +947,7 @@ class ConnectionHandlersBase:
gajim.config.should_log(self.name, obj.jid):
try:
gajim.logger.write('status', obj.jid, obj.status, obj.show)
except exceptions.PysqliteOperationalError, e:
except exceptions.PysqliteOperationalError as e:
self.dispatch('DB_ERROR', (_('Disk Write Error'), str(e)))
except exceptions.DatabaseMalformed:
pritext = _('Database Error')
......@@ -1069,7 +1069,7 @@ class ConnectionHandlersBase:
try:
gajim.logger.write('error', frm, error_msg, tim=tim,
subject=subject)
except exceptions.PysqliteOperationalError, e:
except exceptions.PysqliteOperationalError as e:
self.dispatch('DB_ERROR', (_('Disk Write Error'), str(e)))
except exceptions.DatabaseMalformed:
pritext = _('Database Error')
......
......@@ -220,11 +220,11 @@ class TimeResultReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
try:
t = datetime.datetime.strptime(utc_time, '%Y-%m-%dT%H:%M:%SZ')
except ValueError, e:
except ValueError as e:
try:
t = datetime.datetime.strptime(utc_time,
'%Y-%m-%dT%H:%M:%S.%fZ')
except ValueError, e:
except ValueError as e:
log.info('Wrong time format: %s' % str(e))
return
......@@ -905,7 +905,7 @@ class GcPresenceReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
try:
gajim.logger.write('gcstatus', self.fjid, st,
self.show)
except exceptions.PysqliteOperationalError, e:
except exceptions.PysqliteOperationalError as e:
self.conn.dispatch('DB_ERROR', (_('Disk Write Error'),
str(e)))
except exceptions.DatabaseMalformed:
......
......@@ -32,7 +32,7 @@ try:
from common import caps_cache
from common.account import Account
import common.gajim
except ImportError, e:
except ImportError as e:
if __name__ != "__main__":
raise ImportError(e)
......
......@@ -154,7 +154,7 @@ def get_interface(interface, path, start_service=True):
return None
obj = bus.get_object(interface, path)
return dbus.Interface(obj, interface)
except Exception, e:
except Exception as e:
gajim.log.debug(str(e))
return None
......
......@@ -79,7 +79,7 @@ class GlobalEventsDispatcher(object):
if event_name in self.handlers:
try:
self.handlers[event_name].remove((priority, handler))
except ValueError, error:
except ValueError as error:
log.warn('''Function (%s) with priority "%s" never registered
as handler of event "%s". Couldn\'t remove. Error: %s'''
%(handler, priority, event_name, error))
......@@ -94,7 +94,7 @@ class GlobalEventsDispatcher(object):
return True
except NodeProcessed:
node_processed = True
except Exception, e:
except Exception as e:
log.error('Error while running an even handler: %s' % \
handler)
traceback.print_exc()
......
......@@ -207,7 +207,7 @@ def temp_failure_retry(func, *args, **kwargs):
while True:
try:
return func(*args, **kwargs)
except (os.error, IOError, select.error), ex:
except (os.error, IOError, select.error) as ex:
if ex.errno == errno.EINTR:
continue
else:
......@@ -1465,7 +1465,7 @@ def _get_img_direct(attrs):
req = urllib2.Request(attrs['src'])
req.add_header('User-Agent', 'Gajim ' + gajim.version)
f = urllib2.urlopen(req)
except Exception, ex:
except Exception as ex:
log.debug('Error loading image %s ' % attrs['src'] + str(ex))
pixbuf = None
alt = attrs.get('alt', 'Broken image')
......@@ -1488,7 +1488,7 @@ def _get_img_direct(attrs):
break
try:
temp = f.read(100)
except socket.timeout, ex:
except socket.timeout as ex:
log.debug('Timeout loading image %s ' % attrs['src'] + str(ex))
alt = attrs.get('alt', '')
if alt:
......@@ -1540,7 +1540,7 @@ def _get_img_proxy(attrs, proxy):
c.close()
t = b.getvalue()
return (t, attrs.get('alt', ''))
except pycurl.error, ex:
except pycurl.error as ex:
alt = attrs.get('alt', '')
if alt:
alt += '\n'
......@@ -1550,7 +1550,7 @@ def _get_img_proxy(attrs, proxy):
alt += _('Timeout loading image')
else:
alt += _('Error loading image')
except Exception, ex:
except Exception as ex:
log.debug('Error loading image %s ' % attrs['src'] + str(ex))
pixbuf = None
alt = attrs.get('alt', 'Broken image')
......
......@@ -68,7 +68,7 @@ try:
rootwindow = libX11.XDefaultRootWindow(dpy_p)
xss_available = True
except OSError, e:
except OSError as e:
# Logging?
xss_available = False
......
......@@ -86,8 +86,8 @@ class JingleRTPContent(JingleContent):
try:
ip = socket.getaddrinfo(stun_server, 0, socket.AF_UNSPEC,
socket.SOCK_STREAM)[0][4][0]
except socket.gaierror, (errnum, errstr):
log.warn('Lookup of stun ip failed: %s' % errstr)
except socket.gaierror as e:
log.warn('Lookup of stun ip failed: %s' % str(e))
else:
params['stun-ip'] = ip
......@@ -104,7 +104,7 @@ class JingleRTPContent(JingleContent):
try:
bin = gst.parse_bin_from_description(pipeline, True)
return bin
except GError, error_str:
except GError as error_str:
gajim.nec.push_incoming_event(InformationEvent(None,
conn=self.session.connection, level='error',
pri_txt=_('%s configuration error') % text.capitalize(),
......
......@@ -63,7 +63,7 @@ def load_cert_file(cert_path, cert_store):
return
try:
f = open(cert_path)
except IOError, e:
except IOError as e:
log.warning('Unable to open certificate file %s: %s' % (cert_path,
str(e)))
return
......@@ -79,7 +79,7 @@ def load_cert_file(cert_path, cert_store):
x509cert = OpenSSL.crypto.load_certificate(
OpenSSL.crypto.FILETYPE_PEM, cert)
cert_store.add_cert(x509cert)
except OpenSSL.crypto.Error, exception_obj:
except OpenSSL.crypto.Error as exception_obj:
log.warning('Unable to load a certificate from file %s: %s' %\
(cert_path, exception_obj.args[0][0][2]))
except:
......
......@@ -149,7 +149,7 @@ class Logger:
def attach_cache_database(self):
try:
self.cur.execute("ATTACH DATABASE '%s' AS cache" % CACHE_DB_PATH)
except sqlite.Error, e:
except sqlite.Error as e:
log.debug("Failed to attach cache database: %s" % str(e))
def set_synchronous(self, sync):
......@@ -158,7 +158,7 @@ class Logger:
self.cur.execute("PRAGMA synchronous = NORMAL")
else:
self.cur.execute("PRAGMA synchronous = OFF")
except sqlite.Error, e:
except sqlite.Error as e:
log.debug("Failed to set_synchronous(%s): %s" % (sync, str(e)))
def init_vars(self):
......@@ -168,7 +168,7 @@ class Logger:
def _really_commit(self):
try:
self.con.commit()
except sqlite.OperationalError, e:
except sqlite.OperationalError as e:
print(str(e), file=sys.stderr)
self.commit_timout_id = None
return False
......@@ -256,11 +256,11 @@ class Logger:
self.cur.execute('INSERT INTO jids (jid, type) VALUES (?, ?)', (jid,
typ))
self.con.commit()
except sqlite.IntegrityError, e:
except sqlite.IntegrityError as e:
# Jid already in DB, maybe added by another instance. re-read DB
self.get_jids_already_in_db()
return self.get_jid_id(jid, typestr)
except sqlite.OperationalError, e:
except sqlite.OperationalError as e:
raise exceptions.PysqliteOperationalError(str(e))
jid_id = self.cur.lastrowid
self.jids_already_in.append(jid)
......@@ -407,14 +407,14 @@ class Logger:
self.cur.execute(sql, values)
except sqlite.DatabaseError:
raise exceptions.DatabaseMalformed
except sqlite.OperationalError, e:
except sqlite.OperationalError as e:
raise exceptions.PysqliteOperationalError(str(e))
message_id = None
if write_unread:
try:
self.con.commit()
message_id = self.cur.lastrowid
except sqlite.OperationalError, e:
except sqlite.OperationalError as e:
print(str(e), file=sys.stderr)
else:
self._timeout_commit()
......@@ -522,7 +522,7 @@ class Logger:
# status for roster items
try:
jid_id = self.get_jid_id(jid)
except exceptions.PysqliteOperationalError, e:
except exceptions.PysqliteOperationalError as e:
raise exceptions.PysqliteOperationalError(str(e))
if show is None: # show is None (xmpp), but we say that 'online'
show_col = constants.SHOW_ONLINE
......@@ -535,7 +535,7 @@ class Logger:
try:
# re-get jid_id for the new jid
jid_id = self.get_jid_id(jid, 'ROOM')
except exceptions.PysqliteOperationalError, e:
except exceptions.PysqliteOperationalError as e:
raise exceptions.PysqliteOperationalError(str(e))
contact_name_col = nick
......@@ -549,13 +549,13 @@ class Logger:
try:
# re-get jid_id for the new jid
jid_id = self.get_jid_id(jid, 'ROOM')
except exceptions.PysqliteOperationalError, e:
except exceptions.PysqliteOperationalError as e:
raise exceptions.PysqliteOperationalError(str(e))
contact_name_col = nick
else:
try:
jid_id = self.get_jid_id(jid)
except exceptions.PysqliteOperationalError, e:
except exceptions.PysqliteOperationalError as e:
raise exceptions.PysqliteOperationalError(str(e))
if kind == 'chat_msg_recv':
if not self.jid_is_from_pm(jid):
......@@ -580,7 +580,7 @@ class Logger:
"""
try:
self.get_jid_id(jid)
except exceptions.PysqliteOperationalError, e:
except exceptions.PysqliteOperationalError as e:
# Error trying to create a new jid_id. This means there is no log
return []
where_sql, jid_tuple = self._build_contact_where(account, jid)
......@@ -624,7 +624,7 @@ class Logger:
"""
try:
self.get_jid_id(jid)
except exceptions.PysqliteOperationalError, e:
except exceptions.PysqliteOperationalError as e:
# Error trying to create a new jid_id. This means there is no log
return []
where_sql, jid_tuple = self._build_contact_where(account, jid)
......@@ -653,14 +653,14 @@ class Logger:
"""
try:
self.get_jid_id(jid)
except exceptions.PysqliteOperationalError, e:
except exceptions.PysqliteOperationalError as e:
# Error trying to create a new jid_id. This means there is no log
return []
if False: # query.startswith('SELECT '): # it's SQL query (FIXME)
try:
self.cur.execute(query)
except sqlite.OperationalError, e:
except sqlite.OperationalError as e:
results = [('', '', '', '', str(e))]
return results
......@@ -694,7 +694,7 @@ class Logger:
"""
try:
self.get_jid_id(jid)
except exceptions.PysqliteOperationalError, e:
except exceptions.PysqliteOperationalError as e:
# Error trying to create a new jid_id. This means there is no log
return []
days_with_logs = []
......@@ -736,7 +736,7 @@ class Logger:
else:
try:
jid_id = self.get_jid_id(jid, 'ROOM')
except exceptions.PysqliteOperationalError, e:
except exceptions.PysqliteOperationalError as e:
# Error trying to create a new jid_id. This means there is no log
return None
where_sql = 'jid_id = ?'
......@@ -762,7 +762,7 @@ class Logger:
"""
try:
jid_id = self.get_jid_id(jid, 'ROOM')
except exceptions.PysqliteOperationalError, e:
except exceptions.PysqliteOperationalError as e:
# Error trying to create a new jid_id. This means there is no log
return None
where_sql = 'jid_id = %s' % jid_id
......@@ -802,7 +802,7 @@ class Logger:
for user in family:
try:
jid_id = self.get_jid_id(user['jid'])
except exceptions.PysqliteOperationalError, e:
except exceptions.PysqliteOperationalError as e:
continue
where_sql += 'jid_id = ?'
jid_tuple += (jid_id,)
......@@ -988,7 +988,7 @@ class Logger:
try:
account_jid_id = self.get_jid_id(account_jid)
jid_id = self.get_jid_id(jid)
except exceptions.PysqliteOperationalError, e:
except exceptions.PysqliteOperationalError as e:
raise exceptions.PysqliteOperationalError(str(e))
self.cur.execute(
'DELETE FROM roster_group WHERE account_jid_id=? AND jid_id=?',
......@@ -1010,7 +1010,7 @@ class Logger:
try:
account_jid_id = self.get_jid_id(account_jid)
jid_id = self.get_jid_id(jid)
except exceptions.PysqliteOperationalError, e:
except exceptions.PysqliteOperationalError as e:
raise exceptions.PysqliteOperationalError(str(e))
# Update groups information
......@@ -1150,7 +1150,7 @@ class Logger:
# when we quit this muc
obj.conn.last_history_time[obj.jid] = tim_f
except exceptions.PysqliteOperationalError, e:
except exceptions.PysqliteOperationalError as e:
obj.conn.dispatch('DB_ERROR', (_('Disk Write Error'), str(e)))
except exceptions.DatabaseMalformed:
pritext = _('Database Error')
......
......@@ -102,11 +102,11 @@ class OptionsParser:
self.__tempfile = os.path.join(base_dir, '.' + filename)
try:
f = open(self.__tempfile, 'w')
except IOError, e:
except IOError as e:
return str(e)
try:
gajim.config.foreach(self.write_line, f)
except IOError, e:
except IOError as e:
return str(e)
f.flush()
os.fsync(f.fileno())
......@@ -120,7 +120,7 @@ class OptionsParser:
pass
try:
os.rename(self.__tempfile, self.__filename)
except IOError, e:
except IOError as e:
return str(e)
os.chmod(self.__filename, 0600)
......@@ -648,7 +648,7 @@ class OptionsParser:
'''
)
con.commit()
except sqlite.OperationalError, e:
except sqlite.OperationalError as e:
pass
con.close()
gajim.config.set('version', '0.11.4.4')
......
......@@ -81,7 +81,7 @@ class GnomePasswordStorage(PasswordStorage):
## migrate the password over to keyring
try:
self.save_password(account_name, password, update=False)
except GnomeKeyringError, e:
except GnomeKeyringError as e:
if e.error == GnomeKeyring.Result.NO_KEYRING_DAEMON:
## no keyring daemon: in the future, stop using it
set_storage(SimplePasswordStorage())
......
......@@ -333,7 +333,7 @@ class HostTester(Socks5, IdleObject):
log.debug('Host Connecting to %s:%s' % (self.host, self.port))
self._send = self._sock.send
self._recv = self._sock.recv
except Exception, ee:
except Exception as ee:
errnum = ee[0]
# 56 is for freebsd
if errnum in (errno.EINPROGRESS, errno.EALREADY, errno.EWOULDBLOCK):
......@@ -461,7 +461,7 @@ class ReceiverTester(Socks5, IdleObject):
log.debug('Receiver Connecting to %s:%s' % (self.host, self.port))
self._send = self._sock.send
self._recv = self._sock.recv
except Exception, ee:
except Exception as ee:
errnum = ee[0]
# 56 is for freebsd
if errnum in (errno.EINPROGRESS, errno.EALREADY, errno.EWOULDBLOCK):
......
......@@ -65,7 +65,7 @@ else:
options={}, content=[]):
try:
valid_text = validator(text)
except ValueError, e:
except ValueError as e:
msg = inliner.reporter.error( e.message % dict(text=text), line=lineno)
prb = inliner.problematic(rawtext, rawtext, msg)
return [prb], [msg]
......
......@@ -463,7 +463,7 @@ class Socks5:
self._sock.setblocking(False)
self._server = ai[4]
break
except socket.error, e:
except socket.error as e:
if not isinstance(e, basestring) and e[0] == EINPROGRESS:
break
# for all other errors, we try other addresses
......@@ -481,7 +481,7 @@ class Socks5:
self._sock.setblocking(False)
self._send=self._sock.send
self._recv=self._sock.recv
except Exception, ee:
except Exception as ee:
errnum = ee[0]
self.connect_timeout += 1
if errnum == 111 or self.connect_timeout > 1000:
......@@ -533,7 +533,7 @@ class Socks5:
self.size = self.file_props.offset
self.file.seek(self.size)
self.file_props.received_len = self.size
except IOError, e:
except IOError as e:
self.close_file()
raise IOError, e
......@@ -583,7 +583,7 @@ class Socks5:
try:
add = self._recv(64)
except (OpenSSL.SSL.WantReadError, OpenSSL.SSL.WantWriteError,
OpenSSL.SSL.WantX509LookupError), e:
OpenSSL.SSL.WantX509LookupError) as e:
log.info('SSL rehandshake request : ' + repr(e))
raise e
except Exception:
......@@ -600,10 +600,10 @@ class Socks5:
try:
self._send(raw_data)
except (OpenSSL.SSL.WantReadError, OpenSSL.SSL.WantWriteError,
OpenSSL.SSL.WantX509LookupError), e:
OpenSSL.SSL.WantX509LookupError) as e:
log.info('SSL rehandshake request :' + repr(e))
raise e
except Exception, e:
except Exception as e:
self.disconnect()
return len(raw_data)
......@@ -614,7 +614,7 @@ class Socks5:
else:
try:
self.open_file_for_reading()
except IOError, e:
except IOError as e:
self.state = 8 # end connection
self.disconnect()
self.file_props.error = -7 # unable to read from file
......@@ -625,10 +625,10 @@ class Socks5:
try:
lenn = self._send(buff)
except (OpenSSL.SSL.WantReadError, OpenSSL.SSL.WantWriteError,
OpenSSL.SSL.WantX509LookupError), e:
OpenSSL.SSL.WantX509LookupError) as e:
log.info('SSL rehandshake request :' + repr(e))
raise e
except Exception, e:
except Exception as e:
if e.args[0] not in (EINTR, ENOBUFS, EWOULDBLOCK):
# peer stopped reading
self.state = 8 # end connection
......@@ -671,7 +671,7 @@ class Socks5:
if self.remaining_buff != '':
try:
fd = self.get_fd()
except IOError, e:
except IOError as e:
self.disconnect(False)
self.file_props.error = -6 # file system error
return 0
......@@ -692,14 +692,14 @@ class Socks5:
else:
try:
fd = self.get_fd()
except IOError, e:
except IOError as e:
self.disconnect(False)
self.file_props.error = -6 # file system error
return 0
try:
buff = self._recv(MAX_BUFF_LEN)
except (OpenSSL.SSL.WantReadError, OpenSSL.SSL.WantWriteError,
OpenSSL.SSL.WantX509LookupError), e:
OpenSSL.SSL.WantX509LookupError) as e:
log.info('SSL rehandshake request :' + repr(e))
raise e
except Exception:
......@@ -718,7 +718,7 @@ class Socks5:
return 0
try:
fd.write(buff)
except IOError, e:
except IOError as e:
self.rem_fd(fd)
self.disconnect()
self.file_props.error = -6 # file system error
......@@ -842,7 +842,7 @@ class Socks5:
try:
buff = self._recv()
except (SSL.WantReadError, SSL.WantWriteError,
SSL.WantX509LookupError), e:
SSL.WantX509LookupError) as e:
log.info("SSL rehandshake request : " + repr(e))
raise e
try:
......@@ -1085,7 +1085,7 @@ class Socks5Server(Socks5):
result = self.start_transfer() # send
self.queue.process_result(result, self)
except (OpenSSL.SSL.WantReadError, OpenSSL.SSL.WantWriteError,
OpenSSL.SSL.WantX509LookupError), e:
OpenSSL.SSL.WantX509LookupError) as e:
log.info('caught SSL exception, ignored')
else:
self.disconnect()
......@@ -1123,7 +1123,7 @@ class Socks5Server(Socks5):
else:
self.disconnect()
except (OpenSSL.SSL.WantReadError, OpenSSL.SSL.WantWriteError,
OpenSSL.SSL.WantX509LookupError), e:
OpenSSL.SSL.WantX509LookupError) as e:
log.info('caught SSL exception, ignored')
return
if self.state < 5:
......@@ -1229,7 +1229,7 @@ class Socks5Client(Socks5):
result = self.start_transfer() # receive
self.queue.process_result(result, self)
except (OpenSSL.SSL.WantReadError, OpenSSL.SSL.WantWriteError,
OpenSSL.SSL.WantX509LookupError), e:
OpenSSL.SSL.WantX509LookupError) as e:
log.info('caught SSL exception, ignored')
return
else:
......@@ -1253,7 +1253,7 @@ class Socks5Client(Socks5):
self.queue.process_result(result, self)
return
except (OpenSSL.SSL.WantReadError, OpenSSL.SSL.WantWriteError,
OpenSSL.SSL.WantX509LookupError), e:
OpenSSL.SSL.WantX509LookupError) as e:
log.info('caught SSL exception, ignored')
return
self.state += 1
......@@ -1346,7 +1346,7 @@ class Socks5Listener(IdleObject):
if self.fingerprint is not None:
self._serv = OpenSSL.SSL.Connection(
jingle_xtls.get_context('server'), self._serv)
except socket.error, e:
except socket.error as e:
if e.args[0] == EAFNOSUPPORT:
self.ai = None
continue
......
......@@ -356,7 +356,7 @@ class P2PConnection(IdleObject, PlugIn):
try:
self.ais = socket.getaddrinfo(host, port, socket.AF_UNSPEC,
socket.SOCK_STREAM)
except socket.gaierror, e:
except socket.gaierror as e:
log.info('Lookup failure for %s: %s[%s]', host, e[1],
repr(e[0]), exc_info=True)
else:
......@@ -448,7 +448,7 @@ class P2PConnection(IdleObject, PlugIn):
try:
self._sock.connect(self._server)
self._sock.setblocking(False)
except Exception, ee:
except Exception as ee:
(errnum, errstr) = ee
errors = (errno.EINPROGRESS, errno.EALREADY, errno.EWOULDBLOCK)
if 'WSAEINVAL' in errno.__dict__:
......@@ -488,7 +488,7 @@ class P2PConnection(IdleObject, PlugIn):
try:
# get as many bites, as possible, but not more than RECV_BUFSIZE
received = self._sock.recv(MAX_BUFF_LEN)
except Exception, e:
except Exception as e:
if len(e.args) > 0 and isinstance(e.args[0], int):
errnum = e[0]
# "received" will be empty anyhow
......@@ -559,7 +559,7 @@ class P2PConnection(IdleObject, PlugIn):
self._plug_idle()
self._on_send()
except socket.error, e:
except socket.error as e:
if e[0] == socket.SSL_ERROR_WANT_WRITE:
return True
if self.state < 0:
......
......@@ -22,7 +22,7 @@ log = logging.getLogger('gajim.c.z.zeroconf_avahi')
try:
import dbus.exceptions
except ImportError, e:
except ImportError as e:
pass
from common.zeroconf.zeroconf import C_BARE_NAME, C_INTERFACE, C_PROTOCOL, C_DOMAIN
......@@ -267,7 +267,7 @@ class Zeroconf:
return True
except dbus.DBusException, e:
except dbus.DBusException as e:
log.debug(str(e))
return False
......@@ -327,7 +327,7 @@ class Zeroconf:
self.bus.add_signal_receiver(self.avahi_dbus_connect_cb,
'NameOwnerChanged', 'org.freedesktop.DBus',