[Python-Dev] Vestigial code in threadmodule?
Neal Norwitz
nnorwitz at gmail.com
Thu Jun 2 15:19:36 CEST 2005
On 6/2/05, A.M. Kuchling <amk at amk.ca> wrote:
> Looking at bug #1209880, the following function from threadmodule.c is
> referenced. I think the args==NULL case, which can return None
> instead of a Boolean value, can never be reached because
> PyArg_ParseTuple() will fail if args==NULL.
>
> Before ripping the args==NULL code out, I wanted to be sure my
> analysis is correct; is there some subtlety here I'm missing that
> makes args==NULL possible?
I think the args == NULL code should be ripped out, but there seems to
be a different problem.
If args is NULL to PyArg_ParseTuple() an assertion will be triggered
(or it'll just crash). See vgetargs1() in Python/getargs.c::138.
args can be NULL if load_args() in Python/ceval.c fails (line 3724).
The trace starts at line 3551, PyCFunction_Call() will be called with
the NULL args on line 3553. PyCFunction_Call() will call a PyMethod
that will likely call PyArg_ParseTuple() or something like it.
I think the following patch should fix this (it just adds an if condition).
Does this make sense or am I missing something?
n
--
Index: Python/ceval.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v
retrieving revision 2.422
diff -u -r2.422 ceval.c
--- Python/ceval.c 4 Apr 2005 15:49:02 -0000 2.422
+++ Python/ceval.c 2 Jun 2005 13:16:14 -0000
@@ -3549,9 +3549,13 @@
else {
PyObject *callargs;
callargs = load_args(pp_stack, na);
- READ_TIMESTAMP(*pintr0);
- C_TRACE(x=PyCFunction_Call(func,callargs,NULL));
- READ_TIMESTAMP(*pintr1);
+ if (callargs) {
+ READ_TIMESTAMP(*pintr0);
+
C_TRACE(x=PyCFunction_Call(func,callargs,NULL));+
READ_TIMESTAMP(*pintr1);
+ }
+ else
+ x = NULL;
Py_XDECREF(callargs);
}
} else {
More information about the Python-Dev
mailing list