gh-112068: C API: Add support of nullable arguments in PyArg_Parse (suffix)
This is a variant of #121187, but with suffix instead of prefix. i? instead of ?i.
- Issue: gh-112068
You essentially need to add that macro after every flag that is parsed instead of handling it as if it were a regular character.
In case of multicharacter format unit you need to reorganize the code and add new code at all right places. This is actually simpler than I thought, because the same macros can be used in all cases (except (...)?), but this is still more complex than the prefix implementation, and more error-prone.
For (...)?, when it encounters an opening (, it needs to search the closing ) and look if there is a following ?. Note that parentheses can be nested, so this is not so trivial. If the closing )? is found and the argument is None, it should scan the format string again and skip PyArg_Parse() arguments corresponded to nested format units. The cost of additional scanning is played every time, even if the new feature is not used. Well, this can be optimized for common cases, but at the cost of more complicated code.
I managed to implement (...)? without affecting performance. But the code is still more complex. I need to check it many more times.
Added the documentation. It is now ready for review.