From: Oleg Broytman Date: Mon, 25 Jul 2016 16:05:26 +0000 (+0300) Subject: Use "exception as value" for Py3 compatibility X-Git-Tag: 3.0.0b1~10 X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=c0a3ca4a622dadfa767404da3c366443bab0f791;p=m_lib.git Use "exception as value" for Py3 compatibility --- diff --git a/m_lib/defenc.py b/m_lib/defenc.py index 43b102f..776b78d 100755 --- a/m_lib/defenc.py +++ b/m_lib/defenc.py @@ -16,7 +16,7 @@ if use_locale: # Get the default charset. try: lcAll = locale.getdefaultlocale() - except locale.Error, err: + except locale.Error as err: print("WARNING:", err, file=sys.stderr) lcAll = [] @@ -25,7 +25,7 @@ if use_locale: else: try: default_encoding = locale.getpreferredencoding() - except locale.Error, err: + except locale.Error as err: print("WARNING:", err, file=sys.stderr) default_encoding = sys.getdefaultencoding() else: diff --git a/m_lib/net/ftp/ftpscan.py b/m_lib/net/ftp/ftpscan.py index 5eeb1d2..f12ef3e 100755 --- a/m_lib/net/ftp/ftpscan.py +++ b/m_lib/net/ftp/ftpscan.py @@ -94,7 +94,7 @@ def _traverse_ftp(ftp, tree, ftp_dir): get_files = GetFiles() try: ftp.dir(get_files) - except ftplib.all_errors, msg: + except ftplib.all_errors as msg: tree.append((ftpscan_error_mark, "Cannot list directory `%s': %s" % (ftp_dir, msg))) return files = get_files.files() @@ -110,11 +110,11 @@ def _traverse_ftp(ftp, tree, ftp_dir): full_path = ftp_dir + '/' + name try: ftp.cwd(name) - except ftplib.error_perm, msg: + except ftplib.error_perm as msg: tree.append((ftpscan_error_mark, "Cannot enter directory `%s': %s" % (full_path, msg))) if isinstance(ftp, ReconnectingFTPWrapper): ftp.cwd("..", False) - except ftplib.all_errors, msg: + except ftplib.all_errors as msg: tree.append((ftpscan_error_mark, "Cannot enter directory `%s': %s" % (full_path, msg))) else: _traverse_ftp(ftp, tree, full_path) @@ -272,7 +272,7 @@ if __name__ == "__main__": print("Scanning", ftp_server) try: test(ftp_server, ftpscanrecursive, passive) - except FtpScanError, msg: + except FtpScanError as msg: print("Rescanning due to the error:", msg) try: test(ftp_server, ftpscan1, passive)