From: Adi Roiban <adiroiban@gmail.com>
Date: Tue, 30 Sep 2025 19:04:07 +0100
Subject: Strip trailing hash for Python 3.14

Origin: backport, https://github.com/twisted/twisted/pull/12511
Bug: https://github.com/twisted/twisted/issues/12427
Bug: https://github.com/twisted/twisted/issues/12510
Bug-Debian: https://bugs.debian.org/1122044
Last-Update: 2025-12-07
---
 src/twisted/web/client.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/twisted/web/client.py b/src/twisted/web/client.py
index d3cd11f..4484db7 100644
--- a/src/twisted/web/client.py
+++ b/src/twisted/web/client.py
@@ -220,7 +220,10 @@ def _urljoin(base, url):
     """
     base, baseFrag = urldefrag(base)
     url, urlFrag = urldefrag(urljoin(base, url))
-    return urljoin(url, b"#" + (urlFrag or baseFrag))
+    # We strip the hash to get test pass on Python 3.14
+    # Looks like a regression in 3.14
+    # See https://github.com/twisted/twisted/issues/12427
+    return urljoin(url, b"#" + (urlFrag or baseFrag)).strip(b"#")
 
 
 def _makeGetterFactory(url, factoryFactory, contextFactory=None, *args, **kwargs):
