comparison Python/traceback.c @ 84647:2e42c0a39321

Issue #18408: Fix _Py_DisplaySourceLine() Report _Py_FindSourceFile() error, so the error is cleared; and clear io.open(filename) exception on failure.
author Victor Stinner <victor.stinner@gmail.com>
date Tue, 16 Jul 2013 00:32:14 +0200
parents ef5dd5bda323
children 19a8c3e36cfb
comparison
equal deleted inserted replaced
84646:71a572a516f9 84647:2e42c0a39321
244 if (io == NULL) 244 if (io == NULL)
245 return -1; 245 return -1;
246 binary = _PyObject_CallMethodId(io, &PyId_open, "Os", filename, "rb"); 246 binary = _PyObject_CallMethodId(io, &PyId_open, "Os", filename, "rb");
247 247
248 if (binary == NULL) { 248 if (binary == NULL) {
249 PyErr_Clear();
250
249 binary = _Py_FindSourceFile(filename, buf, sizeof(buf), io); 251 binary = _Py_FindSourceFile(filename, buf, sizeof(buf), io);
250 if (binary == NULL) { 252 if (binary == NULL) {
251 Py_DECREF(io); 253 Py_DECREF(io);
252 return 0; 254 return -1;
253 } 255 }
254 } 256 }
255 257
256 /* use the right encoding to decode the file as unicode */ 258 /* use the right encoding to decode the file as unicode */
257 fd = PyObject_AsFileDescriptor(binary); 259 fd = PyObject_AsFileDescriptor(binary);