PR#2598: lib: better print with debug_xmlrpc

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

Fixes: #2597
https://pagure.io/koji/issue/2597
lib: print decoded bytes with debug_xmlrpc
This commit is contained in:
Tomas Kopecek 2021-01-06 14:38:57 +01:00
commit 6a4f96179b

View file

@ -2702,8 +2702,11 @@ class ClientSession(object):
_val = callopts[_key]
if _key == 'data':
if six.PY3 and isinstance(_val, bytes):
# convert to hex-string
_val = '0x' + _val.hex()
try:
_val = _val.decode()
except UnicodeDecodeError:
# convert to hex-string
_val = '0x' + _val.hex()
if len(_val) > 1024:
_val = _val[:1024] + '...'
self.logger.debug("%s: %r" % (_key, _val))