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.

Author r.david.murray
Recipients benjamin.peterson, invisibleroads, r.david.murray
Date 2015-05-06.17:52:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1430934731.35.0.698685915597.issue24070@psf.upfronthosting.co.za>
In-reply-to
Content
What is happening here is that the __exit__ method gets passed the exception, and then instead of returning and allowing the exception to propagate and be printed, it raises SystemExit (via parse_args), which causes Python to immediately shut down, *before* __exit__ returns and the exception is propagated.

So yes, you'd have to do something specific for argparse (which raises a SystemExit exception if parsing fails) if you want to do something non-normal with SystemExit.  That is, you'll need to catch SystemExit.

This is really a duplicate of issue 9938.
History
Date User Action Args
2015-05-06 17:52:11r.david.murraysetrecipients: + r.david.murray, benjamin.peterson, invisibleroads
2015-05-06 17:52:11r.david.murraysetmessageid: <1430934731.35.0.698685915597.issue24070@psf.upfronthosting.co.za>
2015-05-06 17:52:11r.david.murraylinkissue24070 messages
2015-05-06 17:52:11r.david.murraycreate