|
90 | 90 | import com.oracle.graal.python.nodes.function.builtins.PythonVarargsBuiltinNode;
|
91 | 91 | import com.oracle.graal.python.nodes.object.GetClassNode;
|
92 | 92 | import com.oracle.graal.python.nodes.object.IsBuiltinClassProfile;
|
| 93 | +import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; |
93 | 94 | import com.oracle.graal.python.nodes.util.SplitArgsNode;
|
94 | 95 | import com.oracle.truffle.api.CompilerDirectives;
|
95 | 96 | import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
|
|
100 | 101 | import com.oracle.truffle.api.dsl.ImportStatic;
|
101 | 102 | import com.oracle.truffle.api.dsl.NodeFactory;
|
102 | 103 | import com.oracle.truffle.api.dsl.Specialization;
|
| 104 | +import com.oracle.truffle.api.dsl.TypeSystemReference; |
103 | 105 | import com.oracle.truffle.api.frame.VirtualFrame;
|
104 | 106 | import com.oracle.truffle.api.interop.InteropLibrary;
|
105 | 107 | import com.oracle.truffle.api.interop.UnsupportedMessageException;
|
@@ -572,11 +574,16 @@ Object raise(Object self, @SuppressWarnings("unused") Object dict) {
|
572 | 574 | }
|
573 | 575 |
|
574 | 576 | @Builtin(name = __FORMAT__, minNumOfPositionalArgs = 2)
|
| 577 | + @TypeSystemReference(PythonArithmeticTypes.class) |
575 | 578 | @GenerateNodeFactory
|
576 | 579 | abstract static class FormatNode extends PythonBinaryBuiltinNode {
|
| 580 | + |
577 | 581 | @Specialization(guards = "isString(formatString)")
|
578 |
| - Object format(VirtualFrame frame, Object self, @SuppressWarnings("unused") Object formatString, |
| 582 | + Object format(VirtualFrame frame, Object self, String formatString, |
579 | 583 | @Cached("create(__STR__)") LookupAndCallUnaryNode strCall) {
|
| 584 | + if (formatString.length() > 0) { |
| 585 | + raise(PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_FORMAT_STRING_PASSED_TO_P_FORMAT, self); |
| 586 | + } |
580 | 587 | return strCall.executeObject(frame, self);
|
581 | 588 | }
|
582 | 589 |
|
|
0 commit comments