[Python-Dev] Possible issue in warnings.py (original) (raw)

Scott David Daniels Scott.Daniels at Acm.Org
Sun Sep 21 23:26:57 CEST 2008


Does someone who knows the design of warnings.py a bit better than I know whether it would be an improvement to switch from:

try:
    file.write(formatwarning(message, category, filename,
                             lineno, line))
except IOError:
    pass # the file (probably stderr) is invalid
         # - this warning gets lost.

to:

complaint = formatwarning(message, category, filename,
                          lineno, line)
try:
    file.write(complaint)
except IOError:
    pass # the file (probably stderr) is invalid
         # - this warning gets lost.

on the grounds that you might not want failures in the linecache code to behave the same as failures in writing the complaint to the target area?

I'm working on a patch where the Idle warnings code seems to accidentally escalating warnings into errors, and it looked to me like this would accidentally swallow errors getting warning context and make them fail silently. The Idle issue that I'm fiddling with is that it doesn't take the new showwarning call format, and it looked like this should possibly be fixed at the same time.

--Scott David Daniels Scott.Daniels at Acm.Org



More information about the Python-Dev mailing list