[issue20185] Derby #17: Convert 49 sites to Argument Clinic across 13 files

Vajrasky Kok report at bugs.python.org
Thu Jan 16 10:44:25 CET 2014


Vajrasky Kok added the comment:

With little modification:

class PID_converter(int_converter):
  type = 'pid_t'
  format_unit = '" _Py_PARSE_PID "'

It works. Thanks! But I got unnecessary empty string:

if (!PyArg_ParseTuple(args, "" _Py_PARSE_PID "i:prlimit", &pid, &resource))

It should be:

if (!PyArg_ParseTuple(args, _Py_PARSE_PID "i:prlimit", &pid, &resource))

Anyway, that is trivial problem. Now I hit a hard one. How do you convert this signature?

-    if (!PyArg_ParseTuple(args, _Py_PARSE_PID "i|(OO):prlimit",
-                          &pid, &resource, &curobj, &maxobj))

I create custom converters:

+class TupleOpen_converter(object_converter):
+  format_unit = '(O'
+class TupleClose_converter(object_converter):
+  format_unit = 'O)'

and

+/*[clinic input]
+resource.prlimit
+
+    pid: PID
+    resource: int
+    [
+    curobj: TupleOpen
+    maxobj: TupleClose
+    ]
+    /
+[clinic start generated code]*/

But I got invalid argument size in the generated code.

+        case 2:
+            if (!PyArg_ParseTuple(args, "" _Py_PARSE_PID "i:prlimit", &pid, &resource))
+                return NULL;
+            break;
+        case 4:   ========> should be "case 3:"
+            if (!PyArg_ParseTuple(args, "" _Py_PARSE_PID "i(OO):prlimit", &pid, &resource, &curobj, &maxobj))
+                return NULL;
+            group_right_1 = 1;
+            break;
+        default:
+            PyErr_SetString(PyExc_TypeError, "resource.prlimit requires 2 to 4 arguments"); =======> should be "2 to 3 arguments"
+            return NULL;

Any idea, Larry?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20185>
_______________________________________


More information about the Python-bugs-list mailing list