@@ -313,7 +313,13 @@ otherwise parameter is a python list that we copy from
313
313
g .gofile .Outdent ()
314
314
g .gofile .Printf ("}\n \n " )
315
315
316
- g .pybuild .Printf ("mod.add_function('%s_elem', retval('%s'), [param('%s', 'handle'), param('int', 'idx')])\n " , slNm , esym .cpyname , PyHandle )
316
+ var caller_owns_ret string
317
+ var transfer_ownership string
318
+ if esym .cpyname == "PyObject*" {
319
+ caller_owns_ret = ", caller_owns_return=True"
320
+ transfer_ownership = ", transfer_ownership=False"
321
+ }
322
+ g .pybuild .Printf ("mod.add_function('%s_elem', retval('%s'%s), [param('%s', 'handle'), param('int', 'idx')])\n " , slNm , esym .cpyname , caller_owns_ret , PyHandle )
317
323
318
324
if slc .isSlice () {
319
325
g .gofile .Printf ("//export %s_subslice\n " , slNm )
@@ -340,7 +346,7 @@ otherwise parameter is a python list that we copy from
340
346
g .gofile .Outdent ()
341
347
g .gofile .Printf ("}\n \n " )
342
348
343
- g .pybuild .Printf ("mod.add_function('%s_set', None, [param('%s', 'handle'), param('int', 'idx'), param('%v', 'value')])\n " , slNm , PyHandle , esym .cpyname )
349
+ g .pybuild .Printf ("mod.add_function('%s_set', None, [param('%s', 'handle'), param('int', 'idx'), param('%v', 'value'%s )])\n " , slNm , PyHandle , esym .cpyname , transfer_ownership )
344
350
345
351
if slc .isSlice () {
346
352
g .gofile .Printf ("//export %s_append\n " , slNm )
@@ -355,7 +361,7 @@ otherwise parameter is a python list that we copy from
355
361
g .gofile .Outdent ()
356
362
g .gofile .Printf ("}\n \n " )
357
363
358
- g .pybuild .Printf ("mod.add_function('%s_append', None, [param('%s', 'handle'), param('%s', 'value')])\n " , slNm , PyHandle , esym .cpyname )
364
+ g .pybuild .Printf ("mod.add_function('%s_append', None, [param('%s', 'handle'), param('%s', 'value'%s )])\n " , slNm , PyHandle , esym .cpyname , transfer_ownership )
359
365
}
360
366
}
361
367
}
0 commit comments