On Thu, 2 Sep 2021, 7:08 am Victor Stinner, <vstinner@python.org> wrote:
I saw Python projects injecting fake frames for XML and JSON parsers,
maybe also configuration file (.ini?) parsers. So text files which
have line numbers ;-)

On Wed, Sep 1, 2021 at 7:33 PM Pablo Galindo Salgado
<pablogsal@gmail.com> wrote:
> I don't think we should think on those terms. We certainly don't want to be on a case
> where yet again we cannot change the internals because we have an official C-API exposed.

PyCode_New() is annoying since it requires to provide *all* arguments.
I'm thinking of an Frame API which only allows to set 2 values:
filename and line number. Nothing else.

Something like: frame = PyFrame_New(filename, lineno).


Perhaps "PyCode_FromLocation(file name, lineno)" for the new "good enough to satisfy trace hooks and exception tracebacks" API? These are needed when creating function-like (et al) objects from extension module code, not just for runtime frames.

And then explicitly define which code object fields are expected to always be populated and which are expected to be None on emulated code objects that don't contain Python byte code? (e.g. some fields should be zero or the empty tuple, rather than being set to None)

Cheers,
Nick.