diff options
author | Victor Stinner <vstinner@python.org> | 2020-12-09 19:54:31 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-09 19:54:31 (GMT) |
commit | ca064402079f889226cb107b26b329891431c319 (patch) | |
tree | b2181d7e84a9a5338e453d04d6c85e00be2a0645 | |
parent | 550e4673be538d98b6ddf5550b3922539cf5c4b2 (diff) | |
download | cpython-ca064402079f889226cb107b26b329891431c319.zip cpython-ca064402079f889226cb107b26b329891431c319.tar.gz cpython-ca064402079f889226cb107b26b329891431c319.tar.bz2 |
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.
-rw-r--r-- | Include/cpython/fileutils.h | 4 | ||||
-rw-r--r-- | Misc/NEWS.d/next/C API/2020-12-09-00-35-25.bpo-32381.Je08Ny.rst | 3 | ||||
-rw-r--r-- | Python/fileutils.c | 27 |
3 files changed, 3 insertions, 31 deletions
diff --git a/Include/cpython/fileutils.h b/Include/cpython/fileutils.h index e79d03e..312fd95 100644 --- a/Include/cpython/fileutils.h +++ b/Include/cpython/fileutils.h @@ -95,10 +95,6 @@ PyAPI_FUNC(FILE *) _Py_wfopen( const wchar_t *path, const wchar_t *mode); -PyAPI_FUNC(FILE*) _Py_fopen( - const char *pathname, - const char *mode); - PyAPI_FUNC(FILE*) _Py_fopen_obj( PyObject *path, const char *mode); diff --git a/Misc/NEWS.d/next/C API/2020-12-09-00-35-25.bpo-32381.Je08Ny.rst b/Misc/NEWS.d/next/C API/2020-12-09-00-35-25.bpo-32381.Je08Ny.rst new file mode 100644 index 0000000..ded75fa --- /dev/null +++ b/Misc/NEWS.d/next/C API/2020-12-09-00-35-25.bpo-32381.Je08Ny.rst @@ -0,0 +1,3 @@ +Remove the private :c:func:`_Py_fopen` function which is no longer needed. +Use :c:func:`_Py_wfopen` or :c:func:`_Py_fopen_obj` instead. Patch by Victor +Stinner. diff --git a/Python/fileutils.c b/Python/fileutils.c index ac38282..8dc90fb 100644 --- a/Python/fileutils.c +++ b/Python/fileutils.c @@ -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. |