Terry J. Reedy <tjre...@udel.edu> added the comment:

Crash means 'python stopped erroneously without a traceback'. 

Same exception in 3.8 and 3.9.  Argparse uses None for a count of 0.  I 
consider this a bug.  If not changed, it should be documented.  As argparse is, 
the example needs to recode None to 0.  (Or, it could add '-v' to sys.argv.)  
With proper line wrapping, the result could be

import argparse
from getpass import getuser
parser = argparse.ArgumentParser(description='An argparse example.')
parser.add_argument('name', nargs='?', default=getuser(),  # wrap
                    help='The name of someone to greet.')
parser.add_argument('--verbose', '-v', action='count')
args = parser.parse_args()  # new
args.verbose = 0 if args.verbose is None else args.verbose
greeting = (["Hi", "Hello", "Greetings! its very nice to meet you"] #wrap
            [args.verbose % 3])
print(f'{greeting}, {args.name}')

----------
nosy: +terry.reedy
stage:  -> needs patch
title: TypeError raised trying to run TPT 10.3 Example 2 in Python 3.4.3 -> 
TypeError for Tutorial 10.3 Example 2
type: crash -> behavior

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

Reply via email to