@@ -174,3 +174,39 @@ def compile_module(self, name):
174
174
arguments = ["PyObject* arg0" , "PyObject* arg1" ],
175
175
cmpfunc = unhandled_error_compare
176
176
)
177
+
178
+ test_PointerEquality_Primitive = CPyExtFunction (
179
+ lambda args : True ,
180
+ lambda : (
181
+ (True , lambda arg0 , * args : arg0 ),
182
+ (False , lambda arg0 , * args : arg0 ),
183
+ (10 , lambda arg0 , * args : arg0 ),
184
+ (10.0 , lambda arg0 , * args : arg0 ),
185
+ ("ten" , lambda arg0 , * args : arg0 ),
186
+ ),
187
+ code = """PyObject* PointerEquality_Primitive(PyObject* pyVal, PyObject* fun) {
188
+ PyObject** dummyArray = (PyObject**) malloc(sizeof(PyObject*));
189
+ Py_INCREF(pyVal);
190
+ Py_INCREF(fun);
191
+ dummyArray[0] = pyVal;
192
+
193
+ PyObject* arg = PyTuple_New(1);
194
+ PyTuple_SET_ITEM(arg, 0, dummyArray[0]);
195
+ Py_INCREF(arg);
196
+ PyObject* result0 = PyObject_Call(fun, arg, NULL);
197
+ if (pyVal != result0) {
198
+ PyErr_Format(PyExc_ValueError, "%s is not pointer equal: 0x%lx vs. 0x%lx", PyUnicode_AsUTF8(PyObject_Repr(pyVal)), (void*)pyVal, (void*)result0);
199
+ return NULL;
200
+ }
201
+
202
+ free(dummyArray);
203
+ Py_DECREF(pyVal);
204
+ Py_DECREF(fun);
205
+ return Py_True;
206
+ }
207
+ """ ,
208
+ resultspec = "O" ,
209
+ argspec = "OO" ,
210
+ arguments = ["PyObject* pyVal" , "PyObject* fun" ],
211
+ cmpfunc = unhandled_error_compare
212
+ )
0 commit comments