Add function name to PyArg_ParseTuple()
authorPeter Eisentraut <[email protected]>
Thu, 27 Oct 2016 16:00:00 +0000 (12:00 -0400)
committerPeter Eisentraut <[email protected]>
Thu, 27 Oct 2016 19:41:29 +0000 (15:41 -0400)
This causes the supplied function name to appear in any error message,
making the error message friendlier and relieving us from having to
provide our own in some cases.

src/pl/plpython/plpy_cursorobject.c
src/pl/plpython/plpy_planobject.c
src/pl/plpython/plpy_plpymodule.c
src/pl/plpython/plpy_spi.c

index e682bfe566a9e8589cd7dbf219e590936b3b9536..7bb89921484906fa6667927e5cee52a8a2447cb2 100644 (file)
@@ -406,7 +406,7 @@ PLy_cursor_fetch(PyObject *self, PyObject *args)
    volatile ResourceOwner oldowner;
    Portal      portal;
 
-   if (!PyArg_ParseTuple(args, "i", &count))
+   if (!PyArg_ParseTuple(args, "i:fetch", &count))
        return NULL;
 
    cursor = (PLyCursorObject *) self;
index a9040efb502b2a09951a5ce5751a15a05feb463c..16c39a05ddf0574a6b4c0e9894191b8f2f19e143 100644 (file)
@@ -114,12 +114,11 @@ PLy_plan_dealloc(PyObject *arg)
 static PyObject *
 PLy_plan_status(PyObject *self, PyObject *args)
 {
-   if (PyArg_ParseTuple(args, ""))
+   if (PyArg_ParseTuple(args, ":status"))
    {
        Py_INCREF(Py_True);
        return Py_True;
        /* return PyInt_FromLong(self->status); */
    }
-   PLy_exception_set(PLy_exc_error, "plan.status takes no arguments");
    return NULL;
 }
index f520e7725f308c35f49458129be126f480dd26e4..d80dc51b27462b603b12ef9142427c355429f14c 100644 (file)
@@ -323,7 +323,7 @@ PLy_quote_literal(PyObject *self, PyObject *args)
    char       *quoted;
    PyObject   *ret;
 
-   if (!PyArg_ParseTuple(args, "s", &str))
+   if (!PyArg_ParseTuple(args, "s:quote_literal", &str))
        return NULL;
 
    quoted = quote_literal_cstr(str);
@@ -340,7 +340,7 @@ PLy_quote_nullable(PyObject *self, PyObject *args)
    char       *quoted;
    PyObject   *ret;
 
-   if (!PyArg_ParseTuple(args, "z", &str))
+   if (!PyArg_ParseTuple(args, "z:quote_nullable", &str))
        return NULL;
 
    if (str == NULL)
@@ -360,7 +360,7 @@ PLy_quote_ident(PyObject *self, PyObject *args)
    const char *quoted;
    PyObject   *ret;
 
-   if (!PyArg_ParseTuple(args, "s", &str))
+   if (!PyArg_ParseTuple(args, "s:quote_ident", &str))
        return NULL;
 
    quoted = quote_identifier(str);
index 0d556a2ec28081b1c0c61f9940c35c763b2b2645..b082d017ea942df6d530d846dfa170fa7ffdc57b 100644 (file)
@@ -51,7 +51,7 @@ PLy_spi_prepare(PyObject *self, PyObject *args)
    volatile ResourceOwner oldowner;
    volatile int nargs;
 
-   if (!PyArg_ParseTuple(args, "s|O", &query, &list))
+   if (!PyArg_ParseTuple(args, "s|O:prepare", &query, &list))
        return NULL;
 
    if (list && (!PySequence_Check(list)))