Repository navigation
[Python] Move the PyROOT application setup to Python - #23699
Merged
guitargeek merged 2 commits intoOct 13, 2026
Merged
Conversation
PyROOT turns ROOT warnings into Python warnings with an error handler in its CPython extension module. It must not take the GIL while ROOT runs multithreaded: the reporting thread may hold ROOT's lock, which a thread holding the GIL may be waiting for. That check has to run before any Python code, so it can't move to Python with the rest of the handler. SetWarningHandler() installs an error handler that does the check and passes warnings to a plain function pointer. The handler returns whether it took the warning, so the Python bindings can decline one while a Python exception is pending; declined warnings go to DefaultErrorHandler() like every other message. 🤖 Done with the help of AI
RPyROOTApplication.cxx created the TApplication from the command line options, set up ROOT globals, and installed the error handler that turns ROOT warnings into Python warnings and the PyOS_InputHook that processes GUI events while the Python prompt waits for input. The TApplication is now constructed in _application.py through cppyy, with the same options from sys.argv; its constructor already saves the interpreter context, which the subclass did a second time. Of the ROOT globals only gBenchmark still needs setting: TROOT builds gStyle and TApplication sets gProgName, and evaluating gStyle created the proxies of TStyle and its base classes during every import. The warning handler and the input hook stay compiled, in PyROOTModule.cxx: - a Python callable passed to ROOT::Internal::SetWarningHandler() makes cppyy compile a trampoline during every import, which parses Python.h and takes half a second. The handler now declines warnings while a Python exception is pending, e.g. after a previous warning turned into an error in the same C++ call: PyErr_WarnExplicit() then replaced the exception with a SystemError. - a ctypes callback as input hook swallows the KeyboardInterrupt of a Ctrl-C arriving while it runs, so the Ctrl-C is lost. The setup runs while the ROOT module is being set up, so it goes through cppyy.gbl rather than the ROOT module, and the pythonization decorator test excludes the classes it now creates proxies of. 🤖 Done with the help of AI
guitargeek
requested review from
bellenot,
dpiparo,
pcanal,
siliataider and
vepadulano
as code owners
October 13, 2026 09:33
vepadulano
approved these changes
Oct 13, 2026
vepadulano
left a comment
Member
There was a problem hiding this comment.
Thanks! See one minor comment.
Test Results 24 files 24 suites 4d 3h 54m 51s ⏱️ For more details on these failures, see this check. Results for commit 51efb9c. ♻️ This comment has been updated with latest results. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
More detail in the commit descriptions.