diff --git a/plugins/dbus_plugin/plugin.py b/plugins/dbus_plugin/plugin.py index 43f3840e8..98dda772c 100644 --- a/plugins/dbus_plugin/plugin.py +++ b/plugins/dbus_plugin/plugin.py @@ -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) diff --git a/src/command_system/framework.py b/src/command_system/framework.py index d57ab7e5e..f410d594a 100644 --- a/src/command_system/framework.py +++ b/src/command_system/framework.py @@ -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 diff --git a/src/command_system/implementation/middleware.py b/src/command_system/implementation/middleware.py index 494444a32..64396d0f6 100644 --- a/src/command_system/implementation/middleware.py +++ b/src/command_system/implementation/middleware.py @@ -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!")) diff --git a/src/common/check_paths.py b/src/common/check_paths.py index e046d38aa..9ea3bd898 100644 --- a/src/common/check_paths.py +++ b/src/common/check_paths.py @@ -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() diff --git a/src/common/configpaths.py b/src/common/configpaths.py index c09191709..94550b988 100644 --- a/src/common/configpaths.py +++ b/src/common/configpaths.py @@ -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('~'))) diff --git a/src/common/connection.py b/src/common/connection.py index 2e113f084..6734ede28 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -455,7 +455,7 @@ class CommonConnection: log_msg = '%s' % ( 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: diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py index 4f87ced39..5db5a96ac 100644 --- a/src/common/connection_handlers.py +++ b/src/common/connection_handlers.py @@ -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') diff --git a/src/common/connection_handlers_events.py b/src/common/connection_handlers_events.py index 55430de2d..5dd2690d8 100644 --- a/src/common/connection_handlers_events.py +++ b/src/common/connection_handlers_events.py @@ -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: diff --git a/src/common/contacts.py b/src/common/contacts.py index 88c073242..7f7ff283c 100644 --- a/src/common/contacts.py +++ b/src/common/contacts.py @@ -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) diff --git a/src/common/dbus_support.py b/src/common/dbus_support.py index 5b1424a1c..8109c36ed 100644 --- a/src/common/dbus_support.py +++ b/src/common/dbus_support.py @@ -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 diff --git a/src/common/ged.py b/src/common/ged.py index 9ac3604a2..d46214fc5 100644 --- a/src/common/ged.py +++ b/src/common/ged.py @@ -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() diff --git a/src/common/helpers.py b/src/common/helpers.py index 27ad2fdc9..6a86be88d 100644 --- a/src/common/helpers.py +++ b/src/common/helpers.py @@ -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') diff --git a/src/common/idle.py b/src/common/idle.py index 26f1d6993..c2cccdd4b 100644 --- a/src/common/idle.py +++ b/src/common/idle.py @@ -68,7 +68,7 @@ try: rootwindow = libX11.XDefaultRootWindow(dpy_p) xss_available = True -except OSError, e: +except OSError as e: # Logging? xss_available = False diff --git a/src/common/jingle_rtp.py b/src/common/jingle_rtp.py index c28a48457..26ac22544 100644 --- a/src/common/jingle_rtp.py +++ b/src/common/jingle_rtp.py @@ -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(), diff --git a/src/common/jingle_xtls.py b/src/common/jingle_xtls.py index 9742f0bd7..3a251179f 100644 --- a/src/common/jingle_xtls.py +++ b/src/common/jingle_xtls.py @@ -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: diff --git a/src/common/logger.py b/src/common/logger.py index 0a67fe3e2..1f25d940e 100644 --- a/src/common/logger.py +++ b/src/common/logger.py @@ -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') diff --git a/src/common/optparser.py b/src/common/optparser.py index cbb1bb033..39a20c851 100644 --- a/src/common/optparser.py +++ b/src/common/optparser.py @@ -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') diff --git a/src/common/passwords.py b/src/common/passwords.py index 5a5cbd5f8..d61d2afd9 100644 --- a/src/common/passwords.py +++ b/src/common/passwords.py @@ -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()) diff --git a/src/common/proxy65_manager.py b/src/common/proxy65_manager.py index 71d782f19..ccf20d6c0 100644 --- a/src/common/proxy65_manager.py +++ b/src/common/proxy65_manager.py @@ -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): diff --git a/src/common/rst_xhtml_generator.py b/src/common/rst_xhtml_generator.py index 35907a03d..7d4e366ff 100644 --- a/src/common/rst_xhtml_generator.py +++ b/src/common/rst_xhtml_generator.py @@ -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] diff --git a/src/common/socks5.py b/src/common/socks5.py index a8ce7ecd5..f7dae87a1 100644 --- a/src/common/socks5.py +++ b/src/common/socks5.py @@ -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 diff --git a/src/common/zeroconf/client_zeroconf.py b/src/common/zeroconf/client_zeroconf.py index ebac0209e..69f1a4e6f 100644 --- a/src/common/zeroconf/client_zeroconf.py +++ b/src/common/zeroconf/client_zeroconf.py @@ -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: diff --git a/src/common/zeroconf/zeroconf_avahi.py b/src/common/zeroconf/zeroconf_avahi.py index c146b73f1..acfa85885 100644 --- a/src/common/zeroconf/zeroconf_avahi.py +++ b/src/common/zeroconf/zeroconf_avahi.py @@ -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', arg0='org.freedesktop.Avahi') - except Exception, e: + except Exception as e: # System bus is not present self.bus = None log.debug(str(e)) @@ -354,7 +354,7 @@ class Zeroconf: self.avahi.DBUS_PATH_SERVER), self.avahi.DBUS_INTERFACE_SERVER) self.server.connect_to_signal('StateChanged', self.server_state_changed_callback) - except Exception, e: + except Exception as e: # Avahi service is not present self.server = None log.debug(str(e)) @@ -395,14 +395,14 @@ class Zeroconf: if self.service_browser: try: self.service_browser.Free() - except dbus.DBusException, e: + except dbus.DBusException as e: log.debug(str(e)) self.service_browser._obj._bus = None self.service_browser._obj = None if self.domain_browser: try: self.domain_browser.Free() - except dbus.DBusException, e: + except dbus.DBusException as e: log.debug(str(e)) self.domain_browser._obj._bus = None self.domain_browser._obj = None diff --git a/src/common/zeroconf/zeroconf_bonjour.py b/src/common/zeroconf/zeroconf_bonjour.py index c8270c178..7d1566e34 100644 --- a/src/common/zeroconf/zeroconf_bonjour.py +++ b/src/common/zeroconf/zeroconf_bonjour.py @@ -24,7 +24,7 @@ from common.zeroconf.zeroconf import C_BARE_NAME, C_DOMAIN try: import pybonjour -except ImportError, e: +except ImportError as e: pass @@ -224,7 +224,7 @@ class Zeroconf: regtype = self.stype, port = self.port, txtRecord = self.txt, callBack = self.service_added_callback) self.service_sdRef = sdRef - except pybonjour.BonjourError, e: + except pybonjour.BonjourError as e: self.service_add_fail_callback(e) else: gajim.log.debug('Publishing service %s of type %s' % (self.name, self.stype)) @@ -248,7 +248,7 @@ class Zeroconf: self.service_sdRef.close() self.announced = False return True - except pybonjour.BonjourError, e: + except pybonjour.BonjourError as e: gajim.log.debug(e) return False @@ -282,7 +282,7 @@ class Zeroconf: gajim.log.debug('starting to browse') try: self.browse_sdRef = pybonjour.DNSServiceBrowse(regtype=self.stype, domain=domain, callBack=self.browse_callback) - except pybonjour.BonjourError, e: + except pybonjour.BonjourError as e: self.error_CB("Error while browsing: %s" % e) def browse_loop(self): diff --git a/src/config.py b/src/config.py index 8c395585f..9c748e58c 100644 --- a/src/config.py +++ b/src/config.py @@ -2161,7 +2161,7 @@ class AccountsWindow: # check if jid is conform to RFC and stringprep it try: jid = helpers.parse_jid(jid) - except helpers.InvalidFormat, s: + except helpers.InvalidFormat as s: if not widget.is_focus(): pritext = _('Invalid Jabber ID') dialogs.ErrorDialog(pritext, str(s)) @@ -2238,7 +2238,7 @@ class AccountsWindow: 'utf-8') try: resource = helpers.parse_resource(resource) - except helpers.InvalidFormat, s: + except helpers.InvalidFormat as s: if not widget.is_focus(): pritext = _('Invalid Jabber ID') dialogs.ErrorDialog(pritext, str(s)) @@ -3385,7 +3385,7 @@ class ManageBookmarksWindow: nick = self.nick_entry.get_text() try: nick = helpers.parse_resource(nick) - except helpers.InvalidFormat, e: + except helpers.InvalidFormat as e: dialogs.ErrorDialog(_('Invalid nickname'), _('Character not allowed')) self.nick_entry.set_text(model[iter_][6]) @@ -3405,7 +3405,7 @@ class ManageBookmarksWindow: server.strip() try: room_jid = helpers.parse_resource(room_jid) - except helpers.InvalidFormat, e: + except helpers.InvalidFormat as e: dialogs.ErrorDialog(_('Invalid server'), _('Character not allowed')) self.server_entry.set_text(model[iter_][2].split('@')[1]) @@ -3424,7 +3424,7 @@ class ManageBookmarksWindow: self.server_entry.get_text().strip() try: room_jid = helpers.parse_resource(room_jid) - except helpers.InvalidFormat, e: + except helpers.InvalidFormat as e: dialogs.ErrorDialog(_('Invalid room'), _('Character not allowed')) self.room_entry.set_text(model[iter_][2].split('@')[0]) @@ -3644,7 +3644,7 @@ class AccountCreationWizardWindow: # check if jid is conform to RFC and stringprep it try: jid = helpers.parse_jid(jid) - except helpers.InvalidFormat, s: + except helpers.InvalidFormat as s: pritext = _('Invalid Jabber ID') dialogs.ErrorDialog(pritext, str(s)) return diff --git a/src/conversation_textview.py b/src/conversation_textview.py index 5496a976c..2fbb89567 100644 --- a/src/conversation_textview.py +++ b/src/conversation_textview.py @@ -1366,7 +1366,7 @@ class ConversationTextview(GObject.GObject): xhtml = xhtml.replace('/me', '* %s' % (name,), 1) self.tv.display_html(xhtml.encode('utf-8'), self) return - except Exception, e: + except Exception as e: gajim.log.debug('Error processing xhtml' + str(e)) gajim.log.debug('with |' + xhtml + '|') diff --git a/src/dataforms_widget.py b/src/dataforms_widget.py index f5e306f45..766e51477 100644 --- a/src/dataforms_widget.py +++ b/src/dataforms_widget.py @@ -629,7 +629,7 @@ class SingleForm(Gtk.Table, object): return try: newtext = helpers.parse_jid(newtext) - except helpers.InvalidFormat, s: + except helpers.InvalidFormat as s: dialogs.ErrorDialog(_('Invalid Jabber ID'), str(s)) return if newtext in field.values: diff --git a/src/dialogs.py b/src/dialogs.py index a6f2010af..f8f3402ce 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -1073,7 +1073,7 @@ class AddNewContactWindow: # check if jid is conform to RFC and stringprep it try: jid = helpers.parse_jid(jid) - except helpers.InvalidFormat, s: + except helpers.InvalidFormat as s: pritext = _('Invalid User ID') ErrorDialog(pritext, str(s)) return @@ -2740,7 +2740,7 @@ class NewChatDialog(InputDialog): else: try: jid = helpers.parse_jid(jid) - except helpers.InvalidFormat, e: + except helpers.InvalidFormat as e: ErrorDialog(_('Invalid JID'), e[0]) return except: @@ -3672,7 +3672,7 @@ class ItemArchivingPreferencesWindow: if self.item != 'Default': try: item = helpers.parse_jid(item) - except helpers.InvalidFormat, s: + except helpers.InvalidFormat as s: pritext = _('Invalid User ID') ErrorDialog(pritext, str(s)) return diff --git a/src/disco.py b/src/disco.py index 4d7aed9da..84e19f18c 100644 --- a/src/disco.py +++ b/src/disco.py @@ -803,7 +803,7 @@ _('This type of service does not contain any items to browse.')) jid = self.address_comboboxentry.get_child().get_text() try: jid = helpers.parse_jid(jid) - except helpers.InvalidFormat, s: + except helpers.InvalidFormat as s: pritext = _('Invalid Server Name') dialogs.ErrorDialog(pritext, str(s)) return @@ -813,7 +813,7 @@ _('This type of service does not contain any items to browse.')) jid = self.address_comboboxentry.get_child().get_text() try: jid = helpers.parse_jid(jid) - except helpers.InvalidFormat, s: + except helpers.InvalidFormat as s: pritext = _('Invalid Server Name') dialogs.ErrorDialog(pritext, str(s)) return diff --git a/src/gtkgui_helpers.py b/src/gtkgui_helpers.py index b6e92a9f2..824355cf0 100644 --- a/src/gtkgui_helpers.py +++ b/src/gtkgui_helpers.py @@ -48,7 +48,7 @@ gtk_icon_theme.append_search_path(gajim.ICONS_DIR) def get_icon_pixmap(icon_name, size=16): try: return gtk_icon_theme.load_icon(icon_name, size, 0) - except GObject.GError, e: + except GObject.GError as e: log.error('Unable to load icon %s: %s' % (icon_name, str(e))) def get_icon_path(icon_name, size=16): @@ -59,7 +59,7 @@ def get_icon_path(icon_name, size=16): return "" else: return icon_info.get_filename() - except GObject.GError, e: + except GObject.GError as e: log.error("Unable to find icon %s: %s" % (icon_name, str(e))) import vcard @@ -342,10 +342,10 @@ def parse_server_xml(path_to_file): xml.sax.parse(path_to_file, handler) return handler.servers # handle exception if unable to open file - except IOError, message: + except IOError as message: print(_('Error reading file:') + message, file=sys.stderr) # handle exception parsing file - except xml.sax.SAXParseException, message: + except xml.sax.SAXParseException as message: print(_('Error parsing file:') + message, file=sys.stderr) def set_unset_urgency_hint(window, unread_messages_no): @@ -829,7 +829,7 @@ def on_avatar_save_as_menuitem_activate(widget, jid, default_name=''): # Save image try: pixbuf.savev(file_path, image_format, [], []) - except Exception, e: + except Exception as e: log.debug('Error saving avatar: %s' % str(e)) if os.path.exists(file_path): os.remove(file_path) diff --git a/src/gui_interface.py b/src/gui_interface.py index f3d92c09d..ae4b8dbaf 100644 --- a/src/gui_interface.py +++ b/src/gui_interface.py @@ -2490,7 +2490,7 @@ class Interface: path_to_original_file = path_to_file + extension try: pixbuf.savev(path_to_original_file, typ, [], []) - except Exception, e: + except Exception as e: log.error('Error writing avatar file %s: %s' % ( path_to_original_file, str(e))) # Generate and save the resized, color avatar @@ -2500,7 +2500,7 @@ class Interface: extension try: pixbuf.savev(path_to_normal_file, 'png', [], []) - except Exception, e: + except Exception as e: log.error('Error writing avatar file %s: %s' % \ (path_to_original_file, str(e))) # Generate and save the resized, black and white avatar @@ -2510,7 +2510,7 @@ class Interface: path_to_bw_file = path_to_file + '_notif_size_bw' + extension try: bwbuf.savev(path_to_bw_file, 'png', [], []) - except Exception, e: + except Exception as e: log.error('Error writing avatar file %s: %s' % \ (path_to_original_file, str(e))) diff --git a/src/history_manager.py b/src/history_manager.py index 34e757722..dc2d0b15f 100644 --- a/src/history_manager.py +++ b/src/history_manager.py @@ -64,7 +64,7 @@ def parseOpts(): shortargs = 'hc:' longargs = 'help config_path=' opts = getopt.getopt(sys.argv[1:], shortargs, longargs.split())[0] - except getopt.error, msg: + except getopt.error as msg: print(str(msg)) print('for help use --help') sys.exit(2) diff --git a/src/history_window.py b/src/history_window.py index 00d1c186f..d305e8799 100644 --- a/src/history_window.py +++ b/src/history_window.py @@ -352,7 +352,7 @@ class HistoryWindow: try: log_days = gajim.logger.get_days_with_logs(self.jid, year, month, days_in_this_month, self.account) - except exceptions.PysqliteOperationalError, e: + except exceptions.PysqliteOperationalError as e: dialogs.ErrorDialog(_('Disk Error'), str(e)) return for day in log_days: diff --git a/src/htmltextview.py b/src/htmltextview.py index 208bbf8ba..a34373dd5 100644 --- a/src/htmltextview.py +++ b/src/htmltextview.py @@ -587,7 +587,7 @@ class HtmlHandler(xml.sax.handler.ContentHandler): self.textbuf.delete_mark(tmpmark) else: self._insert_text('[IMG: %s]' % alt, working_iter) - except Exception, ex: + except Exception as ex: log.error('Error loading image ' + str(ex)) pixbuf = None alt = attrs.get('alt', 'Broken image') @@ -764,7 +764,7 @@ class HtmlHandler(xml.sax.handler.ContentHandler): self.textview.focus_out_line_pixbuf) #self._insert_text('\u2550'*40) self._jump_line() - except Exception, e: + except Exception as e: log.debug(str('Error in hr'+e)) elif name in LIST_ELEMS: self.list_counters.pop() diff --git a/src/notify.py b/src/notify.py index f2b8d5b11..a9ca09216 100644 --- a/src/notify.py +++ b/src/notify.py @@ -91,10 +91,10 @@ text=None, timeout=-1): DesktopNotification(event_type, jid, account, msg_type, path_to_image, title, GObject.markup_escape_text(text), timeout) return # sucessfully did D-Bus Notification procedure! - except dbus.DBusException, e: + except dbus.DBusException as e: # Connection to D-Bus failed gajim.log.debug(str(e)) - except TypeError, e: + except TypeError as e: # This means that we sent the message incorrectly gajim.log.debug(str(e)) @@ -129,7 +129,7 @@ text=None, timeout=-1): try: notification.show() return - except GObject.GError, e: + except GObject.GError as e: # Connection to notification-daemon failed, see #2893 gajim.log.debug(str(e)) @@ -397,7 +397,7 @@ class DesktopNotification: dbus.UInt32(self.timeout*1000), reply_handler=self.attach_by_id, error_handler=self.notify_another_way) - except Exception, e: + except Exception as e: self.notify_another_way(e) else: try: @@ -412,7 +412,7 @@ class DesktopNotification: dbus.UInt32(self.timeout*1000), reply_handler=self.attach_by_id, error_handler=self.notify_another_way) - except Exception, e: + except Exception as e: self.notify_another_way(e) def attach_by_id(self, id_): diff --git a/src/plugins/gui.py b/src/plugins/gui.py index 5f4a04213..ca4a63da0 100644 --- a/src/plugins/gui.py +++ b/src/plugins/gui.py @@ -196,7 +196,7 @@ class PluginsWindow(object): else: try: gajim.plugin_manager.activate_plugin(plugin) - except GajimPluginActivateException, e: + except GajimPluginActivateException as e: WarningDialog(_('Plugin failed'), str(e), transient_for=self.window) return @@ -241,7 +241,7 @@ class PluginsWindow(object): is_active = model.get_value(iter, ACTIVE) try: gajim.plugin_manager.remove_plugin(plugin) - except PluginsystemError, e: + except PluginsystemError as e: WarningDialog(_('Unable to properly remove the plugin'), str(e), self.window) return @@ -280,7 +280,7 @@ class PluginsWindow(object): def _try_install(zip_filename): try: plugin = gajim.plugin_manager.install_from_zip(zip_filename) - except PluginsystemError, er_type: + except PluginsystemError as er_type: error_text = str(er_type) if error_text == _('Plugin already exists'): _on_plugin_exists(zip_filename) diff --git a/src/plugins/pluginmanager.py b/src/plugins/pluginmanager.py index d9fce1295..4e7de9de2 100644 --- a/src/plugins/pluginmanager.py +++ b/src/plugins/pluginmanager.py @@ -302,7 +302,7 @@ class PluginManager(object): self.active_plugins.append(plugin) try: plugin.activate() - except GajimPluginException, e: + except GajimPluginException as e: self.deactivate_plugin(plugin) raise GajimPluginActivateException(str(e)) self._set_plugin_active_in_global_config(plugin) @@ -426,9 +426,9 @@ class PluginManager(object): module_name = os.path.splitext(elem_name)[0] try: module = __import__(module_name) - except ValueError, value_error: + except ValueError as value_error: log.debug(value_error) - except ImportError, import_error: + except ImportError as import_error: log.debug(import_error) elif os.path.isdir(file_path) and scan_dirs: @@ -439,9 +439,9 @@ class PluginManager(object): file_path += os.path.sep try: module = __import__(module_name) - except ValueError, value_error: + except ValueError as value_error: log.debug(value_error) - except ImportError, import_error: + except ImportError as import_error: log.debug(import_error) @@ -477,21 +477,21 @@ class PluginManager(object): plugins_found.append(module_attr) - except TypeError, type_error: + except TypeError as type_error: # set plugin localization try: module_attr._ = _ - except AttributeError, type_error: + except AttributeError as type_error: pass - except ConfigParser.NoOptionError, type_error: + except ConfigParser.NoOptionError as type_error: # all fields are required log.debug('%s : %s' % (module_attr_name, 'wrong manifest file. all fields are required!')) - except ConfigParser.NoSectionError, type_error: + except ConfigParser.NoSectionError as type_error: # info section are required log.debug('%s : %s' % (module_attr_name, 'wrong manifest file. info section are required!')) - except ConfigParser.MissingSectionHeaderError, type_error: + except ConfigParser.MissingSectionHeaderError as type_error: # info section are required log.debug('%s : %s' % (module_attr_name, 'wrong manifest file. section are required!')) @@ -504,10 +504,10 @@ class PluginManager(object): ''' try: zip_file = zipfile.ZipFile(zip_filename) - except zipfile.BadZipfile, e: + except zipfile.BadZipfile as e: # it is not zip file raise PluginsystemError(_('Archive corrupted')) - except IOError,e: + except IOError as e: raise PluginsystemError(_('Archive empty')) if zip_file.testzip(): diff --git a/src/plugins/plugins_i18n.py b/src/plugins/plugins_i18n.py index 769d8b060..9eb983eff 100644 --- a/src/plugins/plugins_i18n.py +++ b/src/plugins/plugins_i18n.py @@ -36,6 +36,6 @@ if os.name != 'nt': try: t = gettext.translation(APP, plugins_locale_dir) _ = t.gettext -except IOError, msg: +except IOError as msg: from common import i18n _ = gettext.gettext diff --git a/src/profile_window.py b/src/profile_window.py index 04d596294..614af3add 100644 --- a/src/profile_window.py +++ b/src/profile_window.py @@ -139,7 +139,7 @@ class ProfileWindow: # and hope that user did not specify in ACE crazy size scaled_pixbuf = gtkgui_helpers.get_scaled_pixbuf(pixbuf, 'tooltip') - except GObject.GError, msg: # unknown format + except GObject.GError as msg: # unknown format # msg should be string, not object instance msg = str(msg) invalid_file = True diff --git a/src/remote_control.py b/src/remote_control.py index a5d8cf115..b2a193d32 100644 --- a/src/remote_control.py +++ b/src/remote_control.py @@ -743,7 +743,7 @@ class SignalObject(dbus.service.Object): def prefs_store(self): try: gajim.interface.save_config() - except Exception, e: + except Exception as e: return DBUS_BOOLEAN(False) return DBUS_BOOLEAN(True) diff --git a/src/roster_window.py b/src/roster_window.py index a447f908f..f842027bd 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -3282,7 +3282,7 @@ class RosterWindow: # get the image at 'tooltip size' # and hope that user did not specify in ACE crazy size pixbuf = gtkgui_helpers.get_scaled_pixbuf(pixbuf, 'tooltip') - except GObject.GError, msg: # unknown format + except GObject.GError as msg: # unknown format # msg should be string, not object instance msg = str(msg) dialogs.ErrorDialog(_('Could not load image'), msg) diff --git a/src/session.py b/src/session.py index c43f5c930..eb3df3f19 100644 --- a/src/session.py +++ b/src/session.py @@ -90,7 +90,7 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession): msg_to_log = obj.msgtxt obj.msg_id = gajim.logger.write(log_type, obj.fjid, msg_to_log, tim=obj.timestamp, subject=obj.subject) - except exceptions.PysqliteOperationalError, e: + except exceptions.PysqliteOperationalError as e: gajim.nec.push_incoming_event(InformationEvent(None, conn=self.conn, level='error', pri_txt=_('Disk Write Error'), sec_txt=str(e))) @@ -423,7 +423,7 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession): 'submit': try: self.archiving_accepted(form) - except exceptions.NegotiationError, details: + except exceptions.NegotiationError as details: self.fail_bad_negotiation(details) return @@ -452,7 +452,7 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession): try: self.accept_e2e_alice(form, negotiated) - except exceptions.NegotiationError, details: + except exceptions.NegotiationError as details: self.fail_bad_negotiation(details) def reject_nondefault_options(): @@ -476,7 +476,7 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession): else: try: self.accept_e2e_alice(form, negotiated) - except exceptions.NegotiationError, details: + except exceptions.NegotiationError as details: self.fail_bad_negotiation(details) return @@ -484,21 +484,21 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession): 'result': try: self.we_accept_archiving(form) - except exceptions.NegotiationError, details: + except exceptions.NegotiationError as details: self.fail_bad_negotiation(details) return elif self.status == 'responded-e2e' and form.getType() == 'result': try: self.accept_e2e_bob(form) - except exceptions.NegotiationError, details: + except exceptions.NegotiationError as details: self.fail_bad_negotiation(details) return elif self.status == 'identified-alice' and form.getType() == 'result': try: self.final_steps_alice(form) - except exceptions.NegotiationError, details: + except exceptions.NegotiationError as details: self.fail_bad_negotiation(details) return diff --git a/test/integration/test_xmpp_transports_nb.py b/test/integration/test_xmpp_transports_nb.py index 98f2c87fc..9f7fb0d5d 100644 --- a/test/integration/test_xmpp_transports_nb.py +++ b/test/integration/test_xmpp_transports_nb.py @@ -72,7 +72,7 @@ class TestNonBlockingTCP(AbstractTransportTest): ips = socket.getaddrinfo('gajim.org', 5222, socket.AF_UNSPEC, socket.SOCK_STREAM) ip = ips[0] - except socket.error, e: + except socket.error as e: self.testcase.fail(msg=str(e)) self.socket = transports_nb.NonBlockingTCP( diff --git a/test/runtests.py b/test/runtests.py index e199b9052..9686f6683 100755 --- a/test/runtests.py +++ b/test/runtests.py @@ -17,7 +17,7 @@ try: shortargs = 'hnv:' longargs = 'help no-x verbose=' opts, args = getopt.getopt(sys.argv[1:], shortargs, longargs.split()) -except getopt.error, msg: +except getopt.error as msg: print(msg) print('for help use --help') sys.exit(2)