Fix UnicodeEncodeError in urllib if non-ascii characters are present in Request parameters#91
Closed
romanbarczynski wants to merge 1 commit into
Closed
Fix UnicodeEncodeError in urllib if non-ascii characters are present in Request parameters#91romanbarczynski wants to merge 1 commit into
romanbarczynski wants to merge 1 commit into
Conversation
|
I have the same problem now. |
|
Just hit this problem too, and can confirm that romke's commit fixes things. |
|
Also, that method seems awfully complicated and can probably be replaced with the following if you prefer: def to_url(self):
"""Serialize as a URL for a GET request."""
scheme, netloc, path, query, fragment = urlparse.urlsplit(self.url.encode('utf-8'))
query = parse_qs(query)
for k, v in self.iteritems():
query.setdefault(k.encode('utf-8'), []).append(to_utf8_optional_iterator(v))
query = urllib.urlencode(query, True)
return urlparse.urlunsplit((scheme, netloc, path, query, fragment)) |
|
Thank you romke for the patch, works like charm.. Someone should pull this into master, the patch has been available for over a year now.. |
|
Is there any update on this? I seem to run into this problem. |
|
Thank you! |
|
Thanks emgee. Your fix saves my code. |
Owner
|
Your patch was half-fixed in a different PR. I modified your PR to use |
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.
Request.to_postdata was fixed some time ago, but Request.to_url was still unable to create url when unicode characters were present in any of Request parameters (because of UnicodeEncodeError)
See included test.