Skip to content

Commit a1597e2

Browse files
committed
If the main module wasn't initialized yet (because no parsing was ever requested), don't add it to the scopes
1 parent 80dc54f commit a1597e2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,9 @@ protected Iterable<Scope> findLocalScopes(PythonContext context, Node node, Fram
365365
@Override
366366
protected Iterable<Scope> findTopScopes(PythonContext context) {
367367
ArrayList<Scope> scopes = new ArrayList<>();
368-
scopes.add(Scope.newBuilder("__main__", context.getMainModule()).build());
368+
if (context.getMainModule() != null) {
369+
scopes.add(Scope.newBuilder("__main__", context.getMainModule()).build());
370+
}
369371
scopes.add(Scope.newBuilder("builtins", context.getBuiltins()).build());
370372
return scopes;
371373
}

0 commit comments

Comments
 (0)