summaryrefslogtreecommitdiff
path: root/Python/errors.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-03-18 01:39:23 +0100
committerVictor Stinner <victor.stinner@gmail.com>2015-03-18 01:39:23 +0100
commitb76e79ce344cf60aeeff69c4ca5c96302890ea3c (patch)
tree8cfe2e6fbb4bbdfbd539ee75557fefd044510f6f /Python/errors.c
parentb8d0bcab60af86bb0d982ef0483eec7930a0a9d0 (diff)
downloadcpython-b76e79ce344cf60aeeff69c4ca5c96302890ea3c.tar.gz
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 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);
}