summaryrefslogtreecommitdiff
path: root/Python/errors.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-03-24 12:01:30 +0100
committerVictor Stinner <victor.stinner@gmail.com>2015-03-24 12:01:30 +0100
commit32f51cebfbd544a02c3dcde1ebc746559148f9a0 (patch)
tree69ccf35b2ca5a9a6fba9428916966cc8387fbb5f /Python/errors.c
parent10a64d840fd23928c788ca82149a21950a8ca025 (diff)
parente2e8b892474ee226b527e829695d236dcc6faad8 (diff)
downloadcpython-32f51cebfbd544a02c3dcde1ebc746559148f9a0.tar.gz
(Merge 3.4) Issue #23571: Enhance Py_FatalError()
* Display the current Python stack if an exception was raised but the exception has no traceback * Disable faulthandler if an exception was raised (before it was only disabled if no exception was raised) * To display the current Python stack, call PyGILState_GetThisThreadState() which works even if the GIL was released
Diffstat (limited to 'Python/errors.c')
-rw-r--r--Python/errors.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/Python/errors.c b/Python/errors.c
index a980481110..1d64efd315 100644
--- a/Python/errors.c
+++ b/Python/errors.c
@@ -773,19 +773,11 @@ PyErr_BadInternalCall(void)
#define PyErr_BadInternalCall() _PyErr_BadInternalCall(__FILE__, __LINE__)
-
PyObject *
-PyErr_Format(PyObject *exception, const char *format, ...)
+PyErr_FormatV(PyObject *exception, const char *format, va_list vargs)
{
- va_list vargs;
PyObject* string;
-#ifdef HAVE_STDARG_PROTOTYPES
- va_start(vargs, format);
-#else
- va_start(vargs);
-#endif
-
#ifdef Py_DEBUG
/* in debug mode, PyEval_EvalFrameEx() fails with an assertion error
if an exception is set when it is called */
@@ -795,11 +787,24 @@ PyErr_Format(PyObject *exception, const char *format, ...)
string = PyUnicode_FromFormatV(format, vargs);
PyErr_SetObject(exception, string);
Py_XDECREF(string);
- va_end(vargs);
return NULL;
}
+PyObject *
+PyErr_Format(PyObject *exception, const char *format, ...)
+{
+ va_list vargs;
+#ifdef HAVE_STDARG_PROTOTYPES
+ va_start(vargs, format);
+#else
+ va_start(vargs);
+#endif
+ PyErr_FormatV(exception, format, vargs);
+ va_end(vargs);
+ return NULL;
+}
+
PyObject *
PyErr_NewException(const char *name, PyObject *base, PyObject *dict)
@@ -1121,6 +1126,10 @@ PyErr_ProgramTextObject(PyObject *filename, int lineno)
if (filename == NULL || lineno <= 0)
return NULL;
fp = _Py_fopen_obj(filename, "r" PY_STDIOTEXTMODE);
+ if (fp == NULL) {
+ PyErr_Clear();
+ return NULL;
+ }
return err_programtext(fp, lineno);
}