From e42ccd2bfd7a05a02c1020b819e4ee5b26041d01 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 18 Mar 2015 01:39:23 +0100 Subject: Issue #23694: Enhance _Py_fopen(), it now raises an exception on error * If fopen() fails, OSError is raised with the original filename object. * The GIL is now released while calling fopen() --- Python/errors.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Python/errors.c') diff --git a/Python/errors.c b/Python/errors.c index 940aef33a2..1d64efd315 100644 --- a/Python/errors.c +++ b/Python/errors.c @@ -1126,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); } -- cgit v1.2.1