thrift
thrift copied to clipboard
Fix bug in Python's THttpClient proxy handling
trafficstars
Previously, creating an instance of this class would throw whenever the http(s)_proxy environment variables were set, since it tried concatenating a string with a bytes array.
@fishy the return type of the function should now always be str in Python 2 and 3, so it is consistent to the current behavior in Python2 while also fixing the function in Python 3.
This is the correct type, yes, but it's not the correct string:
$ python3
Python 3.10.4 (main, Mar 24 2022, 13:07:27) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import base64
>>> str(base64.b64encode(b'foo'))
"b'Zm9v'"
You're right, ensure_str it is.
Python 3:
>>> cr = b"abc"
>>> "Basic " + six.ensure_str(cr)
'Basic abc'
Python 2:
>>> cr = "abc"
>>> "Basic " + six.ensure_str(cr)
'Basic abc'
Thanks for your sharp eye! :)