Fixes: https://pagure.io/koji/issue/1656
:thumbsup:
At this point in the code, data might be either bytes (in the upload case) or a string (in most other cases).
With this fix, things break the other way.
$ PYTHONPATH=~/Devel/koji/koji koji -p lkoji --debug --noauth --debug-xmlrpc call echo "$(seq 1000)" 2019-09-25 09:17:27,422 [DEBUG] koji: Opening new requests session 2019-09-25 09:17:27,423 [DEBUG] koji: url: https://localhost/kojihub 2019-09-25 09:17:27,423 [DEBUG] koji: headers: {'User-Agent': 'koji/1', 'Content-Type': 'text/xml', 'Content-Length': '107'} 2019-09-25 09:17:27,423 [DEBUG] koji: data: "<?xml version='1.0'?>\n<methodCall>\n<methodName>getAPIVersion</methodName>\n<params>\n</params>\n</methodCall>\n" 2019-09-25 09:17:27,423 [DEBUG] koji: stream: True 2019-09-25 09:17:27,423 [DEBUG] koji: verify: '/home/mike/.koji/localhost.crt' 2019-09-25 09:17:27,423 [DEBUG] koji: timeout: 43200 2019-09-25 09:17:27,430 [DEBUG] koji: body: b"<?xml version='1.0'?>\n<methodResponse>\n<params>\n<param>\n<value><int>1</int></value>\n</param>\n</params>\n</methodResponse>\n" successfully connected to hub 2019-09-25 09:17:27,431 [DEBUG] koji: url: https://localhost/kojihub 2019-09-25 09:17:27,431 [DEBUG] koji: headers: {'User-Agent': 'koji/1', 'Content-Type': 'text/xml', 'Content-Length': '4040'} 2019-09-25 09:17:27,431 [DEBUG] koji: Opening new requests session Traceback (most recent call last): File "/usr/bin/koji", line 336, in <module> rv = locals()[command].__call__(options, session, args) File "/usr/lib/python3.7/site-packages/koji_cli/commands.py", line 876, in handle_call response = getattr(session, name).__call__(*non_kw, **kw) File "/home/mike/Devel/koji/koji/koji/__init__.py", line 2094, in __call__ return self.__func(self.__name, args, opts) File "/home/mike/Devel/koji/koji/koji/__init__.py", line 2582, in _callMethod return self._sendCall(handler, headers, request) File "/home/mike/Devel/koji/koji/koji/__init__.py", line 2504, in _sendCall return self._sendOneCall(handler, headers, request) File "/home/mike/Devel/koji/koji/koji/__init__.py", line 2539, in _sendOneCall _val = _val[:1024] + six.b('...') TypeError: can only concatenate str (not "bytes") to str
Makes sense - I was too hasty.
Probably the thing to do is check for the bytes case and convert that to a string first (perhaps as hex)
rebased onto 80484f0d669761cfe3434b6f50f6cf7804fec0f0
please review again (@breilly, @julian8628, @mikem)
Commit e54f9fdd fixes this pull-request
Pull-Request has been merged by tkopecek
Fixes: https://pagure.io/koji/issue/1656