summaryrefslogtreecommitdiffstats
path: root/debian/patches/python_3.12.4.diff
blob: 9e7d09a1b440ce07e32e76edb9c727266307a267 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
From: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Date: Tue, 23 Apr 2024 20:25:34 +0200
Subject: Fix `sphinx.util.inspect_evaluate_forwardref` for Python 3.12.4
 (#12317)

Python has recently [1] changed the signature of `_evaluate` for forward references
because of type parameters. The change affects 3.13, and was backported to 3.12.4.

[1]: https://github.com/python/cpython/pull/118104

(cherry picked from commit b5f3ef987ab5c2147d651ad84cc7d72c84ac6acc)
---
 sphinx/util/inspect.py | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/sphinx/util/inspect.py b/sphinx/util/inspect.py
index 6b13b29..dfb4e40 100644
--- a/sphinx/util/inspect.py
+++ b/sphinx/util/inspect.py
@@ -681,6 +681,13 @@ def _evaluate_forwardref(
     localns: dict[str, Any] | None,
 ) -> Any:
     """Evaluate a forward reference."""
+    if sys.version_info >= (3, 12, 4):
+        # ``type_params`` were added in 3.13 and the signature of _evaluate()
+        # is not backward-compatible (it was backported to 3.12.4, so anything
+        # before 3.12.4 still has the old signature).
+        #
+        # See: https://github.com/python/cpython/pull/118104.
+        return ref._evaluate(globalns, localns, {}, recursive_guard=frozenset())  # type: ignore[arg-type, misc]
     return ref._evaluate(globalns, localns, frozenset())