OfflineIMAP / offlineimap3

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

AttributeError: 'NoneType' object has no attribute 'decode' #198

Closed rlucas11 closed 3 months ago

rlucas11 commented 6 months ago

When I try to use offlineimap to sync, two folders (archive and sent) do not sync, but all the others do. The traceback is below, but the last error is the title of this issue. The problem started about a month or so ago, perhaps after upgrading to python 3.12. I haven't found any information about this error when searching issues or online.

General informations

Configuration file offlineimaprc

[general]
pythonfile = ~/.offlineimap.py
accounts = work
socktimeout = 120

[Account work]
localrepository = local
remoterepository = exchange

autorefresh = 1
quick = 10
labelsheader = X-Keywords

[Repository local]
type = Maildir
localfolders = ~/Maildir
sep = /

[Repository exchange]
type = IMAP
remotehost = localhost
ssl = no

maxconnections = 1
singlethreadperfolder = yes
holdconnectionopen = yes
keepalive = 60

Logs, error

ERROR: ERROR in syncfolder for work folder Archive: Traceback (most recent call last):                
  File "/usr/lib/python3.12/site-packages/offlineimap/accounts.py", line 653, in syncfolder           
    remotefolder.cachemessagelist()                                                                   
  File "/usr/lib/python3.12/site-packages/offlineimap/folder/IMAP.py", line 289, in cachemessagelist  
    msgsToFetch = self._msgs_to_fetch(                                                                
                  ^^^^^^^^^^^^^^^^^^^^                                                                
  File "/usr/lib/python3.12/site-packages/offlineimap/folder/IMAP.py", line 249, in _msgs_to_fetch    
    imapdata = [x.decode('utf-8') for x in imapdata]                                                  
                ^^^^^^^^                                                                              
AttributeError: 'NoneType' object has no attribute 'decode'                                           
  'NoneType' object has no attribute 'decode'
keithbowes commented 3 months ago

Yeah, there are various known issues with using this with Python 3.12. They've supposedly been fixed in Git (I'm using my distro's supplied 3.10 atm, so it works fine for me, for now). 8.0.0 is from 2021, when the incompatibilities of Python 3.12 weren't even in anyone's nightmares. Maybe the maintainers will get a new version that works with Python 3.12 released, before Python 3.13 breaks it again :)

etbuira commented 3 months ago

Hi @rlucas11

For the time being (no release for ages), using git master is the way to go. The bug you are facing have been fixed 2 years ago (https://github.com/OfflineIMAP/offlineimap3/commit/210c23bdee9acd852c0bea02887431b630359418).

rlucas11 commented 3 months ago

Thanks for the help; I had installed the git version on one system. The error message went away, but the same two folders wouldn't sync, and I had assumed that the problem was the same, even without the error message. Coincidentally, in the last few days I'd come back to investigate that more and I think it's a different imaplib bug (which I found described here: https://stackoverflow.com/questions/16911238/python-imaplib-error-unexpected-repsonse). So I followed that advice and as far as I can tell, it's working (these are large folders that are taking a long time to sync).