Run the program module. This loads the code from disk, sets up the execution environment, and then invokes the program module (aka main module). The program module is different from other modules in that 1. it cannot return (must throw) 2. the outermost block scope is the global scope, effe
(filename, argv, extraPaths=[])
| 399 | |
| 400 | |
| 401 | def runProgramModule(filename, argv, extraPaths=[]): |
| 402 | """ |
| 403 | Run the program module. This loads the code from disk, sets up the execution environment, and then |
| 404 | invokes the program module (aka main module). The program module is different from other modules in that |
| 405 | 1. it cannot return (must throw) |
| 406 | 2. the outermost block scope is the global scope, effectively making its scope a super-global to |
| 407 | other modules |
| 408 | """ |
| 409 | fullFilename = os.path.abspath(filename) |
| 410 | createRequire(fullFilename, extraPaths, True) |
| 411 | globalThis.__filename = fullFilename |
| 412 | globalThis.__dirname = os.path.dirname(fullFilename) |
| 413 | with open(fullFilename, encoding="utf-8", mode="r") as mainModuleSource: |
| 414 | pm.eval(mainModuleSource.read(), {'filename': fullFilename, 'noScriptRval': True}) |
| 415 | # forcibly run in file mode. We shouldn't be getting the last expression of the script as the result value. |
| 416 | |
| 417 | # The pythonmonkey require export. Every time it is used, the stack is inspected so that the filename |
| 418 | # passed to createRequire is correct. This is necessary so that relative requires work. If the filename |
nothing calls this directly
no test coverage detected