New submission from Tim Chase:

If a mailbox.MH() object is created by pointing at a path that exists but 
doesn't contain a ".mh_sequences" file, it raises an exception upon iteration 
over .{iter,}items() rather than gracefully assuming that the file is empty.  I 
encountered this by pointing it at a Claws Mail IMAP-cache folder (which claims 
to store its messages in MH format¹ but it doesn't place a .mh_sequences file 
in those folders) only to have it raise an exception.

To replicate:
$ mkdir empty
$ python
>>> import mailbox
>>> for msg in mailbox.MH('empty').values(): pass

I suspect this could simply wrap the "f = open(os.path.join(self._path, 
'.mh_sequences'), 'r')" and following lines in a check to ignore the file if it 
doesn't exist (returning the empty "results").

¹ 
http://www.claws-mail.org/faq/index.php/General_Information#How_does_Claws_Mail_store_mails.3F

----------
components: Library (Lib)
messages: 226197
nosy: gumnos
priority: normal
severity: normal
status: open
title: mailbox.MH chokes on directories without .mh_sequences
type: behavior
versions: Python 2.7, Python 3.1, Python 3.2

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue22319>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to