Message402899
There was no much need of this feature. In rare cases when we needed to build a bool in Py_BuildValue (I have found only 2 cases in the stdlib, and one of them is added by me) we use the following idiom:
Py_BuildValue("...O...", ..., expr ? Py_True : Py_False, ...)
You can have a temptation to write it as
Py_BuildValue("...p...", ..., expr, ...)
but there is a catch -- the arguments should be a C int. If it is not, you can break a stack. Explicit cast to int ("(int)expr") is not always correct, so you will need to write "expr ? 1 : 0" which is not much better than "expr ? Py_True : Py_False". |
|
Date |
User |
Action |
Args |
2021-09-29 19:48:54 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, pablogsal |
2021-09-29 19:48:54 | serhiy.storchaka | set | messageid: <1632944934.76.0.0308250067474.issue45325@roundup.psfhosted.org> |
2021-09-29 19:48:54 | serhiy.storchaka | link | issue45325 messages |
2021-09-29 19:48:54 | serhiy.storchaka | create | |
|