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

Created on 2020-06-30 09:03 by inada.naoki, last changed 2020-06-30 09:18 by serhiy.storchaka.

Messages (2)
msg372670 - (view) Author: Inada Naoki (inada.naoki) * (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.
History
Date User Action Args
2020-06-30 09:18:22serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg372674
2020-06-30 09:03:42inada.naokicreate