invasive patch to drop support for Python 2.5, part 02/03
Stephen Gildea <[email protected]> Thu, 04 Nov 2021 01:36:55 -0700
| Newsgroups | gmane.mail.getmail.user |
|---|---|
| Message-ID | <1687765.1636015015@pental> |
02-getmail-except-as-1of2.patch
(text/x-diff, 21.9 KB)
diff -ur getmail-5.16-for-python-2.6/getmail getmail-5.16-except-as-and-2.6/getmail
--- getmail-5.16-for-python-2.6/getmail 2021-11-03 09:49:03.140267922 -0700
+++ getmail-5.16-except-as-and-2.6/getmail 2021-11-01 23:10:25.169896543 -0700
@@ -59,7 +59,7 @@
from getmailcore.exceptions import *
from getmailcore.utilities import eval_bool, logfile, format_params, \
address_no_brackets, expand_user_vars, get_password, run_command
-except ImportError, o:
+except ImportError as o:
sys.stderr.write('ImportError: %s\n' % o)
sys.exit(127)
@@ -164,7 +164,7 @@
% mailbox.encode('utf-8'))
try:
retriever.select_mailbox(mailbox)
- except getmailMailboxSelectError, o:
+ except getmailMailboxSelectError as o:
errorexit = True
log.info(' mailbox %s not selectable (%s) - verify the '
'mailbox exists and you have sufficient '
@@ -198,7 +198,7 @@
if retrieve:
try:
msg = retriever.getmsg(msgid)
- except getmailRetrievalError, o:
+ except getmailRetrievalError as o:
errorexit = True
log.error(
'Retrieval error: server for %s is broken; '
@@ -285,7 +285,7 @@
info += ', deleted'
logline += ', deleted'
- except getmailDeliveryError, o:
+ except getmailDeliveryError as o:
errorexit = True
log.error('Delivery error (%s)\n' % o)
info += ', delivery error (%s)' % o
@@ -295,7 +295,7 @@
syslog.syslog(syslog.LOG_ERR,
'Delivery error (%s)' % o)
- except getmailFilterError, o:
+ except getmailFilterError as o:
errorexit = True
log.error('Filter error (%s)\n' % o)
info += ', filter error (%s)' % o
@@ -327,12 +327,12 @@
except StopIteration:
pass
- except KeyboardInterrupt, o:
+ except KeyboardInterrupt as o:
log.warning('%s: user aborted\n' % configfile)
if options['logfile']:
options['logfile'].write('user aborted')
- except socket.timeout, o:
+ except socket.timeout as o:
errorexit = True
retriever.abort()
if type(o) == tuple and len(o) > 1:
@@ -341,14 +341,14 @@
if options['logfile']:
options['logfile'].write('timeout error (%s)' % o)
- except (poplib.error_proto, imaplib.IMAP4.abort), o:
+ except (poplib.error_proto, imaplib.IMAP4.abort) as o:
errorexit = True
retriever.abort()
log.error('%s: protocol error (%s)\n' % (configfile, o))
if options['logfile']:
options['logfile'].write('protocol error (%s)' % o)
- except socket.gaierror, o:
+ except socket.gaierror as o:
errorexit = True
retriever.abort()
if type(o) == tuple and len(o) > 1:
@@ -357,7 +357,7 @@
if options['logfile']:
options['logfile'].write('gaierror error (%s)' % o)
- except socket.error, o:
+ except socket.error as o:
errorexit = True
retriever.abort()
if type(o) == tuple and len(o) > 1:
@@ -366,20 +366,20 @@
if options['logfile']:
options['logfile'].write('socket error (%s)' % o)
- except getmailCredentialError, o:
+ except getmailCredentialError as o:
errorexit = True
retriever.abort()
log.error('%s: credential/login error (%s)\n' % (configfile, o))
if options['logfile']:
options['logfile'].write('credential/login error (%s)' % o)
- except getmailLoginRefusedError, o:
+ except getmailLoginRefusedError as o:
retriever.abort()
log.error('%s: login refused error (%s)\n' % (configfile, o))
if options['logfile']:
options['logfile'].write('login refused error (%s)' % o)
- except getmailOperationError, o:
+ except getmailOperationError as o:
errorexit = True
retriever.abort()
log.error('%s: operation error (%s)\n' % (configfile, o))
@@ -435,13 +435,13 @@
retriever.set_new_timestamp()
configs.append(configs[0])
continue
- except KeyboardInterrupt, o:
+ except KeyboardInterrupt as o:
# Because configs isn't appended to, this just means we'll
# quit, which is presumably what the user wanted
# The newline is to clear the ^C shown in terminal
log.info('\n')
pass
- except socket.error, o:
+ except socket.error as o:
if o.errno != errno.ECONNRESET:
# Something unexpected happened
raise
@@ -449,7 +449,7 @@
# Just exit after a reset connection.
retriever.quit()
- except getmailOperationError, o:
+ except getmailOperationError as o:
errorexit = True
log.debug('%s: operation error during quit (%s)\n'
% (configfile, o))
@@ -690,7 +690,7 @@
if config['message_log']:
try:
config['logfile'] = logfile(config['message_log'])
- except IOError, o:
+ except IOError as o:
raise getmailConfigurationError(
'error opening message_log file %s (%s)'
% (config['message_log'], o)
@@ -745,7 +745,7 @@
log.debug(' checking retriever configuration for %s\n'
% retriever)
retriever.checkconf()
- except getmailOperationError, o:
+ except getmailOperationError as o:
log.error('Error initializing retriever: %s\n' % o)
continue
@@ -847,22 +847,22 @@
mail_filter = filter_func(**filter_args)
_filters.append(mail_filter)
- except ConfigParser.NoSectionError, o:
+ except ConfigParser.NoSectionError as o:
raise getmailConfigurationError(
'configuration file %s missing section (%s)' % (path, o)
)
- except ConfigParser.NoOptionError, o:
+ except ConfigParser.NoOptionError as o:
raise getmailConfigurationError(
'configuration file %s missing option (%s)' % (path, o)
)
except (ConfigParser.DuplicateSectionError,
ConfigParser.InterpolationError,
ConfigParser.MissingSectionHeaderError,
- ConfigParser.ParsingError), o:
+ ConfigParser.ParsingError) as o:
raise getmailConfigurationError(
'configuration file %s incorrect (%s)' % (path, o)
)
- except getmailConfigurationError, o:
+ except getmailConfigurationError as o:
raise getmailConfigurationError(
'configuration file %s incorrect (%s)' % (path, o)
)
@@ -919,13 +919,13 @@
except KeyboardInterrupt:
log.warning('Operation aborted by user (keyboard interrupt)\n')
sys.exit(0)
- except getmailConfigurationError, o:
+ except getmailConfigurationError as o:
log.error('Configuration error: %s\n' % o)
sys.exit(2)
- except getmailOperationError, o:
+ except getmailOperationError as o:
log.error('Error: %s\n' % o)
sys.exit(3)
- except StandardError, o:
+ except StandardError as o:
log.critical(
'\nException: please read docs/BUGS and include the '
'following information in any bug report:\n\n'
diff -ur getmail-5.16-for-python-2.6/getmail_fetch getmail-5.16-except-as-and-2.6/getmail_fetch
--- getmail-5.16-for-python-2.6/getmail_fetch 2021-11-03 09:49:03.140267922 -0700
+++ getmail-5.16-except-as-and-2.6/getmail_fetch 2021-11-01 23:10:15.753830642 -0700
@@ -11,7 +11,7 @@
from getmailcore import __version__, retrievers, destinations, message, \
logging
from getmailcore.exceptions import *
-except ImportError, o:
+except ImportError as o:
sys.stderr.write('ImportError: %s\n' % o)
sys.exit(127)
@@ -64,30 +64,30 @@
log.info(', deleted')
log.info('\n')
- except getmailDeliveryError, o:
+ except getmailDeliveryError as o:
error_exit(7, 'Delivery error: %s' % o)
try:
retriever.quit()
- except getmailOperationError, o:
+ except getmailOperationError as o:
log.warning('Operation error during quit (%s)\n' % o)
- except socket.timeout, o:
+ except socket.timeout as o:
error_exit(8, 'Timeout error: %s' % o)
- except socket.gaierror, o:
+ except socket.gaierror as o:
error_exit(9, 'gaierror: %s' % o)
- except socket.error, o:
+ except socket.error as o:
error_exit(10, 'Socket error: %s' % o)
- except poplib.error_proto, o:
+ except poplib.error_proto as o:
error_exit(11, 'Protocol error: %s' % o)
- except getmailCredentialError, o:
+ except getmailCredentialError as o:
error_exit(13, 'Credential error: %s' % o)
- except getmailOperationError, o:
+ except getmailOperationError as o:
error_exit(12, 'Operational error: %s' % o)
log.info('%d messages retrieved\n' % msgs_retrieved)
@@ -138,7 +138,7 @@
try:
f = open(options.message, 'rb')
msg = message.Message(fromfile=f)
- except IOError, o:
+ except IOError as o:
error_exit(
1,
'Error reading message file "%s": %s' % (options.message, o)
@@ -166,7 +166,7 @@
try:
retriever = retriever_func(**retriever_args)
retriever.checkconf()
- except getmailOperationError, o:
+ except getmailOperationError as o:
error_exit(3, 'Error initializing retriever: %s' % o)
# Destination
@@ -200,7 +200,7 @@
try:
destination = destination_func(**destination_args)
- except getmailOperationError, o:
+ except getmailOperationError as o:
error_exit(
5, 'Error initializing destination "%s": %s' % (destination, o)
)
@@ -209,11 +209,11 @@
except KeyboardInterrupt:
error_exit(6, 'Operation aborted by user (keyboard interrupt)')
- except getmailOperationError, o:
+ except getmailOperationError as o:
error_exit(7, 'Operation error: %s' % o)
- except getmailConfigurationError, o:
+ except getmailConfigurationError as o:
error_exit(8, 'Configuration error: %s' % o)
- except StandardError, o:
+ except StandardError as o:
log.critical('\nException: please read docs/BUGS and include the '
'following information in any bug report:\n\n')
log.critical(' getmail_fetch version %s\n' % __version__)
diff -ur getmail-5.16-for-python-2.6/getmail_maildir getmail-5.16-except-as-and-2.6/getmail_maildir
--- getmail-5.16-for-python-2.6/getmail_maildir 2021-11-03 09:49:03.140267922 -0700
+++ getmail-5.16-except-as-and-2.6/getmail_maildir 2021-11-01 23:10:11.009797441 -0700
@@ -59,10 +59,10 @@
try:
d = deliver_maildir(path, msg.flatten(True, False), hostname)
-except getmailDeliveryError, o:
+except getmailDeliveryError as o:
raise SystemExit('Error: delivery error delivering to maildir %s (%s)'
% (path, o))
-except StandardError, o:
+except StandardError as o:
raise SystemExit('Error: other error delivering to maildir %s (%s)'
% (path, o))
diff -ur getmail-5.16-for-python-2.6/getmail_mbox getmail-5.16-except-as-and-2.6/getmail_mbox
--- getmail-5.16-for-python-2.6/getmail_mbox 2021-11-03 09:49:03.140267922 -0700
+++ getmail-5.16-except-as-and-2.6/getmail_mbox 2021-11-01 23:10:49.242064836 -0700
@@ -63,10 +63,10 @@
try:
dest = destinations.Mboxrd(path=path)
d = dest.deliver_message(msg, True, False)
-except getmailDeliveryError, o:
+except getmailDeliveryError as o:
raise SystemExit('Error: delivery error delivering to mboxrd %s (%s)'
% (path, o))
-except StandardError, o:
+except StandardError as o:
raise SystemExit('Error: other error delivering to mboxrd %s (%s)'
% (path, o))
diff -ur getmail-5.16-for-python-2.6/getmailcore/baseclasses.py getmail-5.16-except-as-and-2.6/getmailcore/baseclasses.py
--- getmail-5.16-for-python-2.6/getmailcore/baseclasses.py 2021-11-03 09:49:03.140267922 -0700
+++ getmail-5.16-except-as-and-2.6/getmailcore/baseclasses.py 2021-11-01 23:04:17.819304012 -0700
@@ -71,7 +71,7 @@
val = eval_bool(val)
else:
val = self.dtype(eval(val))
- except (ValueError, SyntaxError, TypeError), o:
+ except (ValueError, SyntaxError, TypeError) as o:
raise getmailConfigurationError(
'%s: configuration value (%s) not of required type %s (%s)'
% (self.name, val, self.dtype, o)
@@ -108,7 +108,7 @@
if type(tup) != tuple:
raise ValueError('not a tuple')
val = tup
- except (ValueError, SyntaxError), o:
+ except (ValueError, SyntaxError) as o:
raise getmailConfigurationError(
'%s: incorrect format (%s)' % (self.name, o)
)
@@ -137,13 +137,13 @@
item = str(item)
try:
vals.append(item.decode('ascii'))
- except UnicodeError, o:
+ except UnicodeError as o:
try:
vals.append(item.decode('utf-8'))
- except UnicodeError, o:
+ except UnicodeError as o:
raise ValueError('not ascii or utf-8: %s' % item)
val = vals
- except (ValueError, SyntaxError), o:
+ except (ValueError, SyntaxError) as o:
raise getmailConfigurationError(
'%s: incorrect format (%s)' % (self.name, o)
)
@@ -162,7 +162,7 @@
if type(tup) != tuple:
raise ValueError('not a tuple')
val = tup
- except (ValueError, SyntaxError), o:
+ except (ValueError, SyntaxError) as o:
raise getmailConfigurationError(
'%s: incorrect format (%s)' % (self.name, o)
)
@@ -255,7 +255,7 @@
# Reset atime and mtime
try:
os.utime(val, (status_old.st_atime, status_old.st_mtime))
- except OSError, o:
+ except OSError as o:
# Not root or owner; readers will not be able to reliably
# detect new mail. But you shouldn't be delivering to
# other peoples' mboxes unless you're root, anyways.
@@ -345,7 +345,7 @@
self.log.trace('handler called for signal %s' % sig)
try:
pid, r = os.wait()
- except OSError, o:
+ except OSError as o:
# No children on SIGCHLD. Can't happen?
self.log.warning('handler called, but no children (%s)' % o)
return
diff -ur getmail-5.16-for-python-2.6/getmailcore/destinations.py getmail-5.16-except-as-and-2.6/getmailcore/destinations.py
--- getmail-5.16-for-python-2.6/getmailcore/destinations.py 2021-11-03 09:49:03.140267922 -0700
+++ getmail-5.16-except-as-and-2.6/getmailcore/destinations.py 2021-11-01 23:04:17.815303983 -0700
@@ -74,7 +74,7 @@
ConfigurableBase.__init__(self, **args)
try:
self.initialize()
- except KeyError, o:
+ except KeyError as o:
raise getmailConfigurationError(
'missing required configuration parameter %s' % o
)
@@ -120,7 +120,7 @@
self.dcount = 0
try:
self.conf['filemode'] = int(self.conf['filemode'], 8)
- except ValueError, o:
+ except ValueError as o:
raise getmailConfigurationError('filemode %s not valid: %s'
% (self.conf['filemode'], o))
@@ -155,7 +155,7 @@
stdout.flush()
os.fsync(stdout.fileno())
os._exit(0)
- except StandardError, o:
+ except StandardError as o:
# Child process; any error must cause us to exit nonzero for parent
# to detect it
stderr.write('maildir delivery process failed (%s)' % o)
@@ -296,7 +296,7 @@
try:
os.utime(self.conf['path'], (status_old.st_atime,
status_new.st_mtime))
- except OSError, o:
+ except OSError as o:
# Not root or owner; readers will not be able to reliably
# detect new mail. But you shouldn't be delivering to
# other peoples' mboxes unless you're root, anyways.
@@ -306,7 +306,7 @@
unlock_file(f, self.conf['locktype'])
- except IOError, o:
+ except IOError as o:
try:
if not f.closed:
# If the file was opened and we know how long it was,
@@ -325,7 +325,7 @@
os._exit(0)
- except StandardError, o:
+ except StandardError as o:
# Child process; any error must cause us to exit nonzero for parent
# to detect it
stderr.write('mbox delivery process failed (%s)' % o)
@@ -512,7 +512,7 @@
)
os.execl(*args)
- except StandardError, o:
+ except StandardError as o:
# Child process; any error must cause us to exit nonzero for parent
# to detect it
stderr.write('exec of qmail-local failed (%s)' % o)
@@ -705,7 +705,7 @@
args.append(arg)
self.log.debug('about to execl() with args %s\n' % str(args))
os.execl(*args)
- except StandardError, o:
+ except StandardError as o:
# Child process; any error must cause us to exit nonzero for parent
# to detect it
stderr.write('exec of command %s failed (%s)'
@@ -857,7 +857,7 @@
for item in dests:
try:
dest = self._get_destination(item)
- except getmailConfigurationError, o:
+ except getmailConfigurationError as o:
raise getmailConfigurationError('%s destination error %s'
% (item, o))
self._destinations.append(dest)
@@ -914,13 +914,13 @@
for (pattern, path) in _locals:
try:
dest = self._get_destination(path)
- except getmailConfigurationError, o:
+ except getmailConfigurationError as o:
raise getmailConfigurationError(
'pattern %s destination error %s' % (pattern, o)
)
self.targets.append((re.compile(pattern, re.IGNORECASE), dest))
self._destinations.append(dest)
- except re.error, o:
+ except re.error as o:
raise getmailConfigurationError('invalid regular expression %s' % o)
def _confstring(self):
diff -ur getmail-5.16-for-python-2.6/getmailcore/filters.py getmail-5.16-except-as-and-2.6/getmailcore/filters.py
--- getmail-5.16-for-python-2.6/getmailcore/filters.py 2021-11-03 09:49:03.140267922 -0700
+++ getmail-5.16-except-as-and-2.6/getmailcore/filters.py 2021-11-01 23:04:17.815303983 -0700
@@ -63,7 +63,7 @@
ConfigurableBase.__init__(self, **args)
try:
self.initialize()
- except KeyError, o:
+ except KeyError as o:
raise getmailConfigurationError(
'missing required configuration parameter %s' % o
)
@@ -203,7 +203,7 @@
frozenset(self.exitcodes_drop)
):
raise getmailConfigurationError('exitcode sets intersect')
- except ValueError, o:
+ except ValueError as o:
raise getmailConfigurationError('invalid exit code specified (%s)'
% o)
@@ -242,7 +242,7 @@
# message passed to the filter.
#self.log.debug('about to execl() with args %s\n' % str(args))
os.execl(*args)
- except StandardError, o:
+ except StandardError as o:
# Child process; any error must cause us to exit nonzero for parent
# to detect it
self.log.critical('exec of filter %s failed (%s)'
@@ -439,7 +439,7 @@
',EXT="%(EXT)s"' % os.environ)
self.log.debug('about to execl() with args %s\n' % str(args))
os.execl(*args)
- except StandardError, o:
+ except StandardError as o:
# Child process; any error must cause us to exit nonzero for parent
# to detect it
self.log.critical('exec of filter %s failed (%s)'