summaryrefslogtreecommitdiff
path: root/dev-python/twisted/files/twisted-22.4.0-py311.patch
blob: ed8ded87d4de7903a6e1a3dea3b82b01ce9d07e7 (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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
From 074fc742a699278ea5266b34aace1e34049b3de3 Mon Sep 17 00:00:00 2001
From: Colin Watson <cjwatson@canonical.com>
Date: Sat, 23 Apr 2022 22:29:07 +0100
Subject: [PATCH] Implement twisted.python.failure._Code.co_positions

This is needed for compatibility with Python 3.11.
---
 src/twisted/newsfragments/10336.bugfix | 1 +
 src/twisted/python/failure.py          | 5 ++++-
 src/twisted/test/test_failure.py       | 1 +
 3 files changed, 6 insertions(+), 1 deletion(-)
 create mode 100644 src/twisted/newsfragments/10336.bugfix

diff --git a/src/twisted/newsfragments/10336.bugfix b/src/twisted/newsfragments/10336.bugfix
new file mode 100644
index 00000000000..a7ffab3627d
--- /dev/null
+++ b/src/twisted/newsfragments/10336.bugfix
@@ -0,0 +1 @@
+Implement twisted.python.failure._Code.co_positions for compatibility with Python 3.11.
diff --git a/src/twisted/python/failure.py b/src/twisted/python/failure.py
index 6471e7bca59..c5a359e405b 100644
--- a/src/twisted/python/failure.py
+++ b/src/twisted/python/failure.py
@@ -130,7 +130,7 @@ def _Traceback(stackFrames, tbFrames):
 
 
 # The set of attributes for _TracebackFrame, _Frame and _Code were taken from
-# https://docs.python.org/3.10/library/inspect.html Other Pythons may have a
+# https://docs.python.org/3.11/library/inspect.html Other Pythons may have a
 # few more attributes that should be added if needed.
 class _TracebackFrame:
     """
@@ -202,6 +202,9 @@ def __init__(self, name, filename):
         self.co_nlocals = 0
         self.co_stacksize = 0
 
+    def co_positions(self):
+        return ((None, None, None, None),)
+
 
 _inlineCallbacksExtraneous = []
 
diff --git a/src/twisted/test/test_failure.py b/src/twisted/test/test_failure.py
index 6dd7c682bf9..6fd82c868ec 100644
--- a/src/twisted/test/test_failure.py
+++ b/src/twisted/test/test_failure.py
@@ -825,6 +825,7 @@ def test_fakeCodeAttributes(self):
         self.assertIsInstance(code.co_nlocals, int)
         self.assertIsInstance(code.co_stacksize, int)
         self.assertIsInstance(code.co_varnames, list)
+        self.assertIsInstance(code.co_positions(), tuple)
 
     def test_fakeTracebackFrame(self):
         """