Issue 26427: w* format in PyArg_ParseTupleAndKeywords for optional argument (original) (raw)
Two functions read the format string in Python/getargs.c: convertitem() for present arguments and skipitem() for missing ones. They must agree on the format; in fact, a comment to this effect is written right above convertitem(). Nevertheless, skipitem() only allows '' modifier with 's' and 'z' formats, unlike convertitem(), that correctly processes 'w'. As a result, 'w*' works if an array arguments is supplied, and fails if it is omitted. Suggested fix: add c == 'w' comparison to the line with format == '' in skipitem().