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.

classification
Title: errors in atexit hooks don't change process exit code
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.1, Python 3.2, Python 3.3, Python 2.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: Nosy List: glyph, pitrou, shihai1991, ysj.ray
Priority: normal Keywords:

Created on 2011-03-23 20:26 by pitrou, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (6)
msg131916 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-03-23 20:26
Not sure if it's the desired behaviour, so I'm reporting it:

$ ./python -c "import atexit; atexit.register(lambda: 1/0)" && echo success
Error in atexit._run_exitfuncs:
ZeroDivisionError: division by zero
[36956 refs]
success
msg132083 - (view) Author: ysj.ray (ysj.ray) Date: 2011-03-25 12:41
Comparing to the atexit() in C, I think this is the wrong behavior. I's weird that error in atexit does't change process exit code while error in common python code does. There should be a fix.
msg132092 - (view) Author: ysj.ray (ysj.ray) Date: 2011-03-25 14:26
A straight forward fix maybe making the interpreter exit code a static global variable and change it in Modules/atexitmodule.c:atexit_callfuncs() in the case of errors occurred.
msg132587 - (view) Author: ysj.ray (ysj.ray) Date: 2011-03-30 13:43
see #1257
msg348883 - (view) Author: Hai Shi (shihai1991) * (Python triager) Date: 2019-08-02 04:55
as antoine said in https://bugs.python.org/issue1257, this bug should be closed;)
msg367172 - (view) Author: Glyph Lefkowitz (glyph) (Python triager) Date: 2020-04-24 05:53
I hope nobody will mind if I close: It's a duplicate of issue1257 so future discussion, if any, should probably happen there.
History
Date User Action Args
2022-04-11 14:57:15adminsetgithub: 55863
2020-04-24 05:53:12glyphsetstatus: open -> closed

nosy: + glyph
messages: + msg367172

resolution: duplicate
stage: resolved
2019-08-02 04:55:51shihai1991setnosy: + shihai1991
messages: + msg348883
2011-03-30 13:43:08ysj.raysetmessages: + msg132587
2011-03-25 14:26:44ysj.raysetmessages: + msg132092
2011-03-25 12:41:59ysj.raysetnosy: + ysj.ray
messages: + msg132083
2011-03-23 20:26:52pitroucreate