Control: tags -1 patch

On 2020-03-09 13:29:52 +0100, Vincent Lefevre wrote:
> On 2020-03-09 00:08:45 +0800, 積丹尼 Dan Jacobson wrote:
> > Setting up python3-apt (1.9.9) ...
> > /usr/lib/python3.8/subprocess.py:838: RuntimeWarning: line buffering 
> > (buffering=1) isn't supported in binary mode, the default buffer size will 
> > be used
> >   self.stdin = io.open(p2cwrite, 'wb', bufsize)
> 
> I also got lots of these warning messages.

The warning was added upstream in the following commit:

  
https://github.com/python/cpython/commit/a2670565d8f5c502388378aba1fe73023fd8c8d4

"bpo-32236: open() emits RuntimeWarning if buffering=1 for binary mode 
(GH-4842)"
fixing upstream bug 32236:
"open() shouldn't silently ignore buffering=1 in binary mode"

This is silly. Such warnings are for developers so that should appear
only in some "debug mode". Otherwise they annoy the end user and they
can break tools where the output is important (e.g. where errors can
be detected only by testing whether there is some output).

I've attached a patch that removes this warning. I've tested it
and I no longer see the warning.

Note that there is a warning with the same message (except
"RuntimeWarning:" I think) in /usr/lib/python3.8/_pyio.py,
but I don't know whether it is worth to remove this one.

-- 
Vincent Lefèvre <vinc...@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
Index: python3.8-3.8.2/Modules/_io/_iomodule.c
===================================================================
--- python3.8-3.8.2.orig/Modules/_io/_iomodule.c
+++ python3.8-3.8.2/Modules/_io/_iomodule.c
@@ -364,15 +364,6 @@ _io_open_impl(PyObject *module, PyObject
         goto error;
     }
 
-    if (binary && buffering == 1) {
-        if (PyErr_WarnEx(PyExc_RuntimeWarning,
-                         "line buffering (buffering=1) isn't supported in "
-                         "binary mode, the default buffer size will be used",
-                         1) < 0) {
-           goto error;
-        }
-    }
-
     /* Create the Raw file stream */
     {
         PyObject *RawIO_class = (PyObject *)&PyFileIO_Type;

Reply via email to