Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(16)

Unified Diff: Modules/itertoolsmodule.c

Issue 28261: wrong error messages when using PyArg_ParseTuple to parse normal tuples
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
--- a/Modules/itertoolsmodule.c Thu Sep 22 11:43:46 2016 +0300
+++ b/Modules/itertoolsmodule.c Fri Sep 23 22:25:22 2016 +0300
@@ -147,8 +147,11 @@
groupby_setstate(groupbyobject *lz, PyObject *state)
{
PyObject *currkey, *currvalue, *tgtkey;
- if (!PyArg_ParseTuple(state, "OOO", &currkey, &currvalue, &tgtkey))
+ if (!PyArg_ParseTuple(state,
+ "OOO;groupby.__setstate__: illegal state argument",
+ &currkey, &currvalue, &tgtkey)) {
return NULL;
+ }
Py_INCREF(currkey);
Py_XSETREF(lz->currkey, currkey);
Py_INCREF(currvalue);
@@ -727,8 +730,11 @@
{
teedataobject *tdo;
int index;
- if (!PyArg_ParseTuple(state, "O!i", &teedataobject_type, &tdo, &index))
+ if (!PyArg_ParseTuple(state,
+ "O!i;_tee.__setstate__: illegal state argument",
+ &teedataobject_type, &tdo, &index)) {
return NULL;
+ }
if (index < 0 || index > LINKCELLS) {
PyErr_SetString(PyExc_ValueError, "Index out of range");
return NULL;
@@ -972,8 +978,11 @@
PyObject *saved=NULL;
int firstpass;
- if (!PyArg_ParseTuple(state, "O!i", &PyList_Type, &saved, &firstpass))
+ if (!PyArg_ParseTuple(state,
+ "O!i;cycle.__setstate__: illegal state argument",
+ &PyList_Type, &saved, &firstpass)) {
return NULL;
+ }
Py_INCREF(saved);
Py_XSETREF(lz->saved, saved);
lz->firstpass = firstpass != 0;
@@ -1903,8 +1912,11 @@
{
PyObject *source, *active=NULL;
- if (! PyArg_ParseTuple(state, "O|O", &source, &active))
+ if (!PyArg_ParseTuple(state,
+ "O|O;chain.__setstate__: illegal state argument",
+ &source, &active)) {
return NULL;
+ }
Py_INCREF(source);
Py_XSETREF(lz->source, source);
@@ -3262,10 +3274,12 @@
PyObject *indices, *cycles, *result;
Py_ssize_t n, i;
- if (!PyArg_ParseTuple(state, "O!O!",
- &PyTuple_Type, &indices,
- &PyTuple_Type, &cycles))
+ if (!PyArg_ParseTuple(state,
+ "O!O!;permutations.__setstate__: illegal state "
+ "argument", &PyTuple_Type, &indices,
+ &PyTuple_Type, &cycles)) {
return NULL;
+ }
n = PyTuple_GET_SIZE(po->pool);
if (PyTuple_GET_SIZE(indices) != n || PyTuple_GET_SIZE(cycles) != po->r) {

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+