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

Python 3 email package binary file handling is inconsistent #9

Open
sdgathman opened this issue Sep 21, 2016 · 6 comments
Open

Python 3 email package binary file handling is inconsistent #9

sdgathman opened this issue Sep 21, 2016 · 6 comments

Comments

@sdgathman
Copy link
Owner

Once again, we are back to python2.2 levels of bugginess in the email package for python3. Here is a basic test that needs to work:

import email

with open('test/zip1','r') as fp:
  msg = email.message_from_file(fp)

Apparently all the test cases I provided for python2.2 with Evil™ emails have been dropped.

We'll have to debug the email package in python3, then dynamically patch it like we had to for 2.2 and 2.3.

@sdgathman
Copy link
Owner Author

Looks like it might be just that FILE objects are either unicode or bytes variety now, and you have to pass the 'b' flag to get bytes.

@sdgathman
Copy link
Owner Author

Yes, the email package only works correctly when you pass it a binary file. I haven't found a way to make it output a binary file, however! Will have to see how the as_bytes() method works.

@sdgathman sdgathman changed the title Python 3 breaks email package Python 3 binary file handling is inconsistent Sep 22, 2016
@sdgathman sdgathman changed the title Python 3 binary file handling is inconsistent Python 3 email package binary file handling is inconsistent Sep 22, 2016
@sdgathman
Copy link
Owner Author

The test suite is surprisingly effective at getting all the StringIO changed to BytesIO and otherwise checking that all mail data io is 8-bit.

@xambroz
Copy link

xambroz commented Dec 5, 2022

This is problematic for packaging as well. The test code is written using the "from email import message_from_binary_file", but that is available only in python 3.2+ so can't be used for testing functionality of python27 or python30 version.

@kitterma
Copy link
Collaborator

kitterma commented Dec 6, 2022

Neither of which are supported anymore, so it's probably not a major concern.

@kitterma
Copy link
Collaborator

kitterma commented Dec 6, 2022

Not entirely unrelated, I'm finding the changes in 1.0.5 are helping a lot with non-UTF-8 content in email.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants