From 3fda29a260cce3638c806b39eea1d019099e1ee4 Mon Sep 17 00:00:00 2001 From: Rishav Kundu Date: Sun, 2 Aug 2020 11:29:43 +0530 Subject: [PATCH 1/4] Doc: fix outdated info in mkstemp docs Choosing to open a file in binary or text mode makes a difference on *all* platforms since Python 3.x --- Doc/library/tempfile.rst | 5 ++--- Lib/tempfile.py | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Doc/library/tempfile.rst b/Doc/library/tempfile.rst index a59817c10392109..79fb1f63fbd3723 100644 --- a/Doc/library/tempfile.rst +++ b/Doc/library/tempfile.rst @@ -175,9 +175,8 @@ The module defines the following user-callable items: If you want to force a bytes return value with otherwise default behavior, pass ``suffix=b''``. - If *text* is specified, it indicates whether to open the file in binary - mode (the default) or text mode. On some platforms, this makes no - difference. + If *text* is specified and ``True``, the file is opened in text mode. + Otherwise, (the default) the file is opened in binary mode. :func:`mkstemp` returns a tuple containing an OS-level handle to an open file (as would be returned by :func:`os.open`) and the absolute pathname diff --git a/Lib/tempfile.py b/Lib/tempfile.py index ba04be8f9058e1b..770f72c25295cbe 100644 --- a/Lib/tempfile.py +++ b/Lib/tempfile.py @@ -308,8 +308,7 @@ def mkstemp(suffix=None, prefix=None, dir=None, text=False): otherwise a default directory is used. If 'text' is specified and true, the file is opened in text - mode. Else (the default) the file is opened in binary mode. On - some operating systems, this makes no difference. + mode. Else (the default) the file is opened in binary mode. If any of 'suffix', 'prefix' and 'dir' are not None, they must be the same type. If they are bytes, the returned name will be bytes; str From f0e5e9c21561d169742f94485ce8dbe274516dee Mon Sep 17 00:00:00 2001 From: Rishav Kundu Date: Sun, 2 Aug 2020 17:19:18 +0530 Subject: [PATCH 2/4] bpo-41410: Add note about truthy value --- Doc/library/tempfile.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Doc/library/tempfile.rst b/Doc/library/tempfile.rst index 79fb1f63fbd3723..40c878c2aa16964 100644 --- a/Doc/library/tempfile.rst +++ b/Doc/library/tempfile.rst @@ -175,8 +175,9 @@ The module defines the following user-callable items: If you want to force a bytes return value with otherwise default behavior, pass ``suffix=b''``. - If *text* is specified and ``True``, the file is opened in text mode. - Otherwise, (the default) the file is opened in binary mode. + If *text* is specified and ``True`` (or a truthy value), the file is + opened in text mode. Otherwise, (the default) the file is opened in + binary mode. :func:`mkstemp` returns a tuple containing an OS-level handle to an open file (as would be returned by :func:`os.open`) and the absolute pathname From 077b7a8f9c4d12ebe871f34e59e4d3c9897718f8 Mon Sep 17 00:00:00 2001 From: Rishav Kundu Date: Sun, 2 Aug 2020 19:06:31 +0530 Subject: [PATCH 3/4] bpo-41410: fix patchcheck error --- Doc/library/tempfile.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/tempfile.rst b/Doc/library/tempfile.rst index 40c878c2aa16964..4f811587799371e 100644 --- a/Doc/library/tempfile.rst +++ b/Doc/library/tempfile.rst @@ -175,7 +175,7 @@ The module defines the following user-callable items: If you want to force a bytes return value with otherwise default behavior, pass ``suffix=b''``. - If *text* is specified and ``True`` (or a truthy value), the file is + If *text* is specified and ``True`` (or a truthy value), the file is opened in text mode. Otherwise, (the default) the file is opened in binary mode. From 3ab237226dc8ce33387007561b1cc0c119852431 Mon Sep 17 00:00:00 2001 From: Rishav Kundu Date: Mon, 3 Aug 2020 09:57:47 +0530 Subject: [PATCH 4/4] bpo-41410: remove reference to truthy value --- Doc/library/tempfile.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Doc/library/tempfile.rst b/Doc/library/tempfile.rst index 4f811587799371e..3a2b88c0cb6a205 100644 --- a/Doc/library/tempfile.rst +++ b/Doc/library/tempfile.rst @@ -175,9 +175,8 @@ The module defines the following user-callable items: If you want to force a bytes return value with otherwise default behavior, pass ``suffix=b''``. - If *text* is specified and ``True`` (or a truthy value), the file is - opened in text mode. Otherwise, (the default) the file is opened in - binary mode. + If *text* is specified and true, the file is opened in text mode. + Otherwise, (the default) the file is opened in binary mode. :func:`mkstemp` returns a tuple containing an OS-level handle to an open file (as would be returned by :func:`os.open`) and the absolute pathname