This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Henrique Andrade
Recipients Henrique Andrade, vstinner
Date 2015-10-22.15:03:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <CALAFW=BAHL3nDdHTd0hwh8zMNdZiCdKrTXHFgB8V2gvB8NSHiA@mail.gmail.com>
In-reply-to <1445522490.01.0.701567180376.issue25459@psf.upfronthosting.co.za>
Content
The stream in this case (where I hit the bug) is just the console, but I
suspect the same issue will affect other streams too.

A key piece of information is that this is probably triggered by having a
custom SIGPIPE handler, which my particular application has.

When a SIGPIPE handler is in place, errors such as EAGAIN and EWOULDBLOCK
might be generated and the logging module wasn't resilient to it.

Here is the unified patch output:

11:00:38|sequoia|/opt/continuum/anaconda> diff -u
/opt/continuum/anaconda/pkgs/python-2.7.8-0/lib/python2.7/logging/__init__.py
/opt/continuum/anaconda/pkgs/python-2.7.8-1/lib/python2.7/logging/__init__.py
---
/opt/continuum/anaconda/pkgs/python-2.7.8-0/lib/python2.7/logging/__init__.py
2014-07-02
19:08:57.000000000 -0400
+++
/opt/continuum/anaconda/pkgs/python-2.7.8-1/lib/python2.7/logging/__init__.py
2015-09-22
13:57:39.196032267 -0400
@@ -23,7 +23,7 @@
 To use, simply 'import logging' and log away!
 """

-import sys, os, time, cStringIO, traceback, warnings, weakref, collections
+import sys, os, time, cStringIO, traceback, warnings, weakref,
collections, errno

 __all__ = ['BASIC_FORMAT', 'BufferingFormatter', 'CRITICAL', 'DEBUG',
'ERROR',
            'FATAL', 'FileHandler', 'Filter', 'Formatter', 'Handler',
'INFO',
@@ -877,7 +877,13 @@
                             #An extra encoding step seems to be needed.
                             stream.write((ufs %
msg).encode(stream.encoding))
                     else:
-                        stream.write(fs % msg)
+                        while True:
+                            try:
+                                stream.write(fs % msg)
+                                break
+                            except IOError as e:
+                                if e.errno != errno.EAGAIN:
+                                    raise
                 except UnicodeError:
                     stream.write(fs % msg.encode("UTF-8"))
             self.flush()

On Thu, Oct 22, 2015 at 10:01 AM, STINNER Victor <report@bugs.python.org>
wrote:

>
> STINNER Victor added the comment:
>
> What is the type of the stream? Is is a pipe or a regular file? Or a
> socket?
>
> Can you please format the patch as an unified patch please?
>
> ----------
> nosy: +haypo
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue25459>
> _______________________________________
>
History
Date User Action Args
2015-10-22 15:03:13Henrique Andradesetrecipients: + Henrique Andrade, vstinner
2015-10-22 15:03:13Henrique Andradelinkissue25459 messages
2015-10-22 15:03:13Henrique Andradecreate