Return code when there's a problem at shutdown

Hello, In issue #5319, the poster complains that redirecting stdout to a misbehaving (pseudo-)file such as /dev/full should produce a non-zero error code when the IO error happens at shutdown (when calling flush() on stdout). Is it a reasonable expectation? What would you think of making the change? (it would require giving a return value to Py_Finalize(), which currently returns nothing) Regards Antoine.

On 8/8/2010 5:49 PM, Antoine Pitrou wrote:
Hello,
In issue #5319, the poster complains that redirecting stdout to a misbehaving (pseudo-)file such as /dev/full should produce a non-zero error code when the IO error happens at shutdown (when calling flush() on stdout).
I think is worth noting that in the artificial example, python2.5 -c 'print((1, 2, 3))' > /dev/full || echo error status the redirection occurs outside (before) the program operation.
Is it a reasonable expectation? What would you think of making the change?
It depends on whether or not one considers shutdown operations as part of the program operation. I could argue this either way. In the above example, I could say that Python did what it promised to do -- print something to the stdout stream, and that failure on flushing was outside its purview. I could also say that if one wants the flush to be considered part of the program operation, one should put it in the program explicitly instead of depending on implicit operations after the program ended.
(it would require giving a return value to Py_Finalize(), which currently returns nothing)
I have the impression that finalization sometimes generates bogus errors due the order of operations. If so returning something would require distinguishing between 'proper' and 'bogus' errors. How easy would that be. If non-trivial, I would go back to "If you want shutdown errors reported, put them in the program explicitly." -- Terry Jan Reedy

On Sun, 08 Aug 2010 18:49:50 -0400 Terry Reedy <tjreedy@udel.edu> wrote:
In the above example, I could say that Python did what it promised to do -- print something to the stdout stream, and that failure on flushing was outside its purview.
I could also say that if one wants the flush to be considered part of the program operation, one should put it in the program explicitly instead of depending on implicit operations after the program ended.
Good point. It isn't very hard to call stdout.flush() yourself if you are using stdout as a data stream, and want the user to be notified of errors. Similarly, if deallocating a file object produces an error during the interpreter's lifetime, the error is printed out on stderr and then ignored. Regards Antoine.
participants (2)
-
Antoine Pitrou
-
Terry Reedy