Fix UnicodeDecodeError for httplib#144
Open
moylop260 wants to merge 2 commits intotransifex:masterfrom
Open
Conversation
Python 2.7.6 - /usr/lib/python2.7/httplib.py
820 def _send_output(self, message_body=None):
821 Send the currently buffered request and clear the buffer. ---------------------------------------- 4--
826 self._buffer.extend(("", ""))
827 msg = "\r\n".join(self._buffer)
828 del self._buffer[:]
829 # If msg and message_body are sent in a single send() call,
830 # it will avoid performance problems caused by the interaction
831 # between delayed ack and the Nagle algorithm.
832 if isinstance(message_body, str):
833 msg += message_body
834 message_body = None
835 self.send(msg)
If the variable `self._buffer` has
[u'PUT /api/2/project/PROJECT/resource/RESOURCE/content/ HTTP/1.1', ...]
`msg` is unicode string
`message_body` is bytes string
The line 833 concatenate unicode + bytes string and show the error:
`Fix UnicodeDecodeError: 'ascii' codec can't decode byte ... in position ...: ordinal not in range(128)`
This could be fixed if we force in `host` and `url` of transifex-client use bytes to concatenate bytes vs bytes
moylop260
added a commit
to vauxoo-dev/maintainer-quality-tools
that referenced
this pull request
Nov 24, 2016
moylop260
added a commit
to Vauxoo/maintainer-quality-tools
that referenced
this pull request
Nov 24, 2016
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Python 2.7.6 - /usr/lib/python2.7/httplib.py has the following code:
If the variable
self._buffer(line 827) has[u'PUT /api/2/project/PROJECT/resource/RESOURCE/content/ HTTP/1.1', ...]
then
msgvariable is unicode stringbut
message_bodyis bytes string (line 832)The line 833 concatenate unicode + bytes string and show the error:
Fix UnicodeDecodeError: 'ascii' codec can't decode byte ... in position ...: ordinal not in range(128)Similar to:
python -c "u'unicode string' + 'bytes string é'"It's fixed forcing in
hostandurlvariables of transifex-client use bytes to concatenate bytes vs bytes.Note: We are using
from __future__ import unicode_literals