summaryrefslogtreecommitdiffstats
path: root/Include/internal/pycore_frame.h
diff options
context:
space:
mode:
Diffstat (limited to 'Include/internal/pycore_frame.h')
-rw-r--r--Include/internal/pycore_frame.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/Include/internal/pycore_frame.h b/Include/internal/pycore_frame.h
index 74d9e4c..f913928 100644
--- a/Include/internal/pycore_frame.h
+++ b/Include/internal/pycore_frame.h
@@ -110,7 +110,17 @@ _PyFrame_NumSlotsForCodeObject(PyCodeObject *code)
return code->co_framesize - FRAME_SPECIALS_SIZE;
}
-void _PyFrame_Copy(_PyInterpreterFrame *src, _PyInterpreterFrame *dest);
+static inline void _PyFrame_Copy(_PyInterpreterFrame *src, _PyInterpreterFrame *dest)
+{
+ assert(src->stacktop >= _PyFrame_GetCode(src)->co_nlocalsplus);
+ *dest = *src;
+ for (int i = 1; i < src->stacktop; i++) {
+ dest->localsplus[i] = src->localsplus[i];
+ }
+ // Don't leave a dangling pointer to the old frame when creating generators
+ // and coroutines:
+ dest->previous = NULL;
+}
/* Consumes reference to func and locals.
Does not initialize frame->previous, which happens
@@ -256,7 +266,7 @@ _PyThreadState_HasStackSpace(PyThreadState *tstate, int size)
extern _PyInterpreterFrame *
_PyThreadState_PushFrame(PyThreadState *tstate, size_t size);
-void _PyThreadState_PopFrame(PyThreadState *tstate, _PyInterpreterFrame *frame);
+PyAPI_FUNC(void) _PyThreadState_PopFrame(PyThreadState *tstate, _PyInterpreterFrame *frame);
/* Pushes a frame without checking for space.
* Must be guarded by _PyThreadState_HasStackSpace()