summaryrefslogtreecommitdiffstats
path: root/meta-python/recipes-devtools/python/python3-gevent/py-3.11.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-python/recipes-devtools/python/python3-gevent/py-3.11.patch')
-rw-r--r--meta-python/recipes-devtools/python/python3-gevent/py-3.11.patch170
1 files changed, 0 insertions, 170 deletions
diff --git a/meta-python/recipes-devtools/python/python3-gevent/py-3.11.patch b/meta-python/recipes-devtools/python/python3-gevent/py-3.11.patch
deleted file mode 100644
index 6750c1a3cf..0000000000
--- a/meta-python/recipes-devtools/python/python3-gevent/py-3.11.patch
+++ /dev/null
@@ -1,170 +0,0 @@
1From 90e9169c915a640739880b55ed95f88ce21fa7b0 Mon Sep 17 00:00:00 2001
2From: Victor Stinner <vstinner@python.org>
3Date: Tue, 1 Mar 2022 22:28:40 +0100
4Subject: [PATCH] Add Python 3.11 alpha 6 support
5
6* On Python 3.11a6 and newer, get the PyFrameObject structure from
7 the internal C API ("internal/pycore_frame.h").
8* On Python 3.9 and newer, use PyFrame_GetBack() and
9 PyFrame_GetCode().
10* Add frame getter and setter functions to greenlet:
11
12 * get_f_code(frame)
13 * set_f_lineno(frame, lineno)
14 * set_f_code(frame, code)
15
16* greenlet.h: the CFrame type has been renamed to _PyCFrame.
17
18Upstream-Status: Submitted [https://github.com/gevent/gevent/pull/1872]
19Signed-off-by: Alexander Kanavin <alex@linutronix.de>
20---
21 _setuputils.py | 4 +++
22 deps/greenlet/greenlet.h | 6 +++-
23 src/gevent/_gevent_cgreenlet.pxd | 59 ++++++++++++++++++++++++--------
24 src/gevent/greenlet.py | 7 ++--
25 4 files changed, 59 insertions(+), 17 deletions(-)
26
27diff --git a/_setuputils.py b/_setuputils.py
28index 7257b3eea..0b14ab1f0 100644
29--- a/_setuputils.py
30+++ b/_setuputils.py
31@@ -244,6 +244,10 @@ def cythonize1(ext):
32 'infer_types': True,
33 'nonecheck': False,
34 },
35+ compile_time_env={
36+ 'PY39B1': sys.hexversion >= 0x030900B1,
37+ 'PY311A6': sys.hexversion >= 0x030B00A6,
38+ },
39 # The common_utility_include_dir (not well documented)
40 # causes Cython to emit separate files for much of the
41 # static support code. Each of the modules then includes
42diff --git a/deps/greenlet/greenlet.h b/deps/greenlet/greenlet.h
43index 830bef8dd..f07ce1833 100644
44--- a/deps/greenlet/greenlet.h
45+++ b/deps/greenlet/greenlet.h
46@@ -14,6 +14,10 @@ extern "C" {
47 /* This is deprecated and undocumented. It does not change. */
48 #define GREENLET_VERSION "1.0.0"
49
50+#if PY_VERSION_HEX < 0x30B00A6
51+# define _PyCFrame CFrame
52+#endif
53+
54 typedef struct _greenlet {
55 PyObject_HEAD
56 char* stack_start;
57@@ -39,7 +43,7 @@ typedef struct _greenlet {
58 PyObject* context;
59 #endif
60 #if PY_VERSION_HEX >= 0x30A00B1
61- CFrame* cframe;
62+ _PyCFrame* cframe;
63 #endif
64 } PyGreenlet;
65
66diff --git a/src/gevent/_gevent_cgreenlet.pxd b/src/gevent/_gevent_cgreenlet.pxd
67index cbb81a638..246773e24 100644
68--- a/src/gevent/_gevent_cgreenlet.pxd
69+++ b/src/gevent/_gevent_cgreenlet.pxd
70@@ -57,30 +57,61 @@ cdef extern from "Python.h":
71 ctypedef class types.CodeType [object PyCodeObject]:
72 pass
73
74-cdef extern from "frameobject.h":
75-
76- ctypedef class types.FrameType [object PyFrameObject]:
77- cdef CodeType f_code
78- # Accessing the f_lineno directly doesn't work. There is an accessor
79- # function, PyFrame_GetLineNumber that is needed to turn the raw line number
80- # into the executing line number.
81- # cdef int f_lineno
82- # We can't declare this in the object as an object, because it's
83- # allowed to be NULL, and Cython can't handle that.
84- # We have to go through the python machinery to get a
85- # proper None instead, or use an inline function.
86- cdef void* f_back
87+IF PY311A6:
88+ cdef extern from "internal/pycore_frame.h":
89+ ctypedef class types._PyInterpreterFrame [object _PyInterpreterFrame]:
90+ cdef CodeType f_code
91+
92+ ctypedef class types.FrameType [object PyFrameObject]:
93+ cdef _PyInterpreterFrame f_frame
94+ # Accessing the f_lineno directly doesn't work. There is an accessor
95+ # function, PyFrame_GetLineNumber that is needed to turn the raw line number
96+ # into the executing line number.
97+ # cdef int f_lineno
98+ # We can't declare this in the object as an object, because it's
99+ # allowed to be NULL, and Cython can't handle that.
100+ # We have to go through the python machinery to get a
101+ # proper None instead, or use an inline function.
102+ cdef void* f_back
103+ELSE:
104+ cdef extern from "frameobject.h":
105+ ctypedef class types.FrameType [object PyFrameObject]:
106+ cdef CodeType f_code
107+ cdef void* f_back
108
109+cdef extern from "frameobject.h":
110 int PyFrame_GetLineNumber(FrameType frame)
111+ IF PY39B1:
112+ CodeType PyFrame_GetCode(FrameType frame)
113+ void* PyFrame_GetBack(FrameType frame)
114
115 @cython.nonecheck(False)
116 cdef inline FrameType get_f_back(FrameType frame):
117+ IF PY39B1:
118+ f_back = PyFrame_GetBack(frame)
119+ ELSE:
120+ f_back = frame.f_back
121 if frame.f_back != NULL:
122- return <FrameType>frame.f_back
123+ return <FrameType>f_back
124
125 cdef inline int get_f_lineno(FrameType frame):
126 return PyFrame_GetLineNumber(frame)
127
128+cdef inline void set_f_lineno(FrameType frame, int lineno):
129+ frame.f_lineno = lineno
130+
131+cdef inline CodeType get_f_code(FrameType frame):
132+ IF PY39B1:
133+ return PyFrame_GetCode(frame)
134+ ELSE:
135+ return frame.f_code
136+
137+cdef inline void set_f_code(FrameType frame, CodeType code):
138+ IF PY311A6:
139+ frame.f_frame.f_code = code
140+ ELSE:
141+ frame.f_code = code
142+
143 cdef void _init()
144
145 cdef class SpawnedLink:
146diff --git a/src/gevent/greenlet.py b/src/gevent/greenlet.py
147index bed12ed44..f925770bb 100644
148--- a/src/gevent/greenlet.py
149+++ b/src/gevent/greenlet.py
150@@ -58,6 +58,9 @@
151 # Frame access
152 locals()['get_f_back'] = lambda frame: frame.f_back
153 locals()['get_f_lineno'] = lambda frame: frame.f_lineno
154+locals()['set_f_lineno'] = lambda frame, lineno: setattr(frame, 'f_lineno', lineno)
155+locals()['get_f_code'] = lambda frame: frame.f_code
156+locals()['set_f_code'] = lambda frame, code: setattr(frame, 'f_code', code)
157
158 if _PYPY:
159 import _continuation # pylint:disable=import-error
160@@ -157,8 +160,8 @@ def _extract_stack(limit):
161 # Arguments are always passed to the constructor as Python objects,
162 # meaning we wind up boxing the f_lineno just to unbox it if we pass it.
163 # It's faster to simply assign once the object is created.
164- older_Frame.f_code = frame.f_code
165- older_Frame.f_lineno = get_f_lineno(frame) # pylint:disable=undefined-variable
166+ set_f_code(older_Frame.f_code, get_f_code(frame))
167+ set_f_lineno(older_Frame.f_lineno, get_f_lineno(frame)) # pylint:disable=undefined-variable
168 if newer_Frame is not None:
169 newer_Frame.f_back = older_Frame
170 newer_Frame = older_Frame