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 3a1b09e

Browse filesBrowse files
authored
gh-111654: remove redundant decref in LOAD_FROM_DICT_OR_DEREF (#111655)
1 parent 93206d1 commit 3a1b09e
Copy full SHA for 3a1b09e

File tree

Expand file treeCollapse file tree

5 files changed

+12
-6
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+12
-6
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
@@ -1844,6 +1844,13 @@ def f():
18441844
self.assertIn("nonsense", err.getvalue())
18451845
self.assertIn("ZeroDivisionError", err.getvalue())
18461846

1847+
def test_gh_111654(self):
1848+
def f():
1849+
class TestClass:
1850+
TestClass
1851+
1852+
self.assertRaises(NameError, f)
1853+
18471854
# Note: name suggestion tests live in `test_traceback`.
18481855

18491856

+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-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,10 +1535,8 @@ dummy_func(
15351535
assert(oparg >= 0 && oparg < _PyFrame_GetCode(frame)->co_nlocalsplus);
15361536
name = PyTuple_GET_ITEM(_PyFrame_GetCode(frame)->co_localsplusnames, oparg);
15371537
if (PyMapping_GetOptionalItem(class_dict, name, &value) < 0) {
1538-
Py_DECREF(class_dict);
15391538
GOTO_ERROR(error);
15401539
}
1541-
Py_DECREF(class_dict);
15421540
if (!value) {
15431541
PyObject *cell = GETLOCAL(oparg);
15441542
value = PyCell_GET(cell);
@@ -1548,6 +1546,7 @@ dummy_func(
15481546
}
15491547
Py_INCREF(value);
15501548
}
1549+
Py_DECREF(class_dict);
15511550
}
15521551

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

‎Python/executor_cases.c.h

Copy file name to clipboardExpand all lines: Python/executor_cases.c.h
+1-2Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Python/generated_cases.c.h

Copy file name to clipboardExpand all lines: Python/generated_cases.c.h
+1-2Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

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