GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-100762: Fix optimization in gen_close by iritkatriel · Pull Request #111069 · python/cpython

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.

Sign up for GitHub

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
iritkatriel merged 6 commits into python:main from iritkatriel:refleak
Oct 25, 2023

Uh oh!

There was an error while loading. Please reload this page.

Merged

gh-100762: Fix optimization in gen_close #111069

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
6 commits
Select commit Hold shift + click to select a range
084c91a
gh-100762: fix refleak in gen_close
iritkatriel Oct 19, 2023
eafd6b1
assert instead
iritkatriel Oct 19, 2023
d3e4f64
op.code --> op.arg
iritkatriel Oct 19, 2023
9a83cf8
whitespace
iritkatriel Oct 19, 2023
90d6409
set frame state when returning early
iritkatriel Oct 20, 2023
86b325d
apply review comments
iritkatriel Oct 24, 2023
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

4 changes: 2 additions & 2 deletions 4 Lib/test/test_cprofile.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ def test_throw(self):

for func, (cc, nc, _, _, _) in pr.stats.items():
if func[2] == "<genexpr>":
self.assertEqual(cc, 2)
self.assertEqual(nc, 2)
self.assertEqual(cc, 1)
self.assertEqual(nc, 1)


class TestCommandLine(unittest.TestCase):
Expand Down
4 changes: 0 additions & 4 deletions 4 Lib/test/test_sys_setprofile.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,6 @@ def g(p):
f_ident = ident(f)
g_ident = ident(g)
self.check_events(g, [(1, 'call', g_ident),
(2, 'call', f_ident),
(2, 'return', f_ident),
# once more; the generator is being garbage collected
# and it will do a PY_THROW
(2, 'call', f_ident),
(2, 'return', f_ident),
(1, 'return', g_ident),
Expand Down
5 changes: 3 additions & 2 deletions 5 Objects/genobject.c
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,6 @@ 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) {
Expand All @@ -388,6 +387,7 @@ gen_close(PyGenObject *gen, PyObject *args)
if (gen->gi_frame_state >= FRAME_COMPLETED) {
Py_RETURN_NONE;
}
PyObject *yf = _PyGen_yf(gen);
if (yf) {
PyFrameState state = gen->gi_frame_state;
gen->gi_frame_state = FRAME_EXECUTING;
Expand All @@ -400,12 +400,13 @@ gen_close(PyGenObject *gen, PyObject *args)
* YIELD_VALUE if the debugger has changed the lineno. */
if (err == 0 && is_yield(frame->prev_instr)) {
assert(is_resume(frame->prev_instr + 1));
int exception_handler_depth = frame->prev_instr[0].op.code;
int exception_handler_depth = frame->prev_instr[0].op.arg;
assert(exception_handler_depth > 0);
/* We can safely ignore the outermost try block
* as it automatically generated to handle
* StopIteration. */
if (exception_handler_depth == 1) {
gen->gi_frame_state = FRAME_COMPLETED;
Py_RETURN_NONE;
}
}
Expand Down
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.