Skip to content

Commit b510758

Browse files
committed
Fix unpacking tuple in PyArg_ParseArgs*
1 parent 7e97411 commit b510758

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/common/CExtParseArgumentsNode.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,16 @@ private static ParserState convertArg(ParserState state, Object kwds, char[] for
237237
return state.close();
238238
}
239239
case '|':
240+
if (state.restOptional) {
241+
raiseNode.raiseIntWithoutFrame(0, SystemError, "Invalid format string (| specified twice)", c);
242+
throw ParseArgumentsException.raise();
243+
}
240244
return state.restOptional();
241245
case '$':
246+
if (state.restKeywordsOnly) {
247+
raiseNode.raiseIntWithoutFrame(0, SystemError, "Invalid format string ($ specified twice)", c);
248+
throw ParseArgumentsException.raise();
249+
}
242250
return state.restKeywordsOnly();
243251
case '!':
244252
case '&':
@@ -328,11 +336,11 @@ ParserState restKeywordsOnly() {
328336
}
329337

330338
ParserState open(PositionalArgStack nestedArgs) {
331-
return new ParserState(funName, outIndex, restOptional, true, nestedArgs, nativeContext);
339+
return new ParserState(funName, outIndex, restOptional, false, nestedArgs, nativeContext);
332340
}
333341

334342
ParserState close() {
335-
return new ParserState(funName, outIndex, restOptional, true, v.prev, nativeContext);
343+
return new ParserState(funName, outIndex, restOptional, false, v.prev, nativeContext);
336344
}
337345

338346
}

0 commit comments

Comments
 (0)