Mercurial > cpython-lru_cache-weakref
diff Python/pythonrun.c @ 31771:76053a1dd452 legacy-trunk
Lost reference.
| author | Armin Rigo <arigo@tunes.org> |
|---|---|
| date | Mon, 22 Mar 2004 20:16:58 +0000 |
| parents | 2abc52c3d4c2 |
| children | 846b3ee7e106 |
line wrap: on
line diff
--- a/Python/pythonrun.c Mon Mar 22 20:12:56 2004 +0000 +++ b/Python/pythonrun.c Mon Mar 22 20:16:58 2004 +0000 @@ -1086,8 +1086,8 @@ void PyErr_Display(PyObject *exception, PyObject *value, PyObject *tb) { int err = 0; - PyObject *v = value; PyObject *f = PySys_GetObject("stderr"); + Py_INCREF(value); if (f == NULL) fprintf(stderr, "lost sys.stderr\n"); else { @@ -1097,12 +1097,12 @@ if (tb && tb != Py_None) err = PyTraceBack_Print(tb, f); if (err == 0 && - PyObject_HasAttrString(v, "print_file_and_line")) + PyObject_HasAttrString(value, "print_file_and_line")) { PyObject *message; const char *filename, *text; int lineno, offset; - if (!parse_syntax_error(v, &message, &filename, + if (!parse_syntax_error(value, &message, &filename, &lineno, &offset, &text)) PyErr_Clear(); else { @@ -1118,7 +1118,8 @@ PyFile_WriteString("\n", f); if (text != NULL) print_error_text(f, offset, text); - v = message; + Py_DECREF(value); + value = message; /* Can't be bothered to check all those PyFile_WriteString() calls */ if (PyErr_Occurred()) @@ -1155,8 +1156,8 @@ else err = PyFile_WriteObject(exception, f, Py_PRINT_RAW); if (err == 0) { - if (v != NULL && v != Py_None) { - PyObject *s = PyObject_Str(v); + if (value != Py_None) { + PyObject *s = PyObject_Str(value); /* only print colon if the str() of the object is not the empty string */ @@ -1173,6 +1174,7 @@ if (err == 0) err = PyFile_WriteString("\n", f); } + Py_DECREF(value); /* If an error happened here, don't show it. XXX This is wrong, but too many callers rely on this behavior. */ if (err != 0)
