From 0681b6daaae8594a985d7afeb963f159ba0cd546 Mon Sep 17 00:00:00 2001 From: kovan Date: Tue, 3 Feb 2026 23:17:08 +0100 Subject: [PATCH 1/2] gh-62734: Document that open()'s file param becomes name attribute Clarify that the value passed as the *file* parameter to open() is stored in the name attribute of the returned file object. Co-Authored-By: Claude Opus 4.5 --- Doc/library/functions.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index cd819b8d06480a..0d38690d780155 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -1355,7 +1355,8 @@ are always available. They are listed here in alphabetical order. relative to the current working directory) of the file to be opened or an integer file descriptor of the file to be wrapped. (If a file descriptor is given, it is closed when the returned I/O object is closed unless *closefd* - is set to ``False``.) + is set to ``False``.) The value passed as *file* is stored in the + :attr:`~io.IOBase.name` attribute of the returned file object. *mode* is an optional string that specifies the mode in which the file is opened. It defaults to ``'r'`` which means open for reading in text mode. From d2f7aea21b22ff59ad6f7dbe90b56bcceec9bf25 Mon Sep 17 00:00:00 2001 From: kovan Date: Tue, 3 Feb 2026 23:27:44 +0100 Subject: [PATCH 2/2] Fix cross-reference to io.FileIO.name The name attribute is documented under io.FileIO, not io.IOBase. Co-Authored-By: Claude Opus 4.5 --- Doc/library/functions.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index 0d38690d780155..76ec9e7438f3f5 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -1356,7 +1356,7 @@ are always available. They are listed here in alphabetical order. integer file descriptor of the file to be wrapped. (If a file descriptor is given, it is closed when the returned I/O object is closed unless *closefd* is set to ``False``.) The value passed as *file* is stored in the - :attr:`~io.IOBase.name` attribute of the returned file object. + :attr:`~io.FileIO.name` attribute of the returned file object. *mode* is an optional string that specifies the mode in which the file is opened. It defaults to ``'r'`` which means open for reading in text mode.