On Tue, Feb 8, 2022 at 9:49 AM Serhiy Storchaka <storch...@gmail.com> wrote:
>
> 07.02.22 17:55, Victor Stinner пише:
> > I'm asking to replace runtime checks with assertions when the C API is
> > "obviously" misused: replace PyErr_BadInternalCall(),
> > _Py_CheckFunctionResult() and _Py_CheckSlotResult() with assertions.
> > The exact scope should be defined.
>
> Would not be better to call Py_FatalError() in PyErr_BadInternalCall()
> etc? It can even be controlled by some option or envvar, even in release
> mode (just with different defaults in debug and release modes).

It's unrelated to what I said, but yeah it sounds like a good idea :-)
I already did it manually (local patch) sometimes to help me debugging
C extensions bugs, or when I ran a fuzzer on Python. Otherwise, the
SystemError exception raised by PyErr_BadInternalCall() can be "hidden
silently": a function can catch it and ignores it.

_Py_CheckFunctionResult() already uses Py_FatalError() if Python is
build with Py_DEBUG macro defined (debug build). Maybe we can do
something similar than iobase_finalize(): change the behavior (log an
exception) if Py_DEBUG or if dev_mode config is non-zero (python3 -X
dev / PYTHONDEVMODE=1).

Victor
-- 
Night gathers, and now my watch begins. It shall not end until my death.
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/M4FAFQRV23Z6LFTUJKTSSSPKGQRTRTX6/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to