Skip to content

Commit

Permalink
Use debugPrint instead of str for fail parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
fmeum committed Jun 29, 2023
1 parent dac1780 commit 71e35aa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/net/starlark/java/eval/MethodLibrary.java
Original file line number Diff line number Diff line change
Expand Up @@ -714,10 +714,10 @@ public void fail(Object msg, Object attr, Tuple args, StarlarkThread thread)
List<String> elems = new ArrayList<>();
// msg acts like a leading element of args.
if (msg != Starlark.NONE) {
elems.add(Starlark.str(msg, thread.getSemantics()));
elems.add(Starlark.debugPrint(msg, thread.getSemantics()));
}
for (Object arg : args) {
elems.add(Starlark.str(arg, thread.getSemantics()));
elems.add(Starlark.debugPrint(arg, thread.getSemantics()));
}
String str = Joiner.on(" ").join(elems);
if (attr != Starlark.NONE) {
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/net/starlark/java/eval/Starlark.java
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,11 @@ public static String repr(Object x) {
return new Printer().repr(x).toString();
}

/** Returns the debug form of a value as emitted by the Starlark statement {@code print(x)}. */
public static String debugPrint(Object x, StarlarkSemantics semantics) {
return new Printer().debugPrint(x, semantics).toString();
}

/** Returns a string formatted as if by the Starlark expression {@code pattern % arguments}. */
public static String format(StarlarkSemantics semantics, String pattern, Object... arguments) {
Printer pr = new Printer();
Expand Down

0 comments on commit 71e35aa

Please sign in to comment.