wlav / CPyCppyy

Other
23 stars 20 forks source link

Avoid holding reference to `__main__` in the CPyCppyy API #37

Closed guitargeek closed 1 week ago

guitargeek commented 2 weeks ago

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.

Equivalent ROOT PR with the CI run: https://github.com/root-project/root/pull/16403