for (let mid in require.cache) delete require.cache[mid]
Object assign (python , originalPython )
python on ('error', function unhandledError(error) { if (python.listenerCount('error') > 1) return;if (python.listenerCount('error')===0||python.listeners('error')[0]===unhandledError) python.emit('unhandledException', error);})
Set up global scope which is used to run either program or REPL code in the pmjs script runner.
Author Wes Garland, wes@d.nosp@m. istr.nosp@m. ibuti.nosp@m. ve.n.nosp@m. etwor.nosp@m. k
Date June 2023
Copyright Copyright (c) 2023 Distributive Corp.
◆ assign()
◆ for()
for
(
let mid in require.
cache )
◆ on()
python on
(
'error'
,
function unhandledError(error) { if (python.listenerCount('error') > 1) return;if (python.listenerCount('error')===0||python.listeners('error')[0]===unhandledError) python.emit('unhandledException', error);}
)
◆ const
const { EventEmitter } = require ('events')
◆ initReplLibs
Initial value: = function pmjs$$initReplLibs()
{
globalThis.events =
require (
'events' );
}
require('core-js/actual/dom-exception')
◆ originalPython
◆ patchGlobalRequire
exports patchGlobalRequire
Initial value: = function pmjs$$patchGlobalRequire()
{
}
runProgramModule wants to include the require.cache from the pre-program loads (e.g. via -r or -e), but due to current bugs in PythonMonkey, we can't access the cache property of require because it is a JS function wrapped in a Python function wrapper exposed to script as a native function.
This patch swaps in a descended version of require() , which has the same require.cache, but that has side effects in terms of local module id resolution, so this patch happens only right before we want to fire up the program module.
◆ python
const python = globalThis.python = new EventEmitter('python')
◆ strict
◆ uncaughtExceptionHandler
exports uncaughtExceptionHandler
Initial value: = function globalInit$$uncaughtExceptionHandler(error)
{
python .emit(
'uncaughtException' , error);
else
{
}
}
const python
Definition global-init.js:23
var declare console
Definition global.d.ts:46
Temporary API until we get EventEmitters working. Replace this export with a custom handler.
◆ unhandledRejectionHandler
exports unhandledRejectionHandler
Initial value: = function globalInit$$unhandledRejectionHandler(error)
{
python .emit(
'unhandledRejection' , error);
else
{
}
}
Temporary API until we get EventEmitters working. Replace this export with a custom handler.