R. David Murray <rdmur...@bitdance.com> added the comment: This was quite the adventure. The more I worked on fixing the tests, the more if/else cases the existing splitting algorithm grew. When I reached the point where fixing one test broke two others, I thought maybe it was time to try a different approach.
Based on the knowledge gathered by banging my head on the old algorithm, I developed a new one. This one is more RFC2822/RFC5322 compliant, I believe. It breaks only at FWS, but still gives preference to breaking after commas or semicolons by default. I had to adjust several tests that tested broken behavior: the "folded" lines were longer than maxlen even though there were suitable fold points. I'm very happy with this patch because there are 70 fewer lines of code but the module passes more tests. Even though the code changes are extensive, I plan to apply this to 3.2. It fixes bugs, and the new code is at least somewhat easier to understand than the old code (if only because there is less of it!) I don't plan to apply it to 3.1 because one older test fails if the patch is applied and I don't understand why (it appears to have nothing to do with line wrapping, and the same test works fine in 3.2). ---------- stage: needs patch -> patch review versions: -Python 3.1 Added file: http://bugs.python.org/file21607/better_header_spliter.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue11492> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com