koji.ClientSession: fix erroneous conversion to latin-1
For Python 3, we need to always encode what we are sending to the server as utf-8; encoding strings that have only latin-1 as latin-1 causes us to send something that the server can't parse. (When no encoding is specified xmlclient.client.dumps creates an XML document with an xml declaration for UTF-8.)
This commit is contained in:
parent
19ae3b55c0
commit
3227462528
1 changed files with 4 additions and 7 deletions
|
|
@ -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'),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue