8000 gh-100762: Fix optimization in gen_close by iritkatriel · Pull Request #111069 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-100762: Fix optimization in gen_close #111069

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Oct 25, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
assert instead
  • Loading branch information
iritkatriel committed Oct 19, 2023
commit eafd6b15f7a38e3a8ea3773b4cb93a219ab827e9
4 changes: 3 additions & 1 deletion Objects/genobject.c
8F98
Original file line number Diff line number Diff line change
Expand Up @@ -378,17 +378,19 @@ static PyObject *
gen_close(PyGenObject *gen, PyObject *args)
{
PyObject *retval;
PyObject *yf = _PyGen_yf(gen);
int err = 0;

if (gen->gi_frame_state == FRAME_CREATED) {
assert(yf == NULL);
gen->gi_frame_state = FRAME_COMPLETED;
Py_RETURN_NONE;
}
if (gen->gi_frame_state >= FRAME_COMPLETED) {
assert(yf == NULL);
Py_RETURN_NONE;
}

PyObject *yf = _PyGen_yf(gen);
if (yf) {
PyFrameState state = gen->gi_frame_state;
gen->gi_frame_state = FRAME_EXECUTING;
Expand Down
0