mirror of
https://github.com/python/cpython.git
synced 2025-08-23 02:04:56 +00:00
bpo-32381: Remove unused _Py_fopen() function (GH-23711)
Remove the private _Py_fopen() function which is no longer needed. Use _Py_wfopen() or _Py_fopen_obj() instead.
This commit is contained in:
parent
550e4673be
commit
ca06440207
3 changed files with 3 additions and 31 deletions
|
@ -1455,33 +1455,6 @@ _Py_wfopen(const wchar_t *path, const wchar_t *mode)
|
|||
return f;
|
||||
}
|
||||
|
||||
/* Wrapper to fopen().
|
||||
|
||||
The file descriptor is created non-inheritable.
|
||||
|
||||
If interrupted by a signal, fail with EINTR. */
|
||||
FILE*
|
||||
_Py_fopen(const char *pathname, const char *mode)
|
||||
{
|
||||
PyObject *pathname_obj = PyUnicode_DecodeFSDefault(pathname);
|
||||
if (pathname_obj == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
if (PySys_Audit("open", "Osi", pathname_obj, mode, 0) < 0) {
|
||||
Py_DECREF(pathname_obj);
|
||||
return NULL;
|
||||
}
|
||||
Py_DECREF(pathname_obj);
|
||||
|
||||
FILE *f = fopen(pathname, mode);
|
||||
if (f == NULL)
|
||||
return NULL;
|
||||
if (make_non_inheritable(fileno(f)) < 0) {
|
||||
fclose(f);
|
||||
return NULL;
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
/* Open a file. Call _wfopen() on Windows, or encode the path to the filesystem
|
||||
encoding and call fopen() otherwise.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue