Skip to content

Commit 1eb0d5e

Browse files
committed
Sanitize sys.version output
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]'
1 parent c32cb52 commit 1eb0d5e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tcms_api/xmlrpc.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020

2121
VERBOSE = 0
22+
_PYTHON_VERSION = sys.version.replace("\n", "")
2223

2324

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

3637
scheme = "http"
37-
user_agent = f"tcms-api/{__version__}/Python {sys.version}"
38+
user_agent = f"tcms-api/{__version__}/Python {_PYTHON_VERSION}"
3839

3940
def __init__(self, *args, **kwargs):
4041
super().__init__(*args, **kwargs)

0 commit comments

Comments
 (0)