OfflineIMAP / offlineimap3

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

office365 'tuple' object has no attribute 'decode' #108

Open myutkin opened 2 years ago

myutkin commented 2 years ago

That's the error I get. App version is 8.0.0. Forcing the string on line 112 gives another error, see below Please advise

ERROR: While attempting to sync account 'accountname' 'tuple' object has no attribute 'decode' [' File "/home/z/.local/lib/python3.8/site-packages/offlineimap/accounts.py", line 298, in syncrunner\n self.sync()\n', ' File "/home/z/.local/lib/python3.8/site-packages/offlineimap/accounts.py", line 374, in sync\n remoterepos.getfolders()\n', ' File "/home/z/.local/lib/python3.8/site-packages/offlineimap/repository/IMAP.py", line 704, in getfolders\n flags, delim, name = imaputil.imapsplit(fldr)\n', ' File "/home/z/.local/lib/python3.8/site-packages/offlineimap/imaputil.py", line 112, in imapsplit\n imapstring = imapstring.decode(\'utf-8\')\n'] *** Finished account 'accountname' in 0:02 ERROR: Exceptions occurred during the run! ERROR: While attempting to sync account 'accountname' 'tuple' object has no attribute 'decode'

Traceback: File "/home/z/.local/lib/python3.8/site-packages/offlineimap/accounts.py", line 298, in syncrunner self.sync() File "/home/z/.local/lib/python3.8/site-packages/offlineimap/accounts.py", line 374, in sync remoterepos.getfolders() File "/home/z/.local/lib/python3.8/site-packages/offlineimap/repository/IMAP.py", line 704, in getfolders flags, delim, name = imaputil.imapsplit(fldr) File "/home/z/.local/lib/python3.8/site-packages/offlineimap/imaputil.py", line 112, in imapsplit imapstring = imapstring.decode('utf-8')

ERROR: While attempting to sync account 'accountname' not enough values to unpack (expected 2, got 0) [' File "/home/z/.local/lib/python3.8/site-packages/offlineimap/accounts.py", line 298, in syncrunner\n self.sync()\n', ' File "/home/z/.local/lib/python3.8/site-packages/offlineimap/accounts.py", line 374, in sync\n remoterepos.getfolders()\n', ' File "/home/z/.local/lib/python3.8/site-packages/offlineimap/repository/IMAP.py", line 681, in getfolders\n imapobj = self.imapserver.acquireconnection()\n', ' File "/home/z/.local/lib/python3.8/site-packages/offlineimap/imapserver.py", line 625, in acquireconnection\n self.delim, self.root = \\n'] *** Finished account 'accountname' in 0:01 ERROR: Exceptions occurred during the run! ERROR: While attempting to sync account 'accountname' not enough values to unpack (expected 2, got 0)

Traceback: File "/home/z/.local/lib/python3.8/site-packages/offlineimap/accounts.py", line 298, in syncrunner self.sync() File "/home/z/.local/lib/python3.8/site-packages/offlineimap/accounts.py", line 374, in sync remoterepos.getfolders() File "/home/z/.local/lib/python3.8/site-packages/offlineimap/repository/IMAP.py", line 681, in getfolders imapobj = self.imapserver.acquireconnection() File "/home/z/.local/lib/python3.8/site-packages/offlineimap/imapserver.py", line 625, in acquireconnection self.delim, self.root = \

AndySweden commented 5 months ago

Hello, I receive exactly the same error on Ubuntu in WSL.

Is there any solution for this error?

OfflineIMAP 8.0.0 Licensed under the GNU GPL v2 or any later version (with an OpenSSL exception) imaplib2 v3.05, Python v3.10.12, OpenSSL 3.0.2 15 Mar 2022 Account sync TEST: Processing account TEST Establishing connection to webmail.lth.se:993 (Remote) Enter password for user 'ABC': ERROR: While attempting to sync account 'TEST' 'tuple' object has no attribute 'decode' Finished account 'TEST' in 0:04 ERROR: Exceptions occurred during the run! ERROR: While attempting to sync account 'TEST' 'tuple' object has no attribute 'decode'

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 704, in getfolders flags, delim, name = imaputil.imapsplit(fldr) File "/usr/share/offlineimap3/offlineimap/imaputil.py", line 112, in imapsplit imapstring = imapstring.decode('utf-8')

Thank you for any hint/support!

thekix commented 3 months ago

Hi @myutkin @AndySweden

Sorry for the delay. Do you have the problem?

Could you print the imapstring to see what the problem is?

Currently the code in the imaputil.py, lines 109-112 file is:

    ['(\\HasNoChildren)', '"."', '"INBOX.Sent"']"""

    if isinstance(imapstring, tuple) and imapstring[0].decode("utf-8").rfind("{")>-1:
        imapstring = (imapstring[0].decode("utf-8")[0:imapstring[0].decode("utf-8").rindex("{")] + quote(imapstring[1].decode("utf-8"))).encode("utf-8")

Could you add in the print(imapstring) to find the problem?

    ['(\\HasNoChildren)', '"."', '"INBOX.Sent"']"""

    print(imapstring)
    if isinstance(imapstring, tuple) and imapstring[0].decode("utf-8").rfind("{")>-1:
        imapstring = (imapstring[0].decode("utf-8")[0:imapstring[0].decode("utf-8").rindex("{")] + quote(imapstring[1].decode("utf-8"))).encode("utf-8")

Thanks a lot, kix