@@ -16,6 +16,11 @@ using greenlet::refs::OwnedGreenlet;
16
16
using greenlet::refs::OwnedMainGreenlet;
17
17
using greenlet::refs::BorrowedGreenlet;
18
18
19
+ #if PY_VERSION_HEX < 0x30B00A6
20
+ # define _PyCFrame CFrame
21
+ # define _PyInterpreterFrame _interpreter_frame
22
+ #endif
23
+
19
24
// XXX: TODO: Work to remove all virtual functions
20
25
// for speed of calling and size of objects (no vtable).
21
26
// One pattern is the Curiously Recurring Template
@@ -133,13 +138,13 @@ namespace greenlet
133
138
// won't be reachable from the place that normally decref's
134
139
// it, so we need to do it (hence owning it).
135
140
OwnedFrame _top_frame;
136
- #if GREENLET_USE_CFRAME
137
- CFrame * cframe;
141
+ #if GREENLET_USE_CFRAME
142
+ _PyCFrame * cframe;
138
143
int use_tracing;
139
144
#endif
140
145
int recursion_depth;
141
146
#if GREENLET_PY311
142
- _interpreter_frame *current_frame;
147
+ _PyInterpreterFrame *current_frame;
143
148
_PyStackChunk *datastack_chunk;
144
149
PyObject **datastack_top;
145
150
PyObject **datastack_limit;
@@ -160,7 +165,7 @@ namespace greenlet
160
165
void tp_clear (bool own_top_frame) G_NOEXCEPT;
161
166
void set_initial_state (const PyThreadState* const tstate) G_NOEXCEPT;
162
167
#if GREENLET_USE_CFRAME
163
- void set_new_cframe (CFrame & frame) G_NOEXCEPT;
168
+ void set_new_cframe (_PyCFrame & frame) G_NOEXCEPT;
164
169
#endif
165
170
void will_switch_from (PyThreadState *const origin_tstate) G_NOEXCEPT;
166
171
};
@@ -759,7 +764,7 @@ PythonState::PythonState()
759
764
one from the greenlet parent for the same reason. Yet a further
760
765
no: we can't allocate one scoped to the greenlet and then
761
766
destroy it when the greenlet is deallocated, because inside the
762
- interpreter the CFrame objects form a linked list, and that too
767
+ interpreter the _PyCFrame objects form a linked list, and that too
763
768
can result in accessing memory beyond its dynamic lifetime (if
764
769
the greenlet doesn't actually finish before it dies, its entry
765
770
could still be in the list).
@@ -778,14 +783,14 @@ PythonState::PythonState()
778
783
creation, it uses the ``root_cframe`` just to have something to
779
784
put there. However, once the greenlet is actually switched to
780
785
for the first time, ``g_initialstub`` (which doesn't actually
781
- "return" while the greenlet is running) stores a new CFrame on
786
+ "return" while the greenlet is running) stores a new _PyCFrame on
782
787
its local stack, and copies the appropriate values from the
783
- currently running CFrame ; this is then made the CFrame for the
788
+ currently running _PyCFrame ; this is then made the _PyCFrame for the
784
789
newly-minted greenlet. ``g_initialstub`` then proceeds to call
785
790
``glet.run()``, which results in ``PyEval_...`` adding the
786
- CFrame to the list. Switches continue as normal. Finally, when
791
+ _PyCFrame to the list. Switches continue as normal. Finally, when
787
792
the greenlet finishes, the call to ``glet.run()`` returns and
788
- the CFrame is taken out of the linked list and the stack value
793
+ the _PyCFrame is taken out of the linked list and the stack value
789
794
is now unused and free to expire.
790
795
791
796
XXX: I think we can do better. If we're deallocing in the same
@@ -907,7 +912,7 @@ void PythonState::tp_clear(bool own_top_frame) G_NOEXCEPT
907
912
}
908
913
909
914
#if GREENLET_USE_CFRAME
910
- void PythonState::set_new_cframe (CFrame & frame) G_NOEXCEPT
915
+ void PythonState::set_new_cframe (_PyCFrame & frame) G_NOEXCEPT
911
916
{
912
917
frame = *PyThreadState_GET ()->cframe ;
913
918
/* Make the target greenlet refer to the stack value. */
0 commit comments