[Pyrex] How to deal with Obtaining char * from temporary Python value ?

Greg Ewing greg at cosc.canterbury.ac.nz
Mon Jun 21 08:17:13 CEST 2004


Mateusz Korniak <mateusz at ant.gliwice.pl>:

> But I get error: Obtaining char * from temporary Python value
> 
> I am aware that I can't rely on that char * , but first thing I do in 
> c_add_item is copy contents of all ptrs, and take care of allocaton issues.
> 
> How should I solve such problem ?

Assign the Python string to a local variable first, e.g.

def add_item(item):
  ...
  name = item.name
  ...
  c_add_item(..., name, ...)

and likewise for other string attributes of item.

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg at cosc.canterbury.ac.nz	   +--------------------------------------+




More information about the Pyrex mailing list