R. David Murray added the comment:

Calling sys.exit in an atexit function strikes me as a really bad idea.  It 
feels to me like it breaks the contract of what atexit is designed for, which 
is to run multiple handlers at exit.  If you call sys.exit you are in some 
sense restarting the exit processing, which feels broken to me.  It would feel 
equally broken, however, to call _exit, since that would mean the rest of the 
handlers in the chain would not be run.

In any case, I personally would *expect* an exit called in an atexit handler to 
have no effect, since an exit is already in progress and we've just taken a 
detour to run the handlers.  I can see the argument for the reverse, however, 
so it isn't obvious to me what the correct answer is.

I do note that the OP in #1257 prefers to use the sys.exit return code if an 
atexit handler raises an error, which argues for not replacing it if the atexit 
handler raises SystemExit with a different RC.  It would be more consistent 
with the proposed handling of atexit errors.

----------
nosy: +r.david.murray

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue27035>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to