From d41aa7faa7c763b634b226f7a3149d377462e45d Mon Sep 17 00:00:00 2001 From: ssrthakkumar Date: Fri, 23 Jan 2026 17:54:27 +0530 Subject: [PATCH 1/2] Doc: clarify that open() accepts objects with name attribute --- Doc/library/functions.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index cd819b8d06480a..cfa6d9620df881 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -1352,9 +1352,10 @@ are always available. They are listed here in alphabetical order. :ref:`tut-files` for more examples of how to use this function. *file* is a :term:`path-like object` giving the pathname (absolute or - 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* + relative to the current working directory) of the file to be opened, + or an object with a ``name`` attribute, 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``.) *mode* is an optional string that specifies the mode in which the file is From 41e447d111993052099183910470de6fbb75d1d3 Mon Sep 17 00:00:00 2001 From: ssrthakkumar Date: Fri, 23 Jan 2026 18:36:32 +0530 Subject: [PATCH 2/2] Doc: clarify that open() accepts objects with name attribute --- Doc/library/functions.rst | 4 ++-- tatus | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 tatus diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index cfa6d9620df881..95b39773857c54 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -1346,7 +1346,7 @@ are always available. They are listed here in alphabetical order. single: file object; open() built-in function .. function:: open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) - +` Open *file* and return a corresponding :term:`file object`. If the file cannot be opened, an :exc:`OSError` is raised. See :ref:`tut-files` for more examples of how to use this function. @@ -1367,7 +1367,7 @@ are always available. They are listed here in alphabetical order. *encoding* is not specified the encoding used is platform-dependent: :func:`locale.getencoding` is called to get the current locale encoding. (For reading and writing raw bytes use binary mode and leave - *encoding* unspecified.) The available modes are: + *encoding* unspecified.) The available modes are:` .. _filemodes: diff --git a/tatus b/tatus new file mode 100644 index 00000000000000..6b0511fda0e0a5 --- /dev/null +++ b/tatus @@ -0,0 +1,18 @@ +diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst +index cd819b8d06..cfa6d9620d 100644 +--- a/Doc/library/functions.rst ++++ b/Doc/library/functions.rst +@@ -1352,9 +1352,10 @@ are always available. They are listed here in alphabetical order. + :ref:`tut-files` for more examples of how to use this function. +  + *file* is a :term:`path-like object` giving the pathname (absolute or +- 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* ++ relative to the current working directory) of the file to be opened, ++ or an object with a ``name`` attribute, 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``.) +  + *mode* is an optional string that specifies the mode in which the file is