From cb19de5c98de627632e0fec8d05641b441b29923 Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Thu, 12 Oct 2017 08:57:08 +0300 Subject: [PATCH 1/7] bpo-28647: Update -u documentation after bpo-30404 --- Modules/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/main.c b/Modules/main.c index 3e347dc8e243c6..24638872053f4f 100644 --- a/Modules/main.c +++ b/Modules/main.c @@ -71,8 +71,8 @@ static const char usage_2[] = "\ -S : don't imply 'import site' on initialization\n\ "; static const char usage_3[] = "\ --u : unbuffered binary stdout and stderr, stdin always buffered;\n\ - also PYTHONUNBUFFERED=x\n\ +-u : force the stdout and stderr streams to be unbuffered;\n\ + stdin is always buffered; also PYTHONUNBUFFERED=x\n\ see man page for details on internal buffering relating to '-u'\n\ -v : verbose (trace import statements); also PYTHONVERBOSE=x\n\ can be supplied multiple times to increase verbosity\n\ From 38e467aadac4f75a4459d3b2a3e196bb8d609aa5 Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Thu, 12 Oct 2017 13:22:48 +0300 Subject: [PATCH 2/7] Address review comments --- Doc/using/cmdline.rst | 3 ++- Misc/python.man | 9 ++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/Doc/using/cmdline.rst b/Doc/using/cmdline.rst index a8cdff641e4545..ce2cee6d871c92 100644 --- a/Doc/using/cmdline.rst +++ b/Doc/using/cmdline.rst @@ -303,7 +303,8 @@ Miscellaneous options .. cmdoption:: -u - Force the stdout and stderr streams to be unbuffered. + Force the stdout and stderr streams to be unbuffered. The stdin stream is + always buffered. See also :envvar:`PYTHONUNBUFFERED`. diff --git a/Misc/python.man b/Misc/python.man index 075b974e904955..e37d58999bff1a 100644 --- a/Misc/python.man +++ b/Misc/python.man @@ -178,13 +178,8 @@ that it entails. Also disable these manipulations if is explicitly imported later. .TP .B \-u -Force the binary I/O layers of stdout and stderr to be unbuffered. -stdin is always buffered. -The text I/O layer will still be line-buffered. -.\" Note that there is internal buffering in readlines() and -.\" file-object iterators ("for line in sys.stdin") which is not -.\" influenced by this option. To work around this, you will want to use -.\" "sys.stdin.readline()" inside a "while 1:" loop. +Force the stdout and stderr streams to be unbuffered. +The stdin stream is always buffered. .TP .B \-v Print a message each time a module is initialized, showing the place From 1883b53762e5dcbedbe236addc7f30c1993033f3 Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Thu, 12 Oct 2017 14:09:35 +0300 Subject: [PATCH 3/7] Remove outdated info --- Modules/main.c | 1 - 1 file changed, 1 deletion(-) diff --git a/Modules/main.c b/Modules/main.c index 24638872053f4f..2a278578a50ba8 100644 --- a/Modules/main.c +++ b/Modules/main.c @@ -73,7 +73,6 @@ static const char usage_2[] = "\ static const char usage_3[] = "\ -u : force the stdout and stderr streams to be unbuffered;\n\ stdin is always buffered; also PYTHONUNBUFFERED=x\n\ - see man page for details on internal buffering relating to '-u'\n\ -v : verbose (trace import statements); also PYTHONVERBOSE=x\n\ can be supplied multiple times to increase verbosity\n\ -V : print the Python version number and exit (also --version)\n\ From 01993856ab4fc9801c1490c6d77db1080d94700a Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Thu, 12 Oct 2017 14:14:56 +0300 Subject: [PATCH 4/7] Address Serhiy's comments --- Doc/using/cmdline.rst | 2 +- Misc/python.man | 2 +- Modules/main.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/using/cmdline.rst b/Doc/using/cmdline.rst index ce2cee6d871c92..6124f3d6aecc74 100644 --- a/Doc/using/cmdline.rst +++ b/Doc/using/cmdline.rst @@ -304,7 +304,7 @@ Miscellaneous options .. cmdoption:: -u Force the stdout and stderr streams to be unbuffered. The stdin stream is - always buffered. + always unbuffered. See also :envvar:`PYTHONUNBUFFERED`. diff --git a/Misc/python.man b/Misc/python.man index e37d58999bff1a..4dc03973bb7aad 100644 --- a/Misc/python.man +++ b/Misc/python.man @@ -179,7 +179,7 @@ is explicitly imported later. .TP .B \-u Force the stdout and stderr streams to be unbuffered. -The stdin stream is always buffered. +The stdin stream is always unbuffered. .TP .B \-v Print a message each time a module is initialized, showing the place diff --git a/Modules/main.c b/Modules/main.c index 2a278578a50ba8..b9b9fd0e04d6a8 100644 --- a/Modules/main.c +++ b/Modules/main.c @@ -72,7 +72,7 @@ static const char usage_2[] = "\ "; static const char usage_3[] = "\ -u : force the stdout and stderr streams to be unbuffered;\n\ - stdin is always buffered; also PYTHONUNBUFFERED=x\n\ + stdin is always unbuffered; also PYTHONUNBUFFERED=x\n\ -v : verbose (trace import statements); also PYTHONVERBOSE=x\n\ can be supplied multiple times to increase verbosity\n\ -V : print the Python version number and exit (also --version)\n\ From 8eae89ff1b9dfd9e8ce6c5e2784cd0b6f837f5f7 Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Thu, 12 Oct 2017 19:44:42 +0300 Subject: [PATCH 5/7] Address another round of review comments --- Doc/library/sys.rst | 6 ++++-- Doc/using/cmdline.rst | 4 ++-- Misc/python.man | 2 +- Modules/main.c | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index aa7bd477b05a1b..073c82017c78c9 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -1276,8 +1276,10 @@ always available. :envvar:`PYTHONIOENCODING` environment variable before starting Python. * When interactive, standard streams are line-buffered. Otherwise, they - are block-buffered like regular text files. You can override this - value with the :option:`-u` command-line option. + are block-buffered like regular text files. + + * You can make ``stdout`` and ``stderr`` streams unbuffered by using the + the :option:`-u` command-line option. .. note:: diff --git a/Doc/using/cmdline.rst b/Doc/using/cmdline.rst index 6124f3d6aecc74..8ab26f595578fd 100644 --- a/Doc/using/cmdline.rst +++ b/Doc/using/cmdline.rst @@ -303,8 +303,8 @@ Miscellaneous options .. cmdoption:: -u - Force the stdout and stderr streams to be unbuffered. The stdin stream is - always unbuffered. + Force the stdout and stderr streams to be unbuffered. This option has no + effect on the stdin stream. See also :envvar:`PYTHONUNBUFFERED`. diff --git a/Misc/python.man b/Misc/python.man index 4dc03973bb7aad..9f71d69dfaf260 100644 --- a/Misc/python.man +++ b/Misc/python.man @@ -179,7 +179,7 @@ is explicitly imported later. .TP .B \-u Force the stdout and stderr streams to be unbuffered. -The stdin stream is always unbuffered. +This option has no effect on the stdin stream. .TP .B \-v Print a message each time a module is initialized, showing the place diff --git a/Modules/main.c b/Modules/main.c index b9b9fd0e04d6a8..e86211331047ee 100644 --- a/Modules/main.c +++ b/Modules/main.c @@ -72,7 +72,7 @@ static const char usage_2[] = "\ "; static const char usage_3[] = "\ -u : force the stdout and stderr streams to be unbuffered;\n\ - stdin is always unbuffered; also PYTHONUNBUFFERED=x\n\ + this option has no effect on stdin; also PYTHONUNBUFFERED=x\n\ -v : verbose (trace import statements); also PYTHONVERBOSE=x\n\ can be supplied multiple times to increase verbosity\n\ -V : print the Python version number and exit (also --version)\n\ From e310520d9d4cf86c8bbdf67b1f4965b19ceb6c2d Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Thu, 12 Oct 2017 19:46:15 +0300 Subject: [PATCH 6/7] Drop duplicate 'the' --- Doc/library/sys.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index 073c82017c78c9..67b27aaba03315 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -1279,7 +1279,7 @@ always available. are block-buffered like regular text files. * You can make ``stdout`` and ``stderr`` streams unbuffered by using the - the :option:`-u` command-line option. + :option:`-u` command-line option. .. note:: From 98b9d1732fa6dc748588214d269d8409608b9d55 Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Fri, 13 Oct 2017 13:30:53 +0300 Subject: [PATCH 7/7] Tweak wording --- Doc/library/sys.rst | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index 67b27aaba03315..853e91b93de5d5 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -1275,11 +1275,9 @@ always available. Under all platforms though, you can override this value by setting the :envvar:`PYTHONIOENCODING` environment variable before starting Python. - * When interactive, standard streams are line-buffered. Otherwise, they - are block-buffered like regular text files. - - * You can make ``stdout`` and ``stderr`` streams unbuffered by using the - :option:`-u` command-line option. + * When interactive, ``stdout`` and ``stderr`` streams are line-buffered. + Otherwise, they are block-buffered like regular text files. You can + override this value with the :option:`-u` command-line option. .. note::