Segfault after deepcopy in a C extension

Chris Angelico rosuav at gmail.com
Mon Jan 31 16:59:33 EST 2022


On Tue, 1 Feb 2022 at 08:54, Marco Sulla <Marco.Sulla.Python at gmail.com> wrote:
>     PyObject* d = PyDict_New();
>     args = PyTuple_New(2);
>     PyTuple_SET_ITEM(args, 0, d);
>     PyTuple_SET_ITEM(args, 1, memo);
>     Py_DECREF(d);
>

https://docs.python.org/3/c-api/tuple.html#c.PyTuple_SET_ITEM

SET_ITEM steals a reference, so you'll need to not also decref the
dict yourself.

ChrisA


More information about the Python-list mailing list