2014/1/3 Victor Stinner <victor.stinner@gmail.com>:
2014/1/3 Serhiy Storchaka <storchaka@gmail.com>:
- if (!PyArg_ParseTuple(arg, "kl:_acquire_restore", &count, &owner)) + if (!PyArg_ParseTuple(args, "(kl):_acquire_restore", &count, &owner)) return NULL;
Please don't use "(...)" in PyArg_ParseTuple, it is dangerous (see issue6083 [1]).
...
Would it be possible to handle this issue in Argument Clinic, split the function in two parts: a function to parse arguments and keep references, and the implementation function?
Oh, I found a similiar issue but different issue:
import resource resource.prlimit(0, resource.RLIMIT_CORE, "\u0100\u0101") Erreur de segmentation (core dumped)
This new function uses the following code to parse arguments: if (!PyArg_ParseTuple(args, _Py_PARSE_PID "i|(OO):prlimit", &pid, &resource, &curobj, &maxobj)) return NULL; "\u0100\u0101" is seen as a sequence. Getting an item of this sequence creates a new substring of 1 character, but the substring has only 1 reference, and the only reference is immediatly removed, so the borrowed reference (curobj and maxobj) become immediatly dangling pointers... Victor