File tree Expand file tree Collapse file tree 3 files changed +16
-6
lines changed
graalpython/com.oracle.graal.python/src/com/oracle/graal/python Expand file tree Collapse file tree 3 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -237,9 +237,11 @@ protected void initializeContext(PythonContext context) throws Exception {
237
237
@ Override
238
238
protected CallTarget parse (ParsingRequest request ) throws Exception {
239
239
PythonContext context = this .getContextReference ().get ();
240
- if (!context .getCore ().isInitialized ()) {
241
- context .getCore ().initialize ();
240
+ PythonCore pythonCore = context .getCore ();
241
+ if (!pythonCore .isInitialized ()) {
242
+ pythonCore .initialize ();
242
243
}
244
+ pythonCore .runPostInit ();
243
245
context .getOrCreateMainModule (request .getSource ().getPath ());
244
246
245
247
// if we are running the interpreter, module 'site' is automatically imported
@@ -248,7 +250,7 @@ protected CallTarget parse(ParsingRequest request) throws Exception {
248
250
// no frame required
249
251
new ImportNode ("site" ).execute (null );
250
252
}
251
- PythonParseResult parseResult = context . getCore (). getParser ().parse (context . getCore () , request .getSource ());
253
+ PythonParseResult parseResult = pythonCore . getParser ().parse (pythonCore , request .getSource ());
252
254
RootNode root = parseResult .getRootNode ();
253
255
root = new TopLevelExceptionHandler (this , root );
254
256
return Truffle .getRuntime ().createCallTarget (root );
Original file line number Diff line number Diff line change @@ -357,10 +357,14 @@ public void initialize() {
357
357
exportCInterface (getContext ());
358
358
currentException = null ;
359
359
initialized = true ;
360
+ }
360
361
361
- // apply the patches after initialization is done (we need to lookup modules that are mostly
362
- // in stdlib)
363
- loadFile (POST_INIT_MODULE_NAME , coreHome );
362
+ @ Override
363
+ public void runPostInit () {
364
+ if (initialized ) {
365
+ String coreHome = PythonCore .getCoreHomeOrFail ();
366
+ loadFile (POST_INIT_MODULE_NAME , coreHome );
367
+ }
364
368
}
365
369
366
370
public Object duplicate (Map <Object , Object > replacements , Object value ) {
Original file line number Diff line number Diff line change @@ -123,6 +123,10 @@ public interface PythonCore {
123
123
124
124
public PythonContext getContext ();
125
125
126
+ default void runPostInit () {
127
+
128
+ }
129
+
126
130
static void writeWarning (TruffleLanguage .Env env , String warning ) {
127
131
if (!LIBPOLYGLOT || env .getOptions ().get (PythonOptions .VerboseFlag )) {
128
132
write (env , "WARNING: " + warning );
You can’t perform that action at this time.
0 commit comments