fix xmlrpc encoding error

This commit is contained in:
Tomas Kopecek 2019-01-29 15:42:44 +01:00 committed by Mike McLean
parent 5216c54572
commit ca86a8fa78
2 changed files with 9 additions and 1 deletions

View file

@ -2400,6 +2400,14 @@ class ClientSession(object):
else:
handler = self.baseurl
request = dumps(args, name, allow_none=1)
try:
request.encode('latin-1')
except (UnicodeEncodeError, UnicodeDecodeError):
# py2 string throws UnicodeDecodeError
# py3 string throws UnicodeEncodeError
# if string is not converted to UTF, requests will raise an error
# on identical check before sending data
request = request.encode('utf-8')
headers = [
# connection class handles Host
('User-Agent', 'koji/1'),

View file

@ -75,7 +75,7 @@ def dumps(params, methodname=None, methodresponse=None, encoding=None,
if isinstance(params, Fault):
methodresponse = 1
elif not isinstance(params, tuple):
raise TypeError('params must be a tuple of Fault instance')
raise TypeError('params must be a tuple or Fault instance')
elif methodresponse and len(params) != 1:
raise ValueError('response tuple must be a singleton')