Andrei Kulakov <andrei....@gmail.com> added the comment:
I've looked into this and it seems to be somewhat intentional, as can be seen in this test case for example: test_headerregistry.py", line 1725, in test_fold_address_list + To: "Theodore H. Perfect" <y...@man.com>, + "My address is very long because my name is long" <f...@bar.com>, + "Only A. Friend" <n...@yes.com> Relevant code is here: https://github.com/python/cpython/blob/main/Lib/email/_header_value_parser.py#L2829-L2849 The logic goes like this: tstr = header value - try to add it to current line, if fits; continue to start of loop - try to add it to next line, if fits; continue to start of loop - split tstr; continue to start of loop So as you can see from test case, if split happened before step 2, the name would be split over 2 lines which is not ideal. I tested splitting before step 2, which fixed this bug but failed 11 test cases, all of which deal with email address folding. (To and From headers). So, is this actually an issue worth fixing? If the answer is yes, one option would be to special case Subject header and split it before going to step 2. IOW, the block that starts here: https://github.com/python/cpython/blob/4bcef2bb48b3fd82011a89c1c716421b789f1442/Lib/email/_header_value_parser.py#L2835 would need to be moved after the next block that starts 6 lines below. ---------- nosy: +andrei.avk _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue43493> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com