Skip to content

Commit 3d33795

Browse files
committed
loadBuiltinsPatches when parsing (first time only, and only after initialization)
1 parent 3057dc4 commit 3d33795

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,6 @@ protected CallTarget parse(ParsingRequest request) throws Exception {
241241
if (!pythonCore.isInitialized()) {
242242
pythonCore.initialize();
243243
}
244-
pythonCore.loadBuiltinsPatches();
245244
context.getOrCreateMainModule(request.getSource().getPath());
246245

247246
// if we are running the interpreter, module 'site' is automatically imported
@@ -294,7 +293,6 @@ private void parseAndCache(PythonContext context) {
294293

295294
@TruffleBoundary
296295
private Object parseAndEval(PythonContext context, MaterializedFrame frame) {
297-
context.getCore().loadBuiltinsPatches();
298296
PNode fragment = parseInline(source, context, frame);
299297
return fragment.execute(frame);
300298
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,9 +362,9 @@ public void initialize() {
362362
@Override
363363
public void loadBuiltinsPatches() {
364364
if (initialized && !builtinsPatchesLoaded) {
365+
builtinsPatchesLoaded = true;
365366
String coreHome = PythonCore.getCoreHomeOrFail();
366367
loadFile(__BUILTINS_PATCHES__, coreHome);
367-
builtinsPatchesLoaded = true;
368368
}
369369
}
370370

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/parser/PythonParserImpl.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,8 @@ private static PythonParseResult translateParseResult(PythonCore core, String na
213213
}
214214

215215
private static PythonParseResult translateParseResult(PythonCore core, String name, ParserRuleContext input, Source source, Frame frame) {
216+
// ensure builtins patches are loaded before parsing
217+
core.loadBuiltinsPatches();
216218
TranslationEnvironment environment = new TranslationEnvironment(core.getLanguage());
217219
ScopeTranslator.accept(input, environment,
218220
(env, trackCells) -> new ScopeTranslator<>(core, env, source.isInteractive(), trackCells),
@@ -223,6 +225,8 @@ private static PythonParseResult translateParseResult(PythonCore core, String na
223225
}
224226

225227
private static PNode translateInlineParseResult(PythonCore core, String name, ParserRuleContext input, Source source, Frame currentFrame) {
228+
// ensure builtins patches are loaded before parsing
229+
core.loadBuiltinsPatches();
226230
TranslationEnvironment environment = new TranslationEnvironment(core.getLanguage());
227231
ScopeTranslator.accept(input, environment,
228232
(env, trackCells) -> new InlineScopeTranslator<>(core, env, currentFrame.getFrameDescriptor(), trackCells),

0 commit comments

Comments
 (0)