Skip to content

Commit 0cd3385

Browse files
committed
give better error message in destructuring assignment
1 parent 5e50075 commit 0cd3385

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/DestructuringAssignmentNode.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import com.oracle.graal.python.nodes.subscript.GetItemNode;
4343
import com.oracle.graal.python.nodes.subscript.GetItemNodeGen;
4444
import com.oracle.graal.python.runtime.exception.PException;
45+
import com.oracle.truffle.api.CompilerDirectives;
4546
import com.oracle.truffle.api.frame.VirtualFrame;
4647
import com.oracle.truffle.api.nodes.ExplodeLoop;
4748
import com.oracle.truffle.api.profiles.BranchProfile;
@@ -173,7 +174,11 @@ public void doWrite(VirtualFrame frame, Object rhsValue) {
173174
}
174175
} catch (PException e) {
175176
if (notEnoughValuesProfile.profileException(e, IndexError)) {
176-
throw raise(ValueError, "not enough values to unpack");
177+
if (lenNode == null) {
178+
CompilerDirectives.transferToInterpreterAndInvalidate();
179+
lenNode = insert(BuiltinFunctionsFactory.LenNodeFactory.create());
180+
}
181+
throw raise(ValueError, "not enough values to unpack (expected %d, got %d)", slots.length, lenNode.executeWith(rhsValue));
177182
} else {
178183
throw e;
179184
}

0 commit comments

Comments
 (0)