]> granicus.if.org Git - python/commitdiff
Issue #9425: save/restore exception on filename encoding
authorVictor Stinner <victor.stinner@haypocalc.com>
Tue, 17 Aug 2010 00:39:57 +0000 (00:39 +0000)
committerVictor Stinner <victor.stinner@haypocalc.com>
Tue, 17 Aug 2010 00:39:57 +0000 (00:39 +0000)
_PyUnicode_AsString() raises an exception on unencodable filename.

Python/ceval.c

index c2c4e78f19e58220ebabdb9d5c2f02eac8dc4fb9..4d583a57deec71a6ce4d98e88c7b184512bb6bf0 100644 (file)
@@ -1213,7 +1213,12 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
     lltrace = PyDict_GetItemString(f->f_globals, "__lltrace__") != NULL;
 #endif
 #if defined(Py_DEBUG) || defined(LLTRACE)
-    filename = _PyUnicode_AsString(co->co_filename);
+    {
+        PyObject *error_type, *error_value, *error_traceback;
+        PyErr_Fetch(&error_type, &error_value, &error_traceback);
+        filename = _PyUnicode_AsString(co->co_filename);
+        PyErr_Restore(error_type, error_value, error_traceback);
+    }
 #endif
 
     why = WHY_NOT;