Skip to content

Commit

Permalink
Sanitize sys.version output
Browse files Browse the repository at this point in the history
Apparently some versions of Python on some platforms add a new-line
character inside the version string which breaks HTTP headers:

   File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/http/client.py", line 1263, in putheader
    raise ValueError('Invalid header value %r' % (values[i],))
ValueError: Invalid header value b'tcms-api/12.8.2/Python 3.9.18 (main, Aug 28 2023, 08:38:32) \n[GCC 11.4.0]'
  • Loading branch information
atodorov committed Jan 11, 2024
1 parent c32cb52 commit 1eb0d5e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tcms_api/xmlrpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@


VERBOSE = 0
_PYTHON_VERSION = sys.version.replace("\n", "")


class TCMSProxy(ServerProxy):
Expand All @@ -34,7 +35,7 @@ class CookieTransport(Transport):
"""A subclass of xmlrpc.client.Transport that supports cookies."""

scheme = "http"
user_agent = f"tcms-api/{__version__}/Python {sys.version}"
user_agent = f"tcms-api/{__version__}/Python {_PYTHON_VERSION}"

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
Expand Down

0 comments on commit 1eb0d5e

Please sign in to comment.