Skip to content

Commit

Permalink
Simplify Py_fclose() documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
vstinner committed Dec 13, 2024
1 parent 7390c5e commit 26a5a56
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
5 changes: 0 additions & 5 deletions Doc/c-api/sys.rst
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,6 @@ Operating System Utilities
Call ``fclose(file)``.
This function is needed on Windows: ``FILE*`` files opened by
:c:func:`Py_fopen` in the Python DLL must be closed by the Python DLL to use
the same C runtime version. Otherwise, calling ``fclose()`` directly can
cause undefined behavior.
.. versionadded:: next
Expand Down
2 changes: 1 addition & 1 deletion Doc/whatsnew/3.14.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@ New features
* Add :c:func:`Py_fopen` function to open a file. Similar to the
:c:func:`!fopen` function, but the *path* parameter is a Python object and an
exception is set on error. Add also :c:func:`Py_fclose` function to close a
file, function needed for Windows support.
file.
(Contributed by Victor Stinner in :gh:`127350`.)

Porting to Python 3.14
Expand Down
6 changes: 3 additions & 3 deletions Python/fileutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -1839,9 +1839,9 @@ Py_fopen(PyObject *path, const char *mode)

// Call fclose().
//
// This function is needed on Windows: FILE* files opened by Py_fopen() in the
// Python DLL must be closed by the Python DLL to use the same C runtime
// version. Otherwise, calling fclose() directly can cause undefined behavior.
// On Windows, files opened by Py_fopen() in the Python DLL must be closed by
// the Python DLL to use the same C runtime version. Otherwise, calling
// fclose() directly can cause undefined behavior.
int
Py_fclose(FILE *file)
{
Expand Down

0 comments on commit 26a5a56

Please sign in to comment.