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 1a95ad6

Browse filesBrowse files
JelleZijlstraaisk
andauthored
[3.12] gh-111654: remove redundant decref in LOAD_FROM_DICT_OR_DEREF (GH-111655) (#111674)
(cherry picked from commit 3a1b09e) Co-authored-by: AN Long <aisk@users.noreply.github.com>
1 parent 4db71c3 commit 1a95ad6
Copy full SHA for 1a95ad6

File tree

Expand file treeCollapse file tree

4 files changed

+286
-281
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+286
-281
lines changed

‎Lib/test/test_exceptions.py

Copy file name to clipboardExpand all lines: Lib/test/test_exceptions.py
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1824,6 +1824,13 @@ def f():
18241824
self.assertIn("nonsense", err.getvalue())
18251825
self.assertIn("ZeroDivisionError", err.getvalue())
18261826

1827+
def test_gh_111654(self):
1828+
def f():
1829+
class TestClass:
1830+
TestClass
1831+
1832+
self.assertRaises(NameError, f)
1833+
18271834
# Note: name suggestion tests live in `test_traceback`.
18281835

18291836

+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix runtime crash when some error happens in opcode
2+
``LOAD_FROM_DICT_OR_DEREF``.

‎Python/bytecodes.c

Copy file name to clipboardExpand all lines: Python/bytecodes.c
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,21 +1425,18 @@ dummy_func(
14251425
Py_INCREF(value);
14261426
}
14271427
else if (_PyErr_Occurred(tstate)) {
1428-
Py_DECREF(class_dict);
14291428
goto error;
14301429
}
14311430
}
14321431
else {
14331432
value = PyObject_GetItem(class_dict, name);
14341433
if (value == NULL) {
14351434
if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) {
1436-
Py_DECREF(class_dict);
14371435
goto error;
14381436
}
14391437
_PyErr_Clear(tstate);
14401438
}
14411439
}
1442-
Py_DECREF(class_dict);
14431440
if (!value) {
14441441
PyObject *cell = GETLOCAL(oparg);
14451442
value = PyCell_GET(cell);
@@ -1449,6 +1446,7 @@ dummy_func(
14491446
}
14501447
Py_INCREF(value);
14511448
}
1449+
Py_DECREF(class_dict);
14521450
}
14531451

14541452
inst(LOAD_DEREF, ( -- value)) {

0 commit comments

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