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 terry.reedy
Recipients Julius.Lehmann-Richter, brett.cannon, mhammond, pitrou, terry.reedy, wolma
Date 2016-11-25.11:33:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1480073594.26.0.445070116625.issue22298@psf.upfronthosting.co.za>
In-reply-to
Content
In 3.6, the code in question is

def _showwarnmsg_impl(msg):
    file = msg.file
    if file is None:
        file = sys.stderr
        if file is None:
            # sys.stderr is None when run with pythonw.exe:
            # warnings get lost
            return
    text = _formatwarnmsg(msg)
    try:
        file.write(text)
    except OSError:
        # the file (probably stderr) is invalid - this warning gets lost.
        pass

When the write is attempted, *file* is not None.  It can either be sys.stderr or something else, successfully opened.  If writing to sys.stderr fails, we properly should give up.

If writing to something else fails, I now think we should try to write an exception to stderr.  So I thing the bug here, if any, is unconditionally passing.  Perhaps the exception clause should be replaced (in a new issue) with something like

     except (OSError, ValueError):
        if msg.file is not sys.stderr:
            raise
History
Date User Action Args
2016-11-25 11:33:14terry.reedysetrecipients: + terry.reedy, mhammond, brett.cannon, pitrou, wolma, Julius.Lehmann-Richter
2016-11-25 11:33:14terry.reedysetmessageid: <1480073594.26.0.445070116625.issue22298@psf.upfronthosting.co.za>
2016-11-25 11:33:14terry.reedylinkissue22298 messages
2016-11-25 11:33:14terry.reedycreate