Issue 15033: Different exit status when using -m (original ) (raw )Created on 2012-06-07 21:13 by kisielk , last changed 2022-04-11 14:57 by admin . This issue is now closed .
Files
File name
Uploaded
Description
Edit
exit_code.patch
jeffknupp,2012-07-03 14:07
exit code patch
review
Messages (7)
msg162501 - (view)
Author: Kamil Kisiel (kisielk)
Date: 2012-06-07 21:13
Python returns a different exit status when an exception is raised and -m is used as opposed to just running a module. A short example, let's call it foo.py: def main(): raise ValueError() if __name__ == '__main__': main() When run with python foo.py the exit status of the process is 1. If run with python -mfoo the exit status of the process is 255.
msg162666 - (view)
Author: Alyssa Coghlan (ncoghlan) *
Date: 2012-06-12 11:53
Technically, it returns -1 (which later gets coerced to an unsigned value). However, there's no good reason for the inconsistency - the offending line (663) in main.c should be changed to be: sts = (RunModule(module, 1) != 0); It is currently just: sts = RunModule(module, 1); An additional test in test_cmd_line_script is also needed to ensure that both variants give a returncode of 1 in the future.
msg164602 - (view)
Author: Jeff Knupp (jeffknupp) *
Date: 2012-07-03 14:07
Fixed for 3.3. Does this need to be back ported as well?
msg164603 - (view)
Author: Jeff Knupp (jeffknupp) *
Date: 2012-07-03 14:08
And by 'Fixed' I of course meant 'Patched, awaiting review'.
msg164667 - (view)
Author: Roundup Robot (python-dev)
Date: 2012-07-05 02:33
New changeset fcbd3bda7c0f by Senthil Kumaran in branch '3.2': Fix issue # 15033 - Return the proper exitcode for failure when modules are invoked using -m switch. Patch contributed by Jeff Knupp http://hg.python.org/cpython/rev/fcbd3bda7c0f New changeset 1186d68715cc by Senthil Kumaran in branch 'default': Fix issue # 15033 - Return the proper exitcode for failure when modules are invoked using -m switch. Patch contributed by Jeff Knupp http://hg.python.org/cpython/rev/1186d68715cc
msg164668 - (view)
Author: Roundup Robot (python-dev)
Date: 2012-07-05 02:50
New changeset 55b3de6d701e by Senthil Kumaran in branch '2.7': Fix closes issue # 15033 - Return the proper exitcode for failure when modules are invoked using -m switch. Patch contributed by Jeff Knupp http://hg.python.org/cpython/rev/55b3de6d701e
msg164669 - (view)
Author: Senthil Kumaran (orsenthil) *
Date: 2012-07-05 02:53
Thanks for the patch Jeff and thanks for the guidance, Nick. Committed this in all branches.
History
Date
User
Action
Args
2022-04-11 14:57:31
admin
set
github: 59238
2012-07-05 02:53:25
orsenthil
set
status: open -> closednosy: + orsenthil messages: + resolution: fixedstage: patch review -> resolved
2012-07-05 02:50:44
python-dev
set
messages: +
2012-07-05 02:34:00
python-dev
set
nosy: + python-dev messages: +
2012-07-04 23:09:24
Arfrever
set
nosy: + Arfrever
2012-07-03 20:56:28
pitrou
set
stage: needs patch -> patch review
2012-07-03 14:08:38
jeffknupp
set
messages: +
2012-07-03 14:07:46
jeffknupp
set
files: + exit_code.patch nosy: + jeffknupp messages: + keywords: + patch
2012-07-02 20:53:15
eric.araujo
set
keywords: + easy stage: needs patch
2012-06-12 11:53:56
ncoghlan
set
messages: +
2012-06-08 18:02:07
eric.araujo
set
nosy: + ncoghlan , eric.araujo versions: + Python 3.3, - Python 2.6
2012-06-07 21:13:38
kisielk
create