You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PyRun_SimpleFile unfortunately doesn't expose the locals and globals arguments, which we will need I think to maintain support for py_run_file(local = TRUE) usage.
PyRun_File does expose the globals and locals arguments, but it doesn't set __file__ and __cached__ for us. It looks like we'll have to do that manually. (PyRun_FileExFlags just reads compiles and goes straight to eval, with some error handling along the way. The only attr it ensures is __builtins__ if globals is main)
Something that's interesting is that in PyRun_SimpleFile, the __file__ item is deleted from the dictionary before returning. __file__ is only available during code execution. I think that makes sense if code is being evaluated in __main__, but I'm less sure if that's the correct behavior if we're evaluating in a local dict pseudo-module.
For example, with the script:
One can run the script in a standalone Python instance and see e.g.
However,
__file__
doesn't get defined for scripts sourced byreticulate
:Maybe
py_run_file()
should go through https://docs.python.org/3/c-api/veryhigh.html#c.PyRun_SimpleFile rather than https://docs.python.org/3/c-api/veryhigh.html#c.PyRun_StringFlags?The text was updated successfully, but these errors were encountered: