PR#2040: koji.ClientSession: fix erroneous conversion to latin-1

Merges #2040
https://pagure.io/koji/pull-request/2040

Fixes #2093
https://pagure.io/koji/issue/2093
This commit is contained in:
Tomas Kopecek 2020-03-25 09:54:19 +01:00
commit 4864df3442

View file

@ -2684,13 +2684,10 @@ class ClientSession(object):
handler = self.baseurl
request = dumps(args, name, allow_none=1)
if six.PY3:
try:
request.encode('latin-1')
except UnicodeEncodeError:
# if string is not converted to UTF, requests will raise an error
# on identical check before sending data
# py3 string throws UnicodeEncodeError
request = request.encode('utf-8')
# For python2, dumps() without encoding specified means return a str
# encoded as UTF-8. For python3 it means "return a str with an appropriate
# xml declaration for encoding as UTF-8".
request = request.encode('utf-8')
headers = [
# connection class handles Host
('User-Agent', 'koji/1'),