Skip to content

Commit 4120058

Browse files
committed
fix: mistakenly imported site always
1 parent 11fc768 commit 4120058

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonContext.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,17 +1183,18 @@ public void patch(Env newEnv) {
11831183

11841184
private void importSiteIfForced() {
11851185
PythonModule siteModule;
1186-
if (getOption(PythonOptions.ForceImportSite) &&
1187-
getOption(PythonOptions.PythonPath).isEmpty() &&
1188-
(siteModule = ImpModuleBuiltins.importFrozenModuleObject(this, "graalpython.site", true)) != null) {
1189-
// assume we can use the frozen site module
1190-
// TODO: rename graalpython.site again to just site when we upgrade to Python 3.10+
1191-
// or newer and remove this hack
1192-
PyDictSetItem.getUncached().execute(null, getSysModules(), "site", siteModule);
1193-
LOGGER.log(Level.FINE, () -> "import 'site' # <frozen>");
1194-
} else {
1195-
CallTarget site = env.parsePublic(FORCE_IMPORTS_SOURCE);
1196-
site.call();
1186+
if (getOption(PythonOptions.ForceImportSite)) {
1187+
if (getOption(PythonOptions.PythonPath).isEmpty() &&
1188+
(siteModule = ImpModuleBuiltins.importFrozenModuleObject(this, "graalpython.site", true)) != null) {
1189+
// assume we can use the frozen site module
1190+
// TODO: rename graalpython.site again to just site when we upgrade to Python 3.10+
1191+
// or newer and remove this hack
1192+
PyDictSetItem.getUncached().execute(null, getSysModules(), "site", siteModule);
1193+
LOGGER.log(Level.FINE, () -> "import 'site' # <frozen>");
1194+
} else {
1195+
CallTarget site = env.parsePublic(FORCE_IMPORTS_SOURCE);
1196+
site.call();
1197+
}
11971198
}
11981199
if (!getOption(PythonOptions.WarnOptions).isEmpty()) {
11991200
// we must force an import of the warnings module here if warnings were passed

0 commit comments

Comments
 (0)