#982829 offlineimap3: local variable 'msg' referenced before assignment

#982829#5
Date:
2021-02-14 23:58:42 UTC
From:
To:
Dear Maintainer,

In a situation where the IMAP server is unreachable for some reason,
offlineimap attempts to log a message describing the problem, but instead
seems to encounter a coding error in offlineimap itself.

The logs involved are:

 *** Processing account example
 Establishing connection to imap.example.com:993 (Remote)
 ERROR: While attempting to sync account 'example'
  local variable 'msg' referenced before assignment
 *** Finished account 'example' in 2:09

I have not investigated further, but will try when I get time.

Thanks for maintaining offlineimap!

noah

#982829#10
Date:
2021-02-15 09:30:48 UTC
From:
To:
Hi Noah,

Can you please try to do the same with -dALL as an offlineimap cmdline
argument which might give more logs.

#982829#15
Date:
2021-03-04 18:54:45 UTC
From:
To:
OfflineIMAP 7.3.0
  Licensed under the GNU GPL v2 or any later version (with an OpenSSL exception)
imaplib2 v3.05, Python v3.9.1+, OpenSSL 1.1.1j  16 Feb 2021
Now debugging for imap: IMAP protocol debugging
Now debugging for maildir: Maildir repository debugging
Now debugging for thread: Threading debugging
Now debugging for : Other offlineimap related sync messages
Account sync my_imap:
 [thread]: Register new thread 'Account sync my_imap' (account 'my_imap')
 [imap]: Using authentication mechanisms ['GSSAPI', 'XOAUTH2', 'CRAM-MD5', 'PLAIN', 'LOGIN']
 [maildir]: MaildirRepository initialized, sep is '.'
 *** Processing account my_imap
 Establishing connection to imap.example.com:993 (Remote)
 [imap]: Remote: level 'tls_compat', version 'None'
 [imap]:   51:42.31 Account sync my_imap imaplib2 version 3.05
 [imap]:   51:42.31 Account sync my_imap imaplib2 debug level 5, buffer level 3
 ERROR: While attempting to sync account 'my_imap'
  local variable 'msg' referenced before assignment
 ['  File "/usr/share/offlineimap3/offlineimap/accounts.py", line 298, in syncrunner\n    self.__sync()\n', '  File "/usr/share/offlineimap3/offlineimap/accounts.py", line 374, in __sync\n    remoterepos.getfolders()\n', '  File "/usr/share/offlineimap3/offlineimap/repository/IMAP.py", line 667, in getfolders\n    imapobj = self.imapserver.acquireconnection()\n', '  File "/usr/share/offlineimap3/offlineimap/imapserver.py", line 560, in acquireconnection\n    imapobj = imaplibutil.WrappedIMAP4_SSL(\n', '  File "/usr/share/offlineimap3/offlineimap/imaplibutil.py", line 191, in __init__\n    super(WrappedIMAP4_SSL, self).__init__(*args, **kwargs)\n', '  File "/usr/lib/python3/dist-packages/imaplib2.py", line 2103, in __init__\n    IMAP4.__init__(self, host, port, debug, debug_file, identifier, timeout, debug_buf_lvl)\n', '  File "/usr/lib/python3/dist-packages/imaplib2.py", line 336, in __init__\n    self.open(host, port)\n', '  File "/usr/share/offlineimap3/offlineimap/imaplibutil.py", line 199, in open\n    super(WrappedIMAP4_SSL, self).open(host, port)\n', '  File "/usr/lib/python3/dist-packages/imaplib2.py", line 2115, in open\n    self.sock = self.open_socket()\n', '  File "/usr/share/offlineimap3/offlineimap/imaplibutil.py", line 100, in open_socket\n    raise socket.error(msg)\n']
 *** Finished account 'my_imap' in 0:00
[thread]: Unregister thread 'Account sync my_imap'
ERROR: Exceptions occurred during the run!
ERROR: While attempting to sync account 'my_imap'
  local variable 'msg' referenced before assignment

Traceback:
  File "/usr/share/offlineimap3/offlineimap/accounts.py", line 298, in syncrunner
    self.__sync()
  File "/usr/share/offlineimap3/offlineimap/accounts.py", line 374, in __sync
    remoterepos.getfolders()
  File "/usr/share/offlineimap3/offlineimap/repository/IMAP.py", line 667, in getfolders
    imapobj = self.imapserver.acquireconnection()
  File "/usr/share/offlineimap3/offlineimap/imapserver.py", line 560, in acquireconnection
    imapobj = imaplibutil.WrappedIMAP4_SSL(
  File "/usr/share/offlineimap3/offlineimap/imaplibutil.py", line 191, in __init__
    super(WrappedIMAP4_SSL, self).__init__(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/imaplib2.py", line 2103, in __init__
    IMAP4.__init__(self, host, port, debug, debug_file, identifier, timeout, debug_buf_lvl)
  File "/usr/lib/python3/dist-packages/imaplib2.py", line 336, in __init__
    self.open(host, port)
  File "/usr/share/offlineimap3/offlineimap/imaplibutil.py", line 199, in open
    super(WrappedIMAP4_SSL, self).open(host, port)
  File "/usr/lib/python3/dist-packages/imaplib2.py", line 2115, in open
    self.sock = self.open_socket()
  File "/usr/share/offlineimap3/offlineimap/imaplibutil.py", line 100, in open_socket
    raise socket.error(msg)