8000 gh-111654: remove redundant decref on the eval stack value by aisk · Pull Request #111655 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content
8000

gh-111654: remove redundant decref on the eval stack value #111655

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 1 commit into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 7 additions & 0 deletions Lib/test/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1844,6 +1844,13 @@ def f():
self.assertIn("nonsense", err.getvalue())
self.assertIn("ZeroDivisionError", err.getvalue())

def test_gh_111654(self):
def f():
class TestClass:
TestClass

self.assertRaises(NameError, f)

# Note: name suggestion tests live in `test_traceback`.


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix runtime crash when some error happens in opcode
``LOAD_FROM_DICT_OR_DEREF``.
3 changes: 1 addition & 2 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1537,10 +1537,8 @@ dummy_func(
assert(oparg >= 0 && oparg < _PyFrame_GetCode(frame)->co_nlocalsplus);
name = PyTuple_GET_ITEM(_PyFrame_GetCode(frame)->co_localsplusnames, oparg);
if (PyMapping_GetOptionalItem(class_dict, name, &value) < 0) {
Py_DECREF(class_dict);
GOTO_ERROR(error);
}
Py_DECREF(class_dict);
if (!value) {
PyObject *cell = GETLOCAL(oparg);
value = PyCell_GET(cell);
Expand All @@ -1550,6 +1548,7 @@ dummy_func(
}
Py_INCREF(value);
}
Py_DECREF(class_dict);
Copy link
Member
@iritkatriel iritkatriel Nov 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This DECREF won't happen if we GOTO_ERROR on line 1547. Is that the idea?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is the expected behavior. I'll add some notes on the first comment.

}

inst(LOAD_DEREF, ( -- value)) {
Expand Down
3 changes: 1 addition & 2 deletions Python/executor_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Python/generated_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0