prepare_headers patch not needed for requests in python3
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
python-swiftclient |
New
|
Undecided
|
Unassigned |
Bug Description
Currently there is a patch in place for `requests.
The if statement is very specific for python 2 and applies to requests < 2.0.0, which makes sense seeing this change ( https:/
But there is also an or statement for NOT python2, making it always apply.
Not sure when this was needed, but it appears to work fine in python 3.
Going through git history of `requests`, I honestly cannot find any trace when this would have broken in python 3. The aforementioned change introduced the `to_native_string` for header keys. And the implementation and usage of that hasn't changed since. For our local setup using swiftclient, disabling the patch it all appears to keep working.
Desired situation:
Change the monkeypatch to only apply for the required version of requests.
The reason was hinted-at in https:/ /opendev. org/openstack/ python- swiftclient/ commit/ 7175069b that introduced the `or not six.PY2` -- basically, it allows users to continue doing things like
$ swift post -m '☃:❄'
which swift has allowed ever since account/container metadata was introduced back in https:/ /opendev. org/openstack/ swift/commit/ e8d3f260.
Now, setting metadata like that isn't a great idea. Doing it in my dev environment made `swift list` go from ~0.5s to ~100s (!) because py3's stdlib doesn't know how to handle the non-compliant header and aborts parsing -- see https:/ /bugs.python. org/issue37093
So the *real* value at the moment comes from being able to *clear* the non-compliant metadata after wondering why everything got so slow after switching to python3. Without it, users would have to either switch back to py2 or just use curl.