The gMainDict should be borrowed, i.e. we are not calling Py_INCREF(gMainDict). Like this, we avoid unexpectedly affecting how long __main__ is kept alive. The gMainDict is only used in Exec(), ExecScript(), and Eval(), which should not be called after __main__ is garbage collected anyway.
The
gMainDict
should be borrowed, i.e. we are not calling Py_INCREF(gMainDict). Like this, we avoid unexpectedly affecting how long__main__
is kept alive. ThegMainDict
is only used inExec()
,ExecScript()
, andEval()
, which should not be called after__main__
is garbage collected anyway.Equivalent ROOT PR with the CI run: https://github.com/root-project/root/pull/16403