Skip to content
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

email.encoders.encode7or8bit does not work with binary data #61373

Closed
bitdancer opened this issue Feb 9, 2013 · 3 comments
Closed

email.encoders.encode7or8bit does not work with binary data #61373

bitdancer opened this issue Feb 9, 2013 · 3 comments
Labels
topic-email type-bug An unexpected behavior, bug, or error

Comments

@bitdancer
Copy link
Member

BPO 17171
Nosy @warsaw, @bitdancer

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:

assignee = None
closed_at = <Date 2013-02-11.16:21:56.996>
created_at = <Date 2013-02-09.18:19:45.072>
labels = ['type-bug', 'expert-email']
title = 'email.encoders.encode7or8bit does not work with binary data'
updated_at = <Date 2013-02-11.16:21:56.995>
user = 'https://github.com/bitdancer'

bugs.python.org fields:

activity = <Date 2013-02-11.16:21:56.995>
actor = 'r.david.murray'
assignee = 'none'
closed = True
closed_date = <Date 2013-02-11.16:21:56.996>
closer = 'r.david.murray'
components = ['email']
creation = <Date 2013-02-09.18:19:45.072>
creator = 'r.david.murray'
dependencies = []
files = []
hgrepos = []
issue_num = 17171
keywords = []
message_count = 3.0
messages = ['181748', '181905', '181906']
nosy_count = 3.0
nosy_names = ['barry', 'r.david.murray', 'python-dev']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue17171'
versions = ['Python 3.2', 'Python 3.3', 'Python 3.4']

@bitdancer
Copy link
Member Author

Reported by Serhiy in bpo-16564:

>>> import io, email
>>> bytesdata = b'\xfa\xfb\xfc\xfd\xfe\xff'
>>> msg = email.mime.application.MIMEApplication(bytesdata, _encoder=encoders.encode_7or8bit)
>>> s = io.BytesIO()
>>> g = email.generator.BytesGenerator(s)
>>> g.flatten(msg)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/serhiy/py/cpython3.2/Lib/email/generator.py", line 91, in flatten
    self._write(msg)
  File "/home/serhiy/py/cpython3.2/Lib/email/generator.py", line 137, in _write
    self._dispatch(msg)
  File "/home/serhiy/py/cpython3.2/Lib/email/generator.py", line 163, in _dispatch
    meth(msg)
  File "/home/serhiy/py/cpython3.2/Lib/email/generator.py", line 393, in _handle_text
    if _has_surrogates(msg._payload):
TypeError: can't use a string pattern on a bytes-like object

@bitdancer bitdancer added topic-email type-bug An unexpected behavior, bug, or error labels Feb 9, 2013
@python-dev
Copy link
Mannequin

python-dev mannequin commented Feb 11, 2013

New changeset f83581135ec4 by R David Murray in branch '3.2':
bpo-17171: fix email.encoders.encode_7or8bit when applied to binary data.
http://hg.python.org/cpython/rev/f83581135ec4

New changeset cabcddbed377 by R David Murray in branch '3.3':
Merge: bpo-17171: fix email.encoders.encode_7or8bit when applied to binary data.
http://hg.python.org/cpython/rev/cabcddbed377

New changeset a80b67611c6d by R David Murray in branch 'default':
Merge: bpo-17171: fix email.encoders.encode_7or8bit when applied to binary data.
http://hg.python.org/cpython/rev/a80b67611c6d

New changeset e44fa71d76fe by R David Murray in branch '2.7':
bpo-17171: backport behavior-confirming test from python3.
http://hg.python.org/cpython/rev/e44fa71d76fe

@bitdancer
Copy link
Member Author

Since this was straightforwardly similar to the bpo-16564 fix I didn't bother with a review. The 2.7 commit is backporting the behavior-confirming test, just for thoroughness.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-email type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant