This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Lukas J
Recipients Lukas J, barry, r.david.murray
Date 2019-02-13.12:08:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1550059683.58.0.369389520684.issue35985@roundup.psfhosted.org>
In-reply-to
Content
When converting an email.message.Message with the policy set to email.policy.EmailPolicy with all default settings, I eventually end up with this exception:



  File "/usr/lib/python3.7/email/_header_value_parser.py", line 2727, in _fold_as_ew
    first_part = to_encode[:text_space]
TypeError: slice indices must be integers or None or have an __index__ method



Which is caused because text_space is a float of value +inf. This is set  on line 2594 of the same file: maxlen = policy.max_line_length or float("+inf")

For some reason policy.max_line_length is set to zero, even though the default should be 78 after a glance into the source.


So there's maybe even two issues: 

1.) The fallback for maxlen shouldn't be float("+inf"), as that is not an integer and thus can't be sliced by. I think a big integer would suffice instead, for example 100000000

2.) policy.max_line_length seems to lose it's value in the default settings somewhere along the way if it isn't explicitly set.


Current workaround:
Set max_line_length of the policy to a value (78 is default)
History
Date User Action Args
2019-02-13 12:08:03Lukas Jsetrecipients: + Lukas J, barry, r.david.murray
2019-02-13 12:08:03Lukas Jsetmessageid: <1550059683.58.0.369389520684.issue35985@roundup.psfhosted.org>
2019-02-13 12:08:03Lukas Jlinkissue35985 messages
2019-02-13 12:08:03Lukas Jcreate