When I use PyErr_SetString () in an extension, python just keeps on
chugging instead of acting as though a Python exception had been
'raise'd. Why is this, and do I really have to write the Python code
to raise an exception manually after I've used PyErr_SetString ()?
Most recently, writing an iterator -- I write:
if (nextEl == NULL) {
PyErr_SetString (PyExc_StopIter ation, "Array index out of bounds");
return NULL;
}
in my iterator extension, but when I use my extension, I get an infinite loop:
eger@rosencrant z:/usr/src/CIM-stuff/wbemcli/bugs$ python2.2
Python 2.2.2 (#1, Mar 21 2003, 23:40:29)
[GCC 3.2.3 20030316 (Debian prerelease)] on linux2
Type "help", "copyright" , "credits" or "license" for more information.[color=blue][color=green][color=darkred]
>>> import StopIterTest
>>> a = StopIterTest.du pstring("Amanda 's")
>>> b = StopIterTest.du pstring("got")
>>> l = StopIterTest.st ringArray()
>>> l.add(a)
>>> l.add(b)
>>> for i in l:[/color][/color][/color]
.... print i
....
_10180840_p_str ing
_10181b38_p_str ing
None
None
None
None
None
None
None
None
None
None
(and so on, and so on...) The thing is, even though I *set* the
exception with PyErr_SetString , to the interpreter, it doesn't get
raised. Am I just misinterprettin g how PyErr_SetString is supposed
to work?
-David
chugging instead of acting as though a Python exception had been
'raise'd. Why is this, and do I really have to write the Python code
to raise an exception manually after I've used PyErr_SetString ()?
Most recently, writing an iterator -- I write:
if (nextEl == NULL) {
PyErr_SetString (PyExc_StopIter ation, "Array index out of bounds");
return NULL;
}
in my iterator extension, but when I use my extension, I get an infinite loop:
eger@rosencrant z:/usr/src/CIM-stuff/wbemcli/bugs$ python2.2
Python 2.2.2 (#1, Mar 21 2003, 23:40:29)
[GCC 3.2.3 20030316 (Debian prerelease)] on linux2
Type "help", "copyright" , "credits" or "license" for more information.[color=blue][color=green][color=darkred]
>>> import StopIterTest
>>> a = StopIterTest.du pstring("Amanda 's")
>>> b = StopIterTest.du pstring("got")
>>> l = StopIterTest.st ringArray()
>>> l.add(a)
>>> l.add(b)
>>> for i in l:[/color][/color][/color]
.... print i
....
_10180840_p_str ing
_10181b38_p_str ing
None
None
None
None
None
None
None
None
None
None
(and so on, and so on...) The thing is, even though I *set* the
exception with PyErr_SetString , to the interpreter, it doesn't get
raised. Am I just misinterprettin g how PyErr_SetString is supposed
to work?
-David
Comment