File tree Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -812,7 +812,9 @@ def generate_finalize_for_class(
812812 )
813813 emitter .emit_line ("if (PyErr_Occurred() != NULL) {" )
814814 emitter .emit_line ('PyObject *del_str = PyUnicode_FromString("__del__");' )
815- emitter .emit_line ("PyObject *del_method = _PyType_Lookup(Py_TYPE(self), del_str);" )
815+ emitter .emit_line (
816+ "PyObject *del_method = (del_str == NULL) ? NULL : _PyType_Lookup(Py_TYPE(self), del_str);"
817+ )
816818 # CPython interpreter uses PyErr_WriteUnraisable: https://docs.python.org/3/c-api/exceptions.html#c.PyErr_WriteUnraisable
817819 # However, the message is slightly different due to the way mypyc compiles classes.
818820 # CPython interpreter prints: Exception ignored in: <function F.__del__ at 0x100aed940>
You can’t perform that action at this time.
0 commit comments