summaryrefslogtreecommitdiffstats
path: root/Python/errors.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-03-18 00:39:23 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2015-03-18 00:39:23 (GMT)
commite42ccd2bfd7a05a02c1020b819e4ee5b26041d01 (patch)
tree071843848770176c8aed3f965d783738182847c3 /Python/errors.c
parenta555cfcb73cf677a99d29af6fa0bcfe4c35a2aeb (diff)
downloadcpython-e42ccd2bfd7a05a02c1020b819e4ee5b26041d01.zip
cpython-e42ccd2bfd7a05a02c1020b819e4ee5b26041d01.tar.gz
cpython-e42ccd2bfd7a05a02c1020b819e4ee5b26041d01.tar.bz2
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()
Diffstat (limited to 'Python/errors.c')
-rw-r--r--Python/errors.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/Python/errors.c b/Python/errors.c
index 940aef3..1d64efd 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);
}