[issue28473] mailbox.MH crashes on certain Claws Mail .mh_sequences files

2016-10-29 Thread Garrett Nievin

Garrett Nievin added the comment:

Interestingly, mailutils mh (GNU Mailutils 2.99.99, Ubuntu 16.10)
doesn't have a problem with these files, so I'm using that instead of
nmh.

I assume this is relevant:
http://www.nongnu.org/nmh/diff.html

The limitation on the length of lines in the file containing your
public sequences (.mh_sequences) has been removed. That should be the
end of the error message ".mh_sequences is poorly formatted". 


That's the message I got with nmh, but not with mailutils mh.

Cheers,
Garrett

On Wed, 19 Oct 2016 13:26:33 + "R. David Murray" <rep...@bugs.python.org> 
wrote:

> R. David Murray added the comment:
> 
> I meant 'nmh'.  Also, if the problem is that mailbox blows up on an 
> .mh_sequences file with bad records and doesn't provide any way to access the 
> valid records (like nmh mostly manages to do), then that is something that 
> could be fixed, and we can reopen the issue.
> 
> --
> versions: +Python 3.6, Python 3.7 -Python 3.5
> 
> ___
> Python tracker <rep...@bugs.python.org>
> <http://bugs.python.org/issue28473>
> ___
>

--

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



[issue28473] mailbox.MH crashes on certain Claws Mail .mh_sequences files

2016-10-29 Thread Garrett Nievin

Garrett Nievin added the comment:

Yes, I couldn't access the mailbox at all.  Here's what happens:

$ cat mymail.py ; ./mymail.py 
#!/usr/bin/python3
import mailbox
for message in mailbox.MH('~/mail/Personal'):
print(message['subject'])
Traceback (most recent call last):
  File "/usr/lib/python3.5/mailbox.py", line 1148, in get_sequences
name, contents = line.split(':')
ValueError: not enough values to unpack (expected 2, got 1)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./mymail.py", line 3, in 
for message in mailbox.MH('~/mail/Personal'):
  File "/usr/lib/python3.5/mailbox.py", line 108, in itervalues
value = self[key]
  File "/usr/lib/python3.5/mailbox.py", line 72, in __getitem__
return self.get_message(key)
  File "/usr/lib/python3.5/mailbox.py", line 1037, in get_message
for name, key_list in self.get_sequences().items():
  File "/usr/lib/python3.5/mailbox.py", line 1162, in get_sequences
line.rstrip())
mailbox.FormatError: Invalid sequence specification: 74 27976-27984 27987-27989 
27993-27994 27996-28008 28010-28023 28025 28027-28035 28038-28054 28056-28077 
28080-28104 28107-28109 28112-28117 28120-28123 28127 28129 28131 28133-28142 
28145-28154 28156-28189 28191-28197 28199-28204 28206-28218 28220-28224 28226 
28230-28234 28239-28242 28244-28249 28251 28253-28260 28262-28263 28265-28269 
28274-28280 28282-28286 28290-28297 28300-28306 28308-28351 28354-28362 
28364-28421 28423-28437 28440 28448-28452 28457-28461 28464-28475 28478-28482 
28484-28489 28491-28498 28500-28504 28507-28517 28522-28525 28527-28529 28531 
28536-28550 28554-28555 28562-28564 28567-28574 28577-28579 28581-28582 28586 
28588-28594 28597-28603 28605-28613 28619 28622 28625-28628 28630 28632-28633 
28636-28639 28643-28650 28654-28668 28671-28672 28676-28679 28681-28690 
28695-28706 28710-28712 28714 28716-28717 28719-28725 28728-28730 28732-28742 
28745-28748 28750-28751 28753-28763 28765-28768 28770 28772-28814 28817-
 28840 28843-28859 28862-28873 28876-28894 28899-28900 28902-28917 28920-28934 
28936-28939 28941-28943 28945 28949-28954 28956-28959 28963-28976 28984-28988 
28990-28995 28997-29017 29021-29028 29030-29068 29070-29073 29076-29083 29088 
29099 29102-29104 29106-29107 29109-29119 29121-29139 29142 29144-29145 29149 
29154 29163-29164 29167-29172 29174-29175 29180-29183 29189-29200 29202-29213 
29215-29223 29226-29227 29230 29232-29244 29246-29253 29258-29282 29284-29294 
29296-29307 29309 29311-29319 29326-29342 29345-29351 29354-29364 29371-29382 
29387-29390 29393-29414 29416-29419 29421 29423-29445 29448-29486 29488-29495 
29497-29507 29509-29519 29521-29539 29541-29554 29556-29557 29559-29563 
29566-29571 29575-29589 29593-29601 29604-29609 29611-29617 29620-29622 
29624-29647 29650-29651 29653-29664 29666-29674 29676-29683 29689-29694 
29696-29701 29704-29705 29709-29711 29714-29730 29733-29751 29754 29756-29758 
29760-29762 29764-29768 29770-29771 29773-29780 29782-29784 29787 29790-29805 2
 9807-29808 29811-29819 29822-29826 29829-29831 29834-29843 29845-29848 
29850-29853 29855-29864 29870 29873-29891 29893-29942 29944-29962 29970-29972 
29974-29975 29977-29981 29986-29988 29992-29996 2-30002 30006-30008 30010 
30014-30039 30041-30072 30075-30087 30089-30090 30093-30142 30145-30156 
30158-30171 30174-30177 30180-30194 30197 30202-30203 30206-30214 30216 
30218-30227 30230-30236 30239-30277 30282-30284 30288-30316 30322-30341 
30343-30373 30376-30386 30388-30405 30407-30412 30417-30418 30421-30445 
30449-30452 30456-30463 30468-30488 30492-30500 30502-30510 30516-30530 
30532-30538 30540-30543 30546-30548 30551 30553-30576 30578-30608 30613 
30616-30618 30620-30632 30635-30639 30646-30648 30650-30651 30655-30673 30675 
30678-30681 30685-30693 30695-30738 30741-30742 30745 30747 30749-30757 
30760-30782 30784 30786-30792 30794-30800 30803-30809 30812-30826 30828-30837 
30840-30841 30843-30847 30850-30893 30897-30898 30900 30902-30904 30906-30920 
30922-30932 30938 30943-30984 30
 986-30990 30992-30994 30996-31001 31003-31013 31015-31018 31021-31036 31039 
31043-31047 31051-31061 31064-31068 31070 31073-31074 31077-31088 31093-31095 
31097-31105 31108-31115 31117 31119-31144 31147-31156 31163 31166-31181 
31184-31185 31189 31191 31196-31204 31208 31210-31219 31221-31230 31232-31296 
31299 31301-31308 31312-31321 31324-31327 31329-31346 31349-31368 31371-31375 
31378-31387 31391-31397 31400-31401 31403-31409 31412-31423 31426-31522 
31525-31534 31539-31549 31554-31555 31557-31558 31560-31584 31589-31618 
31621-31637 31640-31648 31656-31669 31671-31680 31683 31685-31696 31698-31706 
31708-31717 31719-31738 31740-31749 31751-31752 31755-31756 31758-31764 
31766-31767 31772-31775 31777-31796 31798-31828 31830-31880 31884-31886 
31888-31890 31892-31958 31961-31963 31966-31992 31996-31998 32000-32003 
32006-32025 32029-32037 32039-32044 32047-32053 

[issue28473] mailbox.MH crashes on certain Claws Mail .mh_sequences files

2016-10-18 Thread Garrett Nievin

New submission from Garrett Nievin:

Using Claws Mail, and mailbox.MH crashes on two different conditions:

1) sequence spans lines, suchly:
unseen: 1-222 225-300
990-1024 1048-2048

Not Pythonic, but I fixed it with this update:

def get_sequences(self):
"""Return a name-to-key-list dictionary to define each sequence."""
results = {}
with open(os.path.join(self._path, '.mh_sequences'), 'r', 
encoding='ASCII') as f:
all_keys = set(self.keys())
for line in f:
try:
if line.count(':') == 0:
contents = line
else:
name, contents = line.split(':')
keys = set()
for spec in contents.split():
if spec.isdigit():
keys.add(int(spec))



2) Sequence spec appears to be open-ended on the front:
 28119-28123 28127 28129 28131 28133-28142 28144-28154 28156-28172 28174-28189 
28191-28204 28206-28218 28220-28224 28226 28228-28234 28237-28239
 28119-28123 28127 28129 28131 28133-28142 28144-28154 28156-28163
 28119-28123 28127 28129 28131 28133-28157
-27920 27923-27945 27947

I'm not sure how to interpret this, so just put in a kludgy fix to get my 
script running as a workaround (not using sequences).

Would also be interested in an option to open a mailbox and process while 
ignoring sequences.

--
components: Library (Lib)
messages: 278945
nosy: garrettzilla
priority: normal
severity: normal
status: open
title: mailbox.MH crashes on certain Claws Mail .mh_sequences files
type: crash
versions: Python 3.5

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