This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vajrasky
Recipients larry, nadeem.vawda, vajrasky
Date 2014-01-16.09:44:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1389865465.93.0.0203195307893.issue20185@psf.upfronthosting.co.za>
In-reply-to
Content
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?
History
Date User Action Args
2014-01-16 09:44:25vajraskysetrecipients: + vajrasky, larry, nadeem.vawda
2014-01-16 09:44:25vajraskysetmessageid: <1389865465.93.0.0203195307893.issue20185@psf.upfronthosting.co.za>
2014-01-16 09:44:25vajraskylinkissue20185 messages
2014-01-16 09:44:25vajraskycreate