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`.
--- /dev/null
+Fix runtime crash when some error happens in opcode
+``LOAD_FROM_DICT_OR_DEREF``.
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);
}
Py_INCREF(value);
}
+ Py_DECREF(class_dict);
}
inst(LOAD_DEREF, ( -- value)) {
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);
}
Py_INCREF(value);
}
+ Py_DECREF(class_dict);
stack_pointer[-1] = value;
break;
}
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);
}
Py_INCREF(value);
}
+ Py_DECREF(class_dict);
stack_pointer[-1] = value;
DISPATCH();
}