New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'UnstructuredTokenList' object has no attribute '_fold_as_ew' #71427
Comments
The folding code for email headers crashes whenever it hits line _header_value_parser.py:432 given it try to call method
Given folding depends a lot on the processed value, this bug only trigger in very specific encoded headers (I've try to reproduce this bug with various values but only the one which originally made me find the bug worked so far). I've isolated the bug into a simple test case (see enclosed file). It seems this part of the code has been rewritten between Python2 and 3 (the file _header_value_parser.py doesn't exists in Python2). So unsurprisingly the bug doesn't trigger in Python2. Replacing |
I think I find a case which can reproduct this bug: For examples, the following subjects can cause this bug:
So, the code can not fold a ValueTerminal correctly. |
It happens regularly for emails with long header lines for me too, which makes the python3 email module quite unusable. A workaround which seems to help a bit is to set refold_source='none' on the email policy, although it seems to keep happening, less often. Is the fix proposed by Emmanuel a proper fix ? I'm not knowledgeable enough on this subject... |
I started rewriting the header folder in response to this bug, because the root problem is a bit deeper than just _fold_as_ew being missing. I will probably work on it some more this week, but if I don't think I'm going to get it finished I'll look at putting in a fix that doesn't address the other problems but does address this one. |
I managed to finish the rewrite, and it does fix this issue. I'll probably post the PR tomorrow. |
All three examples in test2.py correctly folded (doesn't hit the ``except Exception as e:`` branch anymore) in current master. Can this issue be closed now? |
Huh, I thought I had closed it. |
Is there any chance that this fix is gonna be ported to 3.5 as well? |
No. 3.5 is in security-fix-only mode. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: