Skip to content

Commit 24be2b9

Browse files
committed
Improve error message for polyglot.eval() arguments
1 parent b285559 commit 24be2b9

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PolyglotModuleBuiltins.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,12 @@ abstract static class EvalInteropNode extends PythonTernaryBuiltinNode {
209209
@Specialization
210210
Object eval(Object pathObj, Object stringObj, Object languageObj) {
211211
if (languageObj instanceof PNone) {
212-
throw PRaiseNode.raiseUncached(this, ValueError, ErrorMessages.POLYGLOT_EVAL_MUST_PASS_LANG);
212+
throw PRaiseNode.raiseUncached(this, ValueError, ErrorMessages.POLYGLOT_EVAL_MUST_PASS_LANG_AND_STRING_OR_PATH);
213213
}
214214
boolean hasString = !(stringObj instanceof PNone);
215215
boolean hasPath = !(pathObj instanceof PNone);
216216
if (!hasString && !hasPath || hasString && hasPath) {
217-
throw PRaiseNode.raiseUncached(this, ValueError, ErrorMessages.POLYGLOT_EVAL_MUST_PASS_STRING_OR_PATH);
217+
throw PRaiseNode.raiseUncached(this, ValueError, ErrorMessages.POLYGLOT_EVAL_MUST_PASS_LANG_AND_STRING_OR_PATH);
218218
}
219219
String languageName = toJavaString(languageObj, "language");
220220
String string = hasString ? toJavaString(stringObj, "string") : null;

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/ErrorMessages.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -595,8 +595,8 @@ public abstract class ErrorMessages {
595595
public static final TruffleString PATTERNS_MAY_ONLY_MATCH_LITERALS_AND_ATTRIBUTE_LOOKUPS = tsLiteral("patterns may only match literals and attribute lookups");
596596
public static final TruffleString POLYGLOT_ACCESS_NOT_ALLOWED = tsLiteral("polyglot access is not allowed");
597597
public static final TruffleString POLYGLOT_ACCESS_NOT_ALLOWED_FOR_LANGUAGE_S = tsLiteral("polyglot access is not allowed for language '%s'");
598-
public static final TruffleString POLYGLOT_EVAL_MUST_PASS_STRING_OR_PATH = tsLiteral("polyglot.eval() must pass either 'path' or 'string' keyword argument");
599-
public static final TruffleString POLYGLOT_EVAL_MUST_PASS_LANG = tsLiteral("polyglot.eval() must pass 'language' keyword argument");
598+
public static final TruffleString POLYGLOT_EVAL_MUST_PASS_LANG_AND_STRING_OR_PATH = tsLiteral(
599+
"polyglot.eval() must pass 'language' keyword argument, and either 'string' or 'path' keyword argument");
600600
public static final TruffleString POP_FROM_EMPTY_SET = tsLiteral("pop from an emtpy set");
601601
public static final TruffleString POP_INDEX_OUT_OF_RANGE = tsLiteral("pop index out of range");
602602
public static final TruffleString POSITION_D_FROM_ERROR_HANDLER_OUT_OF_BOUNDS = tsLiteral("position %d from error handler out of bounds");

0 commit comments

Comments
 (0)