R. David Murray added the comment:

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.

----------
dependencies: +Documentation for argparse interactive use
nosy: +r.david.murray
resolution: not a bug -> duplicate
stage:  -> resolved
versions: +Python 3.4, Python 3.5 -Python 3.3

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

Reply via email to