8000 MAINT: Include the function name in all argument error messages by eric-wieser · Pull Request #8861 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

MAINT: Include the function name in all argument error messages #8861

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
8000
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion numpy/core/src/multiarray/arrayobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1620,7 +1620,7 @@ array_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)
* strides, and swapped info For now, let's just use this to create an
* empty, contiguous array of a specific type and shape.
*/
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&|O&O&LO&O&",
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&|O&O&LO&O&:ndarray",
kwlist, PyArray_IntpConverter,
&dims,
PyArray_DescrConverter,
Expand Down
18 changes: 9 additions & 9 deletions numpy/core/src/multiarray/compiled_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ arr_bincount(PyObject *NPY_UNUSED(self), PyObject *args, PyObject *kwds)
double *weights , *dans;
static char *kwlist[] = {"list", "weights", "minlength", NULL};

if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|OO",
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|OO:bincount",
kwlist, &list, &weight, &mlength)) {
goto fail;
}
Expand Down Expand Up @@ -217,7 +217,7 @@ arr_digitize(PyObject *NPY_UNUSED(self), PyObject *args, PyObject *kwds)

static char *kwlist[] = {"x", "bins", "right", NULL};

if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO|i", kwlist,
if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO|i:digitize", kwlist,
&obj_x, &obj_bins, &right)) {
goto fail;
}
Expand Down Expand Up @@ -533,7 +533,7 @@ arr_interp(PyObject *NPY_UNUSED(self), PyObject *args, PyObject *kwdict)

NPY_BEGIN_THREADS_DEF;

if (!PyArg_ParseTupleAndKeywords(args, kwdict, "OOO|OO", kwlist,
if (!PyArg_ParseTupleAndKeywords(args, kwdict, "OOO|OO:interp", kwlist,
&x, &xp, &fp, &left, &right)) {
return NULL;
}
Expand Down Expand Up @@ -686,8 +686,8 @@ arr_interp_complex(PyObject *NPY_UNUSED(self), PyObject *args, PyObject *kwdict)

NPY_BEGIN_THREADS_DEF;

if (!PyArg_ParseTupleAndKeywords(args, kwdict, "OOO|OO", kwlist,
&x, &xp, &fp, &left, &right)) {
if (!PyArg_ParseTupleAndKeywords(args, kwdict, "OOO|OO:interp_complex",
kwlist, &x, &xp, &fp, &left, &right)) {
return NULL;
}

Expand Down Expand Up @@ -1409,13 +1409,13 @@ arr_add_docstring(PyObject *NPY_UNUSED(dummy), PyObject *args)
}

#if defined(NPY_PY3K)
if (!PyArg_ParseTuple(args, "OO!", &obj, &PyUnicode_Type, &str)) {
if (!PyArg_ParseTuple(args, "OO!:add_docstring", &obj, &PyUnicode_Type, &str)) {
return NULL;
}

docstr = PyBytes_AS_STRING(PyUnicode_AsUTF8String(str));
#else
if (!PyArg_ParseTuple(args, "OO!", &obj, &PyString_Type, &str)) {
if (!PyArg_ParseTuple(args, "OO!:add_docstring", &obj, &PyString_Type, &str)) {
return NULL;
}

Expand Down Expand Up @@ -1805,7 +1805,7 @@ io_pack(PyObject *NPY_UNUSED(self), PyObject *args, PyObject *kwds)
int axis = NPY_MAXDIMS;
static char *kwlist[] = {"in", "axis", NULL};

if (!PyArg_ParseTupleAndKeywords( args, kwds, "O|O&" , kwlist,
if (!PyArg_ParseTupleAndKeywords( args, kwds, "O|O&:pack" , kwlist,
&obj, PyArray_AxisConverter, &axis)) {
return NULL;
}
Expand All @@ -1819,7 +1819,7 @@ io_unpack(PyObject *NPY_UNUSED(self), PyObject *args, PyObject *kwds)
int axis = NPY_MAXDIMS;
static char *kwlist[] = {"in", "axis", NULL};

if (!PyArg_ParseTupleAndKeywords( args, kwds, "O|O&" , kwlist,
if (!PyArg_ParseTupleAndKeywords( args, kwds, "O|O&:unpack" , kwlist,
&obj, PyArray_AxisConverter, &axis)) {
return NULL;
}
Expand Down
20 changes: 12 additions & 8 deletions numpy/core/src/multiarray/descriptor.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ array_set_typeDict(PyObject *NPY_UNUSED(ignored), PyObject *args)
{
PyObject *dict;

if (!PyArg_ParseTuple(args, "O", &dict)) {
if (!PyArg_ParseTuple(args, "O:set_typeDict", &dict)) {
return NULL;
}
/* Decrement old reference (if any)*/
Expand Down Expand Up @@ -2267,7 +2267,7 @@ arraydescr_new(PyTypeObject *NPY_UNUSED(subtype),

static char *kwlist[] = {"dtype", "align", "copy", "metadata", NULL};

if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O&O&O!", kwlist,
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O&O&O!:dtype", kwlist,
&odescr,
PyArray_BoolConverter, &align,
PyArray_BoolConverter, &copy,
Expand Down Expand Up @@ -2566,37 +2566,41 @@ arraydescr_setstate(PyArray_Descr *self, PyObject *args)
}
switch (PyTuple_GET_SIZE(PyTuple_GET_ITEM(args,0))) {
case 9:
if (!PyArg_ParseTuple(args, "(iOOOOiiiO)", &version, &endian_obj,
if (!PyArg_ParseTuple(args, "(iOOOOiiiO):__setstate__",
&version, &endian_obj,
&subarray, &names, &fields, &elsize,
&alignment, &int_dtypeflags, &metadata)) {
PyErr_Clear();
return NULL;
}
break;
case 8:
if (!PyArg_ParseTuple(args, "(iOOOOiii)", &version, &endian_obj,
if (!PyArg_ParseTuple(args, "(iOOOOiii):__setstate__",
&version, &endian_obj,
&subarray, &names, &fields, &elsize,
&alignment, &int_dtypeflags)) {
return NULL;
}
break;
case 7:
if (!PyArg_ParseTuple(args, "(iOOOOii)", &version, &endian_obj,
if (!PyArg_ParseTuple(args, "(iOOOOii):__setstate__",
&version, &endian_obj,
&subarray, &names, &fields, &elsize,
&alignment)) {
return NULL;
}
break;
case 6:
if (!PyArg_ParseTuple(args, "(iOOOii)", &version,
if (!PyArg_ParseTuple(args, "(iOOOii):__setstate__",
&version,
&endian_obj, &subarray, &fields,
&elsize, &alignment)) {
return NULL;
}
break;
case 5:
version = 0;
if (!PyArg_ParseTuple(args, "(OOOii)",
if (!PyArg_ParseTuple(args, "(OOOii):__setstate__",
&endian_obj, &subarray, &fields, &elsize,
&alignment)) {
return NULL;
Expand Down Expand Up @@ -3082,7 +3086,7 @@ arraydescr_newbyteorder(PyArray_Descr *self, PyObject *args)
{
char endian=NPY_SWAP;

if (!PyArg_ParseTuple(args, "|O&", PyArray_ByteorderConverter,
if (!PyArg_ParseTuple(args, "|O&:newbyteorder", PyArray_ByteorderConverter,
&endian)) {
return NULL;
}
Expand Down
Loading
0