This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Add new formats to PyArg_ParseTuple for "str or None"
Type: Stage:
Components: C API Versions: Python 3.10
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: methane, serhiy.storchaka
Priority: normal Keywords:

Created on 2020-06-30 09:03 by methane, last changed 2022-04-11 14:59 by admin.

Messages (2)
msg372670 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2020-06-30 09:03
PyArg_ParseTuple has 'U' format for getting Unicode as PyObject*.
But when user want accept "str or None", they are forced to use 'O&' and write a custom converter. It is not convenient.

I am proposing to add 'U?' for "str or None" variants of 'U'. Does it make sense?
msg372674 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-06-30 09:18
I think it is more common to use the general "O" format. In any case you need to write separate code for None and str in the body of function.
Date User Action Args
2022-04-11 14:59:33adminsetgithub: 85339
2020-06-30 09:18:22serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg372674
2020-06-30 09:03:42methanecreate