If USE_STACKCHECK is defined use PyOS_CheckStack() in the repr and str

routines. This catches a slightly different set of crashes than the
recursive-repr fix.
(Jack)
This commit is contained in:
Guido van Rossum 1998-04-28 16:06:54 +00:00
parent f2044e1a71
commit 9b00dfae75
1 changed files with 12 additions and 0 deletions

View File

@ -162,6 +162,12 @@ PyObject_Print(op, fp, flags)
int ret = 0;
if (PyErr_CheckSignals())
return -1;
#ifdef USE_STACKCHECK
if (PyOS_CheckStack()) {
PyErr_SetString(PyExc_MemoryError, "Stack overflow");
return -1;
}
#endif
if (op == NULL) {
fprintf(fp, "<nil>");
}
@ -213,6 +219,12 @@ PyObject_Repr(v)
{
if (PyErr_CheckSignals())
return NULL;
#ifdef USE_STACKCHECK
if (PyOS_CheckStack()) {
PyErr_SetString(PyExc_MemoryError, "Stack overflow");
return NULL;
}
#endif
if (v == NULL)
return PyString_FromString("<NULL>");
else if (v->ob_type->tp_repr == NULL) {