Extension types as exceptions
Daniel Dittmar
daniel.dittmar at sap-ag.de
Thu Aug 12 12:00:07 EDT 1999
Should it be possible to use extension types (implemented in C) as
exceptions?
Currently, this works partly, as you can 'raise' and 'except' them.
It doesn't work in the following code:
try:
... code raising exception
except EOFException, err:
pass
When the exception doesn't match any 'except' clause, it seems to be
reraised through the following code in ceval.c:
case END_FINALLY:
v = POP();
if (PyInt_Check(v)) {
why = (enum why_code) PyInt_AsLong(v);
if (why == WHY_RETURN)
retval = POP();
}
else if (PyString_Check(v) || PyClass_Check(v)) {
w = POP();
u = POP();
PyErr_Restore(v, w, u);
why = WHY_RERAISE;
break;
}
else if (v != Py_None) {
PyErr_SetString(PyExc_SystemError,
"'finally' pops bad exception");
why = WHY_EXCEPTION;
}
Py_DECREF(v);
break;
Only strings and python classes seem to be allowed.
--
Daniel Dittmar
daniel.dittmar at sap-ag.de
SAP AG, Basis Entwicklung Berlin
More information about the Python-list
mailing list