As of 3.12 _lsprof
no longer calls _PyEval_SetProfile
making sys.getprofile()
useless with cProfile
#130377
Labels
3.12
bugs and security fixes
3.13
bugs and security fixes
3.14
new features, bugs and security fixes
extension-modules
C modules in the Modules dir
type-bug
An unexpected behavior, bug, or error
Bug report
Bug description:
Starting in 3.12 with the addition of
sys.monitoring
,_lsprof
, specifically inprofiler_enable
, no longer calls_PyEval_SetProfile
.Very specifically, this impacts previous functionality where
python -m cProfile -m whatever
would result insys.setprofile()
being called, and subsequently thewhatever
module could access the profiler object viasys.getprofile()
To my knowledge this is now completely impossible as
sys.monitoring
provides no meaningful way to access the profiler object.In my particular use case, profiling could be enabled within the application, or if
python -m cProfile
was used, the existing profiler could be used allowing profiling to happen earlier than the enablement point ofcProfile
within the application.Something to the effect of:
CPython versions tested on:
3.13
Operating systems tested on:
Linux
The text was updated successfully, but these errors were encountered: