
Nov. 17, 2011
7:33 p.m.
Thanks Marc-Andre,
If not, you simply pass on
the NULL/-1 return value to the higher level function in your call stack.
This is exactly my problem. What I am trying to do (and the example seems to show) is:
- define an new type.
- define getsetters functions.
- say, if one want to delete an attribute, one writes in the setter function:
if (value == NULL) { PyErr_SetString(PyExc_TypeError, "Cannot delete the last attribute"); return -1; }
so, one expects that can do:
import noddy2 mynoddy = noddy2.Noddy(number=15) mynoddy.first = "a" try: del mynoddy.last except TypeError, e: print "Error: ", e
(passing the PyExc_TypeError to the interpreter). In my situation try/except is ignored and the interpreter crushes. Am I missing something?
Lee