File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
graalpython/com.oracle.graal.python.test/src/tests/cpyext Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -271,6 +271,30 @@ def compile_module(self, name):
271
271
cmpfunc = unhandled_error_compare
272
272
)
273
273
274
+ # We get a pattern like this in Cython generated code
275
+ test_PyLong_FromAndToVoidPtrAllocated = CPyExtFunction (
276
+ lambda args : True ,
277
+ lambda : ((None ,),),
278
+ code = """PyObject* PyLong_FromAndToVoidPtrAllocated(PyObject* none) {
279
+ void* dummyPtr = malloc(sizeof(size_t));
280
+ PyObject* obj = PyLong_FromVoidPtr(dummyPtr);
281
+ int r = PyObject_RichCompareBool(obj, Py_False, Py_LT);
282
+ if (r < 0) {
283
+ return Py_None;
284
+ }
285
+ unsigned long l = PyLong_AsUnsignedLong(obj);
286
+ void* unwrappedPtr = (void*)l;
287
+ PyObject* result = unwrappedPtr == dummyPtr ? Py_True : Py_False;
288
+ free(dummyPtr);
289
+ return result;
290
+ }
291
+ """ ,
292
+ resultspec = "O" ,
293
+ argspec = 'O' ,
294
+ arguments = ["PyObject* none" ],
295
+ cmpfunc = unhandled_error_compare
296
+ )
297
+
274
298
test_PyLong_Check = CPyExtFunction (
275
299
lambda args : isinstance (args [0 ], int ),
276
300
lambda : (
You can’t perform that action at this time.
0 commit comments