Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1fc0752

Browse filesBrowse files
committed
Fix confusion of enum _framestate with enum _frameowner
The owner field of _PyInterpreterFrame is supposed to be a member of enum _frameowner, but FRAME_CLEARED is a member of enum _framestate. Add FRAME_OWNED_BY_ACCIDENT to enum _frameowner and use that instead. (It happens to have the same numerical value, but we shouldn’t rely on that anywhere.) Signed-off-by: Anders Kaseorg <andersk@mit.edu>
1 parent eaa1eae commit 1fc0752
Copy full SHA for 1fc0752

File tree

2 files changed

+4
-3
lines changed
Filter options

2 files changed

+4
-3
lines changed

‎Include/internal/pycore_frame.h

Copy file name to clipboardExpand all lines: Include/internal/pycore_frame.h
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ enum _frameowner {
4444
FRAME_OWNED_BY_GENERATOR = 1,
4545
FRAME_OWNED_BY_FRAME_OBJECT = 2,
4646
FRAME_OWNED_BY_CSTACK = 3,
47+
FRAME_OWNED_BY_ACCIDENT = 4,
4748
};
4849

4950
typedef struct _PyInterpreterFrame {

‎Python/frame.c

Copy file name to clipboardExpand all lines: Python/frame.c
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ _PyFrame_MakeAndSetFrameObject(_PyInterpreterFrame *frame)
5050
// Just pretend that we have an owned, cleared frame so frame_dealloc
5151
// doesn't make the situation worse:
5252
f->f_frame = (_PyInterpreterFrame *)f->_f_frame_data;
53-
f->f_frame->owner = FRAME_CLEARED;
53+
f->f_frame->owner = FRAME_OWNED_BY_ACCIDENT;
5454
f->f_frame->frame_obj = f;
5555
Py_DECREF(f);
5656
return frame->frame_obj;
5757
}
5858
assert(frame->owner != FRAME_OWNED_BY_FRAME_OBJECT);
59-
assert(frame->owner != FRAME_CLEARED);
59+
assert(frame->owner != FRAME_OWNED_BY_ACCIDENT);
6060
f->f_frame = frame;
6161
frame->frame_obj = f;
6262
return f;
@@ -79,7 +79,7 @@ take_ownership(PyFrameObject *f, _PyInterpreterFrame *frame)
7979
{
8080
assert(frame->owner != FRAME_OWNED_BY_CSTACK);
8181
assert(frame->owner != FRAME_OWNED_BY_FRAME_OBJECT);
82-
assert(frame->owner != FRAME_CLEARED);
82+
assert(frame->owner != FRAME_OWNED_BY_ACCIDENT);
8383
Py_ssize_t size = ((char*)&frame->localsplus[frame->stacktop]) - (char *)frame;
8484
Py_INCREF(_PyFrame_GetCode(frame));
8585
memcpy((_PyInterpreterFrame *)f->_f_frame_data, frame, size);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.