OfflineIMAP / offlineimap3

Read/sync your IMAP mailboxes (python3)
Other
455 stars 64 forks source link

IMAP4 protocol error: <class 'TypeError'> #100

Open mrfuton opened 3 years ago

mrfuton commented 3 years ago

General informations

Configuration file offlineimaprc

[general]
accounts = gmx

[Account gmx]
localrepository = gmx-local
remoterepository = gmx-remote

[Repository gmx-local]
type = Maildir
localfolders = ~/.gmx/Mail

[Repository gmx-remote]
type = IMAP
#added for troubleshooting, didn't work with "yes" either
starttls = no
#added for troubleshooting
ssl = yes
remotehost = imap.gmx.com
remoteport = 993
remoteuser = XXXXX@gmx.com
#not sure why offlineimap wouldn't use the system ca certs, but I had to add this manually
sslcacertfile = ~/.gmx/global-root-ca-chain-demos-digicert-com.pem
#added for troubleshooting, tried various options here, no difference
auth_mechanisms = GSSAPI, XOAUTH2, CRAM-MD5, PLAIN, LOGIN

Logs, error

$ offlineimap -d imap
OfflineIMAP 7.3.4
  Licensed under the GNU GPL v2 or any later version (with an OpenSSL exception)
imaplib2 v2.101 (bundled), Python v3.8.12, OpenSSL 1.1.1l  24 Aug 2021
Debug mode: Forcing to singlethreaded.
Now debugging for imap: IMAP protocol debugging
Now debugging for : Other offlineimap related sync messages
Account sync gmx:
 [imap]: Using authentication mechanisms ['GSSAPI', 'XOAUTH2', 'CRAM-MD5', 'PLAIN', 'LOGIN']
 *** Processing account gmx
 Establishing connection to imap.gmx.com:993 (gmx-remote)
 [imap]: gmx-remote: level 'tls_compat', version 'None'
 ERROR: While attempting to sync account 'gmx'
  IMAP4 protocol error: program error: <class 'TypeError'> - cannot use a bytes pattern on a string-like object
 ['  File "/usr/local/lib/python3.8/site-packages/offlineimap/accounts.py", line 293, in syncrunner\n    self.__sync()\n', '  File "/usr/local/lib/python3.8/site-packages/offlineimap/accounts.py", line 372, in __sync\n    remoterepos.getfolders()\n', '  File "/usr/local/lib/python3.8/site-packages/offlineimap/repository/IMAP.py", line 452, in getfolders\n    imapobj = self.imapserver.acquireconnection()\n', '  File "/usr/local/lib/python3.8/site-packages/offlineimap/imapserver.py", line 557, in acquireconnection\n    imapobj = imaplibutil.WrappedIMAP4_SSL(\n', '  File "/usr/local/lib/python3.8/site-packages/offlineimap/imaplibutil.py", line 202, in __init__\n    super(WrappedIMAP4_SSL, self).__init__(*args, **kwargs)\n', '  File "/usr/local/lib/python3.8/site-packages/offlineimap/bundled_imaplib2.py", line 2191, in __init__\n    IMAP4.__init__(self, host, port, debug, debug_file, identifier, timeout, debug_buf_lvl)\n', '  File "/usr/local/lib/python3.8/site-packages/offlineimap/bundled_imaplib2.py", line 399, in __init__\n    self.welcome = self._request_push(name=\'welcome\', tag=\'continuation\').get_response(\'IMAP4 protocol error: %s\')[1]\n', '  File "/usr/local/lib/python3.8/site-packages/offlineimap/bundled_imaplib2.py", line 200, in get_response\n    raise typ(exc_fmt % str(val))\n']
 *** Finished account 'gmx' in 0:00
 ERROR: Exceptions occurred during the run!
 ERROR: While attempting to sync account 'gmx'
  IMAP4 protocol error: program error: <class 'TypeError'> - cannot use a bytes pattern on a string-like object

Traceback:
  File "/usr/local/lib/python3.8/site-packages/offlineimap/accounts.py", line 293, in syncrunner
    self.__sync()
  File "/usr/local/lib/python3.8/site-packages/offlineimap/accounts.py", line 372, in __sync
    remoterepos.getfolders()
  File "/usr/local/lib/python3.8/site-packages/offlineimap/repository/IMAP.py", line 452, in getfolders
    imapobj = self.imapserver.acquireconnection()
  File "/usr/local/lib/python3.8/site-packages/offlineimap/imapserver.py", line 557, in acquireconnection
    imapobj = imaplibutil.WrappedIMAP4_SSL(
  File "/usr/local/lib/python3.8/site-packages/offlineimap/imaplibutil.py", line 202, in __init__
    super(WrappedIMAP4_SSL, self).__init__(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/offlineimap/bundled_imaplib2.py", line 2191, in __init__
    IMAP4.__init__(self, host, port, debug, debug_file, identifier, timeout, debug_buf_lvl)
  File "/usr/local/lib/python3.8/site-packages/offlineimap/bundled_imaplib2.py", line 399, in __init__
    self.welcome = self._request_push(name='welcome', tag='continuation').get_response('IMAP4 protocol error: %s')[1]
  File "/usr/local/lib/python3.8/site-packages/offlineimap/bundled_imaplib2.py", line 200, in get_response
    raise typ(exc_fmt % str(val))

Additional notes

mrfuton commented 3 years ago

This reports the same issue: https://github.com/OfflineIMAP/offlineimap/issues/472

This issue seems to be running the Py2 version of offlineimap in Py3. But I installed via pip3 install offlineimap, and it's explicitly calling Python 3.8:

$ head -1 /usr/local/bin/offlineimap
#!/usr/bin/python3.8

so not sure what's going on?

thekix commented 3 years ago

Hi @mrfuton

Please, could you try to run the version 8.0.0 and check if the problem already exists?

Thanks a lot, Best regards, kix

liovbt commented 2 years ago

I had the exact same error and stack trace with OfflineIMAP 7.3.4. Then tried with 8.0.0 and it seems to be fixed.

bitozoid commented 2 years ago

Same for me.

I installed via

pip install -v git+https://github.com/offlineIMAP/offlineimap3.git@v8.0.0

and then it worked fine.