New submission from Miroslav Matějů:
I want to set exit code of my script in a function registered in the atexit
module. (See https://stackoverflow.com/q/37178636/711006.) Calling sys.exit()
in that function results in the following error:
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "atexit_test.py", line 3, in myexit
sys.exit(2)
SystemExit: 2
Despite the printed error, the exit code is set to 0. (This might be related
with #1257.)
This problem seems to affect Python 3.x. I experienced it with Python 3.5.1 on
Windows 7 x64 and I am able to reproduce it with Python 3.4.3 on Linux (x64).
Python 2.7.6 on the same Linux machine works as expected: Exits without
additional messages and the desired exit code is set.
A simple test case:
def myexit():
import sys
sys.exit(2)
import atexit
atexit.register(myexit)
----------
components: Extension Modules
messages: 265678
nosy: Melebius
priority: normal
severity: normal
status: open
title: Cannot set exit code in atexit callback
type: behavior
versions: Python 3.5
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue27035>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com