docker-offlineimap/offlineimap
Thomas De Schampheleire 58d34df29f imapserver: fix exception handling in xoauth2handler
In case of an exception in XOAUTH2 code refresh (HTTP Error 400: Bad
Request), following exception occurs:

ERROR: While attempting to sync account 'xxx'
  __init__() missing 3 required positional arguments: 'msg', 'hdrs', and 'fp'

Traceback:
  File ".../offlineimap3/offlineimap/accounts.py", line 298, in syncrunner
    self.__sync()
  File ".../offlineimap3/offlineimap/accounts.py", line 374, in __sync
    remoterepos.getfolders()
  File ".../offlineimap3/offlineimap/repository/IMAP.py", line 648, in getfolders
    imapobj = self.imapserver.acquireconnection()
  File ".../offlineimap3/offlineimap/imapserver.py", line 591, in acquireconnection
    self.__authn_helper(imapobj)
  File ".../offlineimap3/offlineimap/imapserver.py", line 448, in __authn_helper
    if func(imapobj):
  File ".../offlineimap3/offlineimap/imapserver.py", line 382, in __authn_xoauth2
    imapobj.authenticate('XOAUTH2', self.__xoauth2handler)
  File ".../offlineimap3/venv/lib/python3.7/site-packages/imaplib2.py", line 682, in authenticate
    typ, dat = self._simple_command('AUTHENTICATE', mechanism.upper())
  File ".../offlineimap3/venv/lib/python3.7/site-packages/imaplib2.py", line 1675, in _simple_command
    return self._command_complete(self._command(name, *args), kw)
  File ".../offlineimap3/venv/lib/python3.7/site-packages/imaplib2.py", line 1395, in _command
    literal = literator(data, rqb)
  File ".../offlineimap3/venv/lib/python3.7/site-packages/imaplib2.py", line 2238, in process
    ret = self.mech(self.decode(data))
  File ".../offlineimap3/offlineimap/imapserver.py", line 257, in __xoauth2handler
    raise type(e)(msg, exc_info()[2])

The exception 'e' is of type HTTPError, which does not have the same kind of
constructor as normal Python exceptions.

Instead, print the constructed message and just raise the existing
exception.

With that change, the same condition triggers another problem further on:

ERROR: While attempting to sync account 'xxx'
  tuple index out of range

Traceback:
  File ".../offlineimap3/offlineimap/accounts.py", line 298, in syncrunner
    self.__sync()
  File ".../offlineimap3/offlineimap/accounts.py", line 374, in __sync
    remoterepos.getfolders()
  File ".../offlineimap3/offlineimap/repository/IMAP.py", line 648, in getfolders
    imapobj = self.imapserver.acquireconnection()
  File ".../offlineimap3/offlineimap/imapserver.py", line 664, in acquireconnection
    elif isinstance(e, socket.error) and e.args[0] == errno.ECONNREFUSED:

because e.args is empty.
2021-01-04 10:26:01 +01:00
..
folder Avoid crash in search if no results 2020-11-08 22:07:14 +01:00
repository foldersort broken with instance comparison 2020-12-30 21:49:19 +01:00
ui ui/UIBase.py do not use builtin object as variable 2020-08-30 18:12:17 +02:00
utils distro_utils.py renamed variable f 2020-11-01 08:31:47 +01:00
__init__.py Reformat offlineimap/__init__.py 2020-08-29 20:04:40 +02:00
accounts.py accounts: decode output of hooks 2020-10-12 09:01:59 +02:00
CustomConfig.py six: changed offlineimap/CustomConfig.py 2020-09-03 21:35:54 +02:00
emailutil.py emailutil.py updated docstrings 2020-08-30 18:21:00 +02:00
error.py Reformat offlineimap/error.py 2020-08-29 20:15:55 +02:00
globals.py Reformat offlineimap/globals.py 2020-08-29 20:16:35 +02:00
imaplibutil.py BUG: offlineimap3 fails with tunneled connections 2020-12-28 18:54:53 +01:00
imapserver.py imapserver: fix exception handling in xoauth2handler 2021-01-04 10:26:01 +01:00
imaputil.py Allow folder names with atom specials 2020-10-11 23:01:08 +02:00
init.py removed virtual_imaplib2 2020-08-31 16:24:26 +02:00
localeval.py localeval.py removed extra parenthesys 2020-08-30 18:52:56 +02:00
mbnames.py mbnames.py removed extra parenthesys 2020-08-30 18:53:02 +02:00
threadutil.py Removed doxygen param 2020-10-10 14:50:47 +02:00