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

Support mixed string and bytes as input #66

Merged

Conversation

asfaltboy
Copy link
Contributor

Some smart programmers may cautiously encode a unicode string to "bytestring" when setting their message body/headers, however this would currently fail on python 2 if they left in any unicode; even an empty unicode literal (u'').

By encoding each frame part before packing (as we already do for Python 3) we avoid raising a UnicodeDecodeError for perfectly encoded bunch of strings.

Without this "part-by-part encoding", both py2 and py3 version of pack would fail test_pack_mixed_string_and_bytes, so I added the test to both, and with the fix both now pass.

By encoding each frame part before packing (as we already do for
Python 3) we avoid raising a UnicodeDecodeError for perfectly
legitimate bunch of strings.

Without this part by part encoding, both py2 and py3 version of
pack would fail, so I added the test to both.
@jasonrbriggs jasonrbriggs merged commit ccf28e8 into jasonrbriggs:master Dec 22, 2015
@asfaltboy
Copy link
Contributor Author

That was a quick merge, thanks! 🐎

@jasonrbriggs
Copy link
Owner

Thanks for the contribution, btw.

@asfaltboy asfaltboy deleted the feature/fix-mixed-unicode-bytes branch December 29, 2015 10:41
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

Successfully merging this pull request may close these issues.

2 participants