Skip to content

Commit 3cbbfd4

Browse files
authored
Merge pull request #294 from vstinner/py311a6
Update for Python 3.11 alpha 6
2 parents ecaad8d + b8d0281 commit 3cbbfd4

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
runs-on: ${{ matrix.os }}
2626
strategy:
2727
matrix:
28-
python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9, "3.10", "3.11.0-alpha.4"]
28+
python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9, "3.10", "3.11.0-alpha.6"]
2929
os: [ubuntu-latest, macos-latest]
3030
steps:
3131
- uses: actions/checkout@v2

src/greenlet/greenlet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,7 @@ UserGreenlet::g_initialstub(void* mark)
10341034
We want to defer copying the state info until we're sure
10351035
we need it and are in a stable place to do so.
10361036
*/
1037-
CFrame trace_info;
1037+
_PyCFrame trace_info;
10381038

10391039
this->python_state.set_new_cframe(trace_info);
10401040
#endif

src/greenlet/greenlet_greenlet.hpp

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ using greenlet::refs::OwnedGreenlet;
1616
using greenlet::refs::OwnedMainGreenlet;
1717
using greenlet::refs::BorrowedGreenlet;
1818

19+
#if PY_VERSION_HEX < 0x30B00A6
20+
# define _PyCFrame CFrame
21+
# define _PyInterpreterFrame _interpreter_frame
22+
#endif
23+
1924
// XXX: TODO: Work to remove all virtual functions
2025
// for speed of calling and size of objects (no vtable).
2126
// One pattern is the Curiously Recurring Template
@@ -133,13 +138,13 @@ namespace greenlet
133138
// won't be reachable from the place that normally decref's
134139
// it, so we need to do it (hence owning it).
135140
OwnedFrame _top_frame;
136-
#if GREENLET_USE_CFRAME
137-
CFrame* cframe;
141+
#if GREENLET_USE_CFRAME
142+
_PyCFrame* cframe;
138143
int use_tracing;
139144
#endif
140145
int recursion_depth;
141146
#if GREENLET_PY311
142-
_interpreter_frame *current_frame;
147+
_PyInterpreterFrame *current_frame;
143148
_PyStackChunk *datastack_chunk;
144149
PyObject **datastack_top;
145150
PyObject **datastack_limit;
@@ -160,7 +165,7 @@ namespace greenlet
160165
void tp_clear(bool own_top_frame) G_NOEXCEPT;
161166
void set_initial_state(const PyThreadState* const tstate) G_NOEXCEPT;
162167
#if GREENLET_USE_CFRAME
163-
void set_new_cframe(CFrame& frame) G_NOEXCEPT;
168+
void set_new_cframe(_PyCFrame& frame) G_NOEXCEPT;
164169
#endif
165170
void will_switch_from(PyThreadState *const origin_tstate) G_NOEXCEPT;
166171
};
@@ -759,7 +764,7 @@ PythonState::PythonState()
759764
one from the greenlet parent for the same reason. Yet a further
760765
no: we can't allocate one scoped to the greenlet and then
761766
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
763768
can result in accessing memory beyond its dynamic lifetime (if
764769
the greenlet doesn't actually finish before it dies, its entry
765770
could still be in the list).
@@ -778,14 +783,14 @@ PythonState::PythonState()
778783
creation, it uses the ``root_cframe`` just to have something to
779784
put there. However, once the greenlet is actually switched to
780785
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
782787
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
784789
newly-minted greenlet. ``g_initialstub`` then proceeds to call
785790
``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
787792
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
789794
is now unused and free to expire.
790795
791796
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
907912
}
908913

909914
#if GREENLET_USE_CFRAME
910-
void PythonState::set_new_cframe(CFrame& frame) G_NOEXCEPT
915+
void PythonState::set_new_cframe(_PyCFrame& frame) G_NOEXCEPT
911916
{
912917
frame = *PyThreadState_GET()->cframe;
913918
/* Make the target greenlet refer to the stack value. */

0 commit comments

Comments
 (0)