-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Do not re-encode a UTF-8 string as ISO-8859-1 silently in HTTP requests #5560
Comments
I may have encountered this problem too. I wonder if there is any status change. python3 -m requests.help |
Quoting the original issue:
In other words, not code that Requests controls and not a bug we can fix. |
I disagree. You could fix it if you wanted. Since you are wrapping that code, you could handle the issue in your wrapper so that at least your clients are not hurt by this issue. In other words: Requests could offer an API that is consistent with the Python ecosystem, and handle such silly issues internally if needed, before calling |
@baharev Requests is under feature freeze with no room for breaking changes so this change is extremely unlikely to land, regardless of its utility. It is a best practice to provide |
Yes, I have figured that out the hard way. The problem is that it is incredibly easy to forget an In other words, I find the current interface a loaded gun, and you can easily shoot yourself in the foot.
OK, I understand. |
@sethmlarson +1s are great, I really appreciate it, but what should I do so that this issue is eventually addressed? If this issue remains closed, it will be forgotten. A "fix" could be as simple as throwing |
This issue is about sending an HTTP request, and not about the response.
Expected Result
I expected the request to be sent as UTF-8, after all, everything in the Python 3 ecosystem uses UTF-8 by default.
Actual Result
My UTF-8 string is silently re-encoded as ISO-8859-1, causing confusing bugs at the recipient. The code in
http.client
is doing it:https://github.com/python/cpython/blob/c3dd7e45cc5d36bbe2295c2840faabb5c75d83e4/Lib/http/client.py#L1312
Suggestion
I suggest that if
requests
takes a native UTF-8 string asdata
argument, it makes sure that it is handled as a UTF-8 string all the way, and won't be silently re-encoded as ISO-8859-1. It can cause really obscure bugs otherwise.Related
This issue is about sending a request. Related open issues are mostly concerned with the response:
Reproduction Steps
See above.
System Information
The text was updated successfully, but these errors were encountered: