comparison Python/pythonrun.c @ 48024:7ad6e4cd7713 legacy-trunk

#3378: in case of no memory, don't leak even more memory. :)
author Georg Brandl <georg@python.org>
date Sat, 19 Jul 2008 10:08:55 +0000
parents 6f132a26b22f
children b1682c693b9a
comparison
equal deleted inserted replaced
48023:caca33832a1a 48024:7ad6e4cd7713
1551 msg = "EOL while scanning string literal"; 1551 msg = "EOL while scanning string literal";
1552 break; 1552 break;
1553 case E_INTR: 1553 case E_INTR:
1554 if (!PyErr_Occurred()) 1554 if (!PyErr_Occurred())
1555 PyErr_SetNone(PyExc_KeyboardInterrupt); 1555 PyErr_SetNone(PyExc_KeyboardInterrupt);
1556 return; 1556 goto cleanup;
1557 case E_NOMEM: 1557 case E_NOMEM:
1558 PyErr_NoMemory(); 1558 PyErr_NoMemory();
1559 return; 1559 goto cleanup;
1560 case E_EOF: 1560 case E_EOF:
1561 msg = "unexpected EOF while parsing"; 1561 msg = "unexpected EOF while parsing";
1562 break; 1562 break;
1563 case E_TABSPACE: 1563 case E_TABSPACE:
1564 errtype = PyExc_TabError; 1564 errtype = PyExc_TabError;
1599 msg = "unknown parsing error"; 1599 msg = "unknown parsing error";
1600 break; 1600 break;
1601 } 1601 }
1602 v = Py_BuildValue("(ziiz)", err->filename, 1602 v = Py_BuildValue("(ziiz)", err->filename,
1603 err->lineno, err->offset, err->text); 1603 err->lineno, err->offset, err->text);
1604 if (err->text != NULL) {
1605 PyObject_FREE(err->text);
1606 err->text = NULL;
1607 }
1608 w = NULL; 1604 w = NULL;
1609 if (v != NULL) 1605 if (v != NULL)
1610 w = Py_BuildValue("(sO)", msg, v); 1606 w = Py_BuildValue("(sO)", msg, v);
1611 Py_XDECREF(u); 1607 Py_XDECREF(u);
1612 Py_XDECREF(v); 1608 Py_XDECREF(v);
1613 PyErr_SetObject(errtype, w); 1609 PyErr_SetObject(errtype, w);
1614 Py_XDECREF(w); 1610 Py_XDECREF(w);
1611 cleanup:
1612 if (err->text != NULL) {
1613 PyObject_FREE(err->text);
1614 err->text = NULL;
1615 }
1615 } 1616 }
1616 1617
1617 /* Print fatal error message and abort */ 1618 /* Print fatal error message and abort */
1618 1619
1619 void 1620 void