[Python-Dev] cpython: threading.RLock._acquire_restore() now raises a TypeError instead of a (original) (raw)
Victor Stinner victor.stinner at gmail.com
Fri Jan 3 13:13:53 CET 2014
- Previous message: [Python-Dev] cpython: threading.RLock._acquire_restore() now raises a TypeError instead of a
- Next message: [Python-Dev] cpython: threading.RLock._acquire_restore() now raises a TypeError instead of a
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
2014/1/3 Victor Stinner <victor.stinner at gmail.com>:
2014/1/3 Serhiy Storchaka <storchaka at gmail.com>:
- if (!PyArgParseTuple(arg, "kl:acquirerestore", &count, &owner)) + if (!PyArgParseTuple(args, "(kl):acquirerestore", &count, &owner)) return NULL;
Please don't use "(...)" in PyArgParseTuple, it is dangerous (see issue6083 [1]). [1] http://bugs.python.org/issue6083 ... 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.RLIMITCORE, "\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
- Previous message: [Python-Dev] cpython: threading.RLock._acquire_restore() now raises a TypeError instead of a
- Next message: [Python-Dev] cpython: threading.RLock._acquire_restore() now raises a TypeError instead of a
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]