TypeError: 'NoneType' object is not subscriptable.

Nicolas Sebrecht nicolas.s-dev at laposte.net
Fri Apr 29 18:51:27 BST 2011


On Fri, Apr 29, 2011 at 06:15:26PM +0300, vitaly.repin at gmail.com wrote:
>    Hello,
> 
>    I use offlineimap version 6.3.3. Previously I have used 6.3.2 (with the
>    same server/account) and everything worked fine.
> 
>    Now (with 6.3.3) I have decided to re-sync everything and started to
>    receive the following stdout from offlineimap:
> 
>    (a lot of successfully copied messages)
>    Copy message 28909 IMAP[BugsSeen] -> Maildir[BugsSeen]
>    (The problem starts)
>    Copy message 32773 IMAP[Calendar] -> Maildir[Calendar]
>    Thread 'Copy message 22531 from Calendar' terminated with exception:
>    Traceback (most recent call last):
>      File "/usr/lib64/python2.7/site-packages/offlineimap/threadutil.py",
>    line 159, in run
>        Thread.run(self)
>      File "/usr/lib64/python2.7/threading.py", line 483, in run
>        self.__target(*self.__args, **self.__kwargs)
>      File "/usr/lib64/python2.7/site-packages/offlineimap/folder/Base.py",
>    line 332, in copymessageto
>        message = self.getmessage(uid)
>      File "/usr/lib64/python2.7/site-packages/offlineimap/folder/IMAP.py",
>    line 218, in getmessage
>        return initialresult[1][0][1].replace("\r\n", "\n")
>    TypeError: 'NoneType' object is not subscriptable
> 
>    Last 1 debug messages logged for Copy message 22531 from Calendar prior to
>    exception:
>    imap: Returned object from fetching 22531: ('OK', [None])
> 
>    stderr shows:
> 
>    WARNING:root:Using old interface name, consider using one of machineui,
>    blinkenlights, quiet, ttyui, basic
>    WARNING: ERROR attempting to copy message 22531 for account Acc:Traceback
>    (most recent call last):
>      File "/usr/lib64/python2.7/site-packages/offlineimap/folder/Base.py",
>    line 332, in copymessageto
>        message = self.getmessage(uid)
>      File "/usr/lib64/python2.7/site-packages/offlineimap/folder/IMAP.py",
>    line 218, in getmessage
>        return initialresult[1][0][1].replace("\r\n", "\n")
>    TypeError: 'NoneType' object is not subscriptable

Funny! I just happenned to have this error:

   WARNING: ERROR attempting to copy message 4221 for account nis:Traceback (most recent call last):
    File "/usr/lib64/python2.5/site-packages/offlineimap/folder/Base.py", line 255, in copymessageto
      message = self.getmessage(uid)
    File "/usr/lib64/python2.5/site-packages/offlineimap/folder/IMAP.py", line 208, in getmessage
      data = data[0][1]
  TypeError: 'NoneType' object is unsubscriptable
  
   Thread 'Copy message 4221 from INBOX.joomla-dev-cms' terminated with exception:
  Traceback (most recent call last):
    File "/usr/lib64/python2.5/site-packages/offlineimap/threadutil.py", line 159, in run
      Thread.run(self)
    File "/usr/lib64/python2.5/threading.py", line 446, in run
      self.__target(*self.__args, **self.__kwargs)
    File "/usr/lib64/python2.5/site-packages/offlineimap/folder/Base.py", line 255, in copymessageto
      message = self.getmessage(uid)
    File "/usr/lib64/python2.5/site-packages/offlineimap/folder/IMAP.py", line 208, in getmessage
      data = data[0][1]
  TypeError: 'NoneType' object is unsubscriptable

[ The error change a bit from OP's due to commit 1ff628bd in current
  "next" development branch. ]


While I wanted to cleanup some of my folders I decided to test
OfflineIMAP. What I did:

  1) Delete the folder where stands the mails
  2) Start a new sync
  3) Delete the folder via a webmail on IMAP server during the sync
  4) Boom!

I suspect OP's issue is the same and I wouldn't be surprised if Exchange
server is deleting/creating a lot of mails in the Calendar folder (maybe
only changing UID on some data).

I tend to think that there are two cases we should handle differently:

  a) The mail was deleted from the server and we should skip that mail.
  b) Another (true) mistake happenned and we should warn/abort.

In order to be robust, I think we should dynamically update the status
of the folder and restart the sync of this folder if we can't fetch a
UID. If the same error appear for the same UID we are in case (b).
Otherwise, continue as usual; we are in case (a).

-- 
Nicolas Sebrecht




More information about the OfflineIMAP-project mailing list