[issue34800] email.contentmanager raises error when policy.max_line_length==None or 0

2018-09-25 Thread silane

New submission from silane :

The document of the email.policy.Policy says max_line_length=0 or None 
indicates that no line wrapping should be done at all.
But email.contentmanager doesn't handle this properly and raises error when 
calling set_content() with bytes or non-ascii str.


---Code to reproduce the bug---

from email.message import EmailMessage
from email.policy import default
msg=EmailMessage(default.clone(max_line_length=None)) # or max_line_length=0

msg.set_content('あ') # raise error
# or
msg.set_content(b'a',maintype='application',subtype='octet-stream') # raise 
error

---


This bug is caused by contentmanager._encode_text() and 
contentmanager.set_bytes_content().
These don't assume policy.max_line_length to be None or 0.

I tested this on python3.7 3.6 3.5, but probably 3.4 has the same bug.

--
components: email
messages: 326364
nosy: barry, r.david.murray, silane
priority: normal
severity: normal
status: open
title: email.contentmanager raises error when policy.max_line_length==None or 0
versions: Python 3.5, Python 3.6, Python 3.7

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



[issue34800] email.contentmanager raises error when policy.max_line_length==None or 0

2018-09-25 Thread silane


Change by silane :


--
type:  -> behavior

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



[issue34800] email.contentmanager raises error when policy.max_line_length==None or 0

2018-09-25 Thread silane


Change by silane :


--
keywords: +patch
pull_requests: +8980
stage:  -> patch review

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



[issue34800] email.contentmanager raises error when policy.max_line_length==None or 0

2018-09-25 Thread silane


silane  added the comment:

I've made a pull request.
Please look at it.
And this is my first pull request, so please let me know if something wrong.

https://github.com/python/cpython/pull/9578

--

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