Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions Include/cpython/fileutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
27 changes: 0 additions & 27 deletions Python/fileutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down