# HG changeset patch
# User Jan-Erik Rediger <jrediger@mozilla.com>
# Date 1756256998 0
#      Wed Aug 27 01:09:58 2025 +0000
# Node ID d4b3eb4f76e81f18c53863b1d55ee146d6ec7d10
# Parent  3f3cecb96480b861cfb31c2f1c0cba0da92e98ef
Bug 1983736 - Patch jsonschema to work with Python 3.14+ r=mach-reviewers,ahal,ahochheiden

Differential Revision: https://phabricator.services.mozilla.com/D262335

diff -r 3f3cecb96480 -r d4b3eb4f76e8 python/mozbuild/mozbuild/vendor/vendor_python.py
--- a/python/mozbuild/mozbuild/vendor/vendor_python.py	Wed Aug 27 00:50:51 2025 +0000
+++ b/python/mozbuild/mozbuild/vendor/vendor_python.py	Wed Aug 27 01:09:58 2025 +0000
@@ -40,6 +40,10 @@
     # modified 'dummy' version of it so that the dependency checks still succeed, but
     # if it ever is attempted to be used, it will fail gracefully.
     "ansicon",
+    # jsonschema 4.17.3 is incompatible with Python 3.14+,
+    # but later versions use a dependency with Rust components, which we thus can't vendor.
+    # For now we apply the minimal patch to jsonschema to make it work again.
+    "jsonschema",
 }
 
 
diff -r 3f3cecb96480 -r d4b3eb4f76e8 third_party/python/jsonschema/jsonschema/validators.py
--- a/third_party/python/jsonschema/jsonschema/validators.py	Wed Aug 27 00:50:51 2025 +0000
+++ b/third_party/python/jsonschema/jsonschema/validators.py	Wed Aug 27 01:09:58 2025 +0000
@@ -875,8 +875,11 @@
             return None
         uri, fragment = urldefrag(url)
         for subschema in subschemas:
+            id = subschema["$id"]
+            if not isinstance(id, str):
+                continue
             target_uri = self._urljoin_cache(
-                self.resolution_scope, subschema["$id"],
+                self.resolution_scope, id,
             )
             if target_uri.rstrip("/") == uri.rstrip("/"):
                 if fragment:
