Bug report
Bug description:
Following Code ends up as exception of type SystemExit when called as python test.py or python test.py -c. The catching is possible only over BaseException. According to documentation the code should raise an ArgumentError exception.
#test.py
parser = argparse.ArgumentParser(exit_on_error=False)
parser.add_argument('command',
choices=['call', 'text', 'email'],
help='What should be done')
parser.add_argument('--contact',
help='How to reach')
try:
parser.parse_args()
except argparse.ArgumentError as err:
print('Error happened')
CPython versions tested on:
3.12
Operating systems tested on:
Windows