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.

Author godlygeek
Recipients godlygeek, pablogsal, serhiy.storchaka, vstinner
Date 2021-09-29.23:25:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1632957908.94.0.350786681365.issue45325@roundup.psfhosted.org>
In-reply-to
Content
> but there is a catch -- the arguments should be a C int

Or a type that promotes to int. If you pass a C short or char, or a C++ bool, it is implicitly promoted to int.

> so you will need to write "expr ? 1 : 0"

Or alternatively "!!expr"

> which is not much better than "expr ? Py_True : Py_False"

I had to write that recently after reading through the Py_BuildValue docs twice to make sure I wasn't missing a format code I could use. It's a strange omission, especially because 'p' exists for PyArg_Parse. I'd very much like to see this change.
History
Date User Action Args
2021-09-29 23:25:08godlygeeksetrecipients: + godlygeek, vstinner, serhiy.storchaka, pablogsal
2021-09-29 23:25:08godlygeeksetmessageid: <1632957908.94.0.350786681365.issue45325@roundup.psfhosted.org>
2021-09-29 23:25:08godlygeeklinkissue45325 messages
2021-09-29 23:25:08godlygeekcreate