[issue45325] Allow "p" in Py_BuildValue

Serhiy Storchaka report at bugs.python.org
Wed Sep 29 17:46:30 EDT 2021


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

> What happens if you pass a double, it is stored as a double on the C stack, and then Py_BuildValue() will read junk data?

AFAIK, it is complicated. On old computer primitive compilers just pushed arguments one by one on the stack (in platform-depending order). When you push 64-bytes double and read 32-bit int, you get a junk not only for this read, but for reads of all following or preceding arguments.

Modern compilers on modern platforms can use registers to pass variable arguments. I do not know details, but doubles and ints are passed using different registers, so the difference can be even larger.

My concern is that such feature can provoke bugs. The risk can exceed the minor benefit.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45325>
_______________________________________


More information about the Python-bugs-list mailing list