Mailing List Archive

Note when migrating '#' formats for PyArgs_ParseTuple
Just in case anyone else runs in to it.

If you have code such as:

char* a;
char* b;
char* d;
int size;

if (!PyArg_ParseTuple(args, "sss#:f", &a, &b, &d, &size))
return NULL;

and it tells you to:

#define PY_SSIZE_T_CLEAN
#include "Python.h"

Be sure to change int size; to:

Py_ssize_t size;

If you forget, your code will compile fine and still work perfectly fine
on all py2 and py3 i386 variants, but will break 64bit variants in very
non-obvious ways.

In the above example the mismatched pointer type of size messes up the
seemingly unrelated pointer a

padr a 0x7f1f00000000
padr b 0x7f1fa656b960
padr d 0x7f1fa65579a0

So while accessing the s# argument works fine, you get a segfault when
you access a

I spent quite a while chasing my tail researching variadics, picking
apart the code trying to understand how and where 'a' gets stomped on
before I realized the size type mismatch.

--
On that note, I will say that the removal of distutils/setup.py-ability
from 3.12 without a similarly simple out of the box replacement is
unfortunate. (if setup.py usage had design flaws that lead to
deprecation fine, but python should have some form of stand alone
equivalency included out of the box by default)

For researching issues like the above, and for people who want to use
python for off-internet projects, it is nice to be able to spin up a
virtual machine from any said era, and do a
./configure
make
./python setup.py install --user

As things diverge in the future, things start to break, and you don't
always have all the pieces to put it back together, and pip kind of
sucks and is not simple when it doesn't work. It's pushy, it wants to
force everyone to connect to the hive, it demands ssl, etc, when I just
want it to shut up and make
./python -m pip install .
do what
./python setup.py install --user
does

I will figure out what works best situationally moving forward as far as
work arounds (probably modifying pip), but just saying, the modern way
of jenkinizing everything sucks, and takes the fun out of tinkering in a
cave.
--
https://mail.python.org/mailman/listinfo/python-list