mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
[3.12] gh-111654: remove redundant decref in LOAD_FROM_DICT_OR_DEREF (GH-111655) (#111674)
(cherry picked from commit 3a1b09e6d0
)
Co-authored-by: AN Long <aisk@users.noreply.github.com>
This commit is contained in:
parent
4db71c3ca7
commit
1a95ad68b4
4 changed files with 286 additions and 281 deletions
|
@ -1824,6 +1824,13 @@ class NameErrorTests(unittest.TestCase):
|
||||||
self.assertIn("nonsense", err.getvalue())
|
self.assertIn("nonsense", err.getvalue())
|
||||||
self.assertIn("ZeroDivisionError", 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`.
|
# Note: name suggestion tests live in `test_traceback`.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
Fix runtime crash when some error happens in opcode
|
||||||
|
``LOAD_FROM_DICT_OR_DEREF``.
|
|
@ -1425,7 +1425,6 @@ dummy_func(
|
||||||
Py_INCREF(value);
|
Py_INCREF(value);
|
||||||
}
|
}
|
||||||
else if (_PyErr_Occurred(tstate)) {
|
else if (_PyErr_Occurred(tstate)) {
|
||||||
Py_DECREF(class_dict);
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1433,13 +1432,11 @@ dummy_func(
|
||||||
value = PyObject_GetItem(class_dict, name);
|
value = PyObject_GetItem(class_dict, name);
|
||||||
if (value == NULL) {
|
if (value == NULL) {
|
||||||
if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) {
|
if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) {
|
||||||
Py_DECREF(class_dict);
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
_PyErr_Clear(tstate);
|
_PyErr_Clear(tstate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Py_DECREF(class_dict);
|
|
||||||
if (!value) {
|
if (!value) {
|
||||||
PyObject *cell = GETLOCAL(oparg);
|
PyObject *cell = GETLOCAL(oparg);
|
||||||
value = PyCell_GET(cell);
|
value = PyCell_GET(cell);
|
||||||
|
@ -1449,6 +1446,7 @@ dummy_func(
|
||||||
}
|
}
|
||||||
Py_INCREF(value);
|
Py_INCREF(value);
|
||||||
}
|
}
|
||||||
|
Py_DECREF(class_dict);
|
||||||
}
|
}
|
||||||
|
|
||||||
inst(LOAD_DEREF, ( -- value)) {
|
inst(LOAD_DEREF, ( -- value)) {
|
||||||
|
|
554
Python/generated_cases.c.h
generated
554
Python/generated_cases.c.h
generated
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue