Skip to content

Commit 076ae2a

Browse files
committed
Assert that engine option is not queried via context.
1 parent 4c8a403 commit 076ae2a

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ public long getNextGlobalId() {
258258
}
259259

260260
public <T> T getOption(OptionKey<T> key) {
261+
assert !PythonOptions.isEngineOption(key) : "Querying engine option via context.";
261262
if (CompilerDirectives.inInterpreter()) {
262263
return getEnv().getOptions().get(key);
263264
} else {

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,18 @@ public static <T> T getOptionUnrolling(Object[] optionValuesStorage, OptionKey<?
291291
throw new IllegalStateException("Using Python options with a non-Python option key");
292292
}
293293

294+
@ExplodeLoop
295+
public static boolean isEngineOption(OptionKey<?> key) {
296+
CompilerAsserts.partialEvaluationConstant(ENGINE_OPTION_KEYS);
297+
for (int i = 0; i < ENGINE_OPTION_KEYS.length; i++) {
298+
CompilerAsserts.partialEvaluationConstant(ENGINE_OPTION_KEYS[i]);
299+
if (ENGINE_OPTION_KEYS[i] == key) {
300+
return true;
301+
}
302+
}
303+
return false;
304+
}
305+
294306
/**
295307
* Check if the options set in the {@code first} and {@code second} set are compatible, i.e,
296308
* there are no Python per-engine options in these sets that differ.

0 commit comments

Comments
 (0)