mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
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()
This commit is contained in:
parent
a555cfcb73
commit
e42ccd2bfd
5 changed files with 44 additions and 24 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue