New submission from Yun Li <yunle...@gmail.com>:

email.header.make_header() doesn't work if any `ascii` code is out of range(128)

For example 

>>> header = "Your booking at Voyager Int'l 
>>> Hostel,=?UTF-8?B?IFBhbmFtw6EgQ2l0eQ==?=,   Panamá- Casco Antiguo"

>>> decode_header(header)
[(b"Your booking at Voyager Int'l Hostel,", None), (b' Panam\xc3\xa1 City', 
'utf-8'), (b',   Panam\xe1- Casco Antiguo', None)]

>>> make_header(decode_header(header))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File 
"/usr/local/Cellar/python/3.7.2_2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/email/header.py",
 line 174, in make_header
    h.append(s, charset)
  File 
"/usr/local/Cellar/python/3.7.2_2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/email/header.py",
 line 295, in append
    s = s.decode(input_charset, errors)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe1 in position 9: ordinal 
not in range(128)

----------
components: email
messages: 347577
nosy: barry, r.david.murray, yunlee
priority: normal
severity: normal
status: open
title: email.header.make_header() doesn't work if any `ascii` code is out of 
range(128)
type: behavior
versions: Python 3.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue37532>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to