Author vstinner
Recipients Mark.Shannon, brett.cannon, dino.viehland, eric.snow, fabioz, gregory.p.smith, lukasz.langa, phsilva, vstinner
Date 2020-03-10.17:45:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I plan to merge my PR 17340 at the end of week to not miss Python 3.9 feature freeze deadline, unless someone speaks up and find a good reason to not merge this PR. The PR adds a public C API PyInterpreterState_SetEvalFrameFunc() and now pass tstate to the frame evaluation function.


Mark Shannon is against the idea of providing a way to set the frame evaluation function (PEP 523), but Dino Viehland, Eric Snow, Brett Cannon and me want to provide a C API for that.


I propose to properly fix this issue in Python 3.9:

* Add a public C API to get and set the frame evaluation function
* Pass tstate to this frame evaluation function

Pass tstate is a backward incompatible change. But it's unclear to me if its API was part of the "public" C API in Python 3.7. In Python 3.8, PyInterpreterState structure moved to the internal C API which is clearly excluded from backward compatibility warranties of the public C API.

Anyway, I expect that they are less than 10 projects in the world which use the frame evaluation function, which it should be doable to update all of them to support the C API for Python 3.9 that I'm proposing.


> This is no longer possible because in 3.8 the PyInterpreterState is opaque, so, Py_BUILD_CORE_MODULE needs to be defined defined and "internal/pycore_pystate.h" must be included to set PyInterpreterState.eval_frame.

The status quo is that Python 3.8.0, 3.8.1 and 3.8.2 have been released with that. If someone wants to support "Python 3.8", using Py_BUILD_CORE_MODULE to access the internal C API is the way to go. If we wanted to add a public C API in Python 3.8, IMHO we had to do it *before Python 3.8.0 release. Now it's way too late.
Date User Action Args
2020-03-10 17:45:43vstinnersetrecipients: + vstinner, brett.cannon, gregory.p.smith, fabioz, phsilva, dino.viehland, lukasz.langa, Mark.Shannon, eric.snow
2020-03-10 17:45:43vstinnersetmessageid: <>
2020-03-10 17:45:43vstinnerlinkissue38500 messages
2020-03-10 17:45:42vstinnercreate