@@ -54,6 +54,16 @@ def _reference_typecheck(args, expected_type):
54
54
return args [0 ][0 ]
55
55
56
56
57
+ def _reference_parse_O (args ):
58
+ assert isinstance (args [0 ], tuple )
59
+ assert isinstance (args [1 ], dict )
60
+ if args [0 ]:
61
+ return args [0 ][0 ]
62
+ elif "arg0" in args [1 ]:
63
+ return args [1 ]["arg0" ]
64
+ raise TypeError
65
+
66
+
57
67
class Indexable :
58
68
def __int__ (self ):
59
69
return 456
@@ -107,6 +117,32 @@ def compile_module(self, name):
107
117
cmpfunc = unhandled_error_compare
108
118
)
109
119
120
+ test_parseargs_O = CPyExtFunction (
121
+ _reference_parse_O ,
122
+ lambda : (
123
+ (('helloworld' , ), dict ()),
124
+ (tuple (), {"arg0" : 'helloworld' }),
125
+ (tuple (), dict ()),
126
+ (tuple (), {"arg1" : 'helloworld' }),
127
+ ),
128
+ code = '''
129
+ static PyObject* wrap_PyArg_ParseTupleAndKeywords(PyObject* argTuple, PyObject* kwargs) {
130
+ PyObject* out = NULL;
131
+ static char *kwdnames[] = {"arg0", NULL};
132
+ if (PyArg_ParseTupleAndKeywords(argTuple, kwargs, "O", kwdnames, &out) == 0) {
133
+ return NULL;
134
+ }
135
+ Py_XINCREF(out);
136
+ return out;
137
+ }
138
+ ''' ,
139
+ resultspec = "O" ,
140
+ argspec = "OO" ,
141
+ arguments = ["PyObject* argTuple" , "PyObject* kwargs" ],
142
+ callfunction = "wrap_PyArg_ParseTupleAndKeywords" ,
143
+ cmpfunc = unhandled_error_compare
144
+ )
145
+
110
146
test_parseargs_O_conv = CPyExtFunction (
111
147
lambda args : True if args [0 ][0 ] else False ,
112
148
lambda : (
0 commit comments