[issue39955] argparse print_help breaks when help is blank space

2021-09-09 Thread Irit Katriel


Change by Irit Katriel :


--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> In argparse empty choices cannot be printed in the help
type: crash -> behavior

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39955] argparse print_help breaks when help is blank space

2020-03-15 Thread Ido Michael


Ido Michael  added the comment:

Looks like both the original and this are still issues.
Can I take this?

--
nosy: +Ido Michael

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39955] argparse print_help breaks when help is blank space

2020-03-13 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

Seems to be a duplicate of issue2

--
nosy: +xtreak

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39955] argparse print_help breaks when help is blank space

2020-03-13 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +rhettinger

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39955] argparse print_help breaks when help is blank space

2020-03-13 Thread paul j3


Change by paul j3 :


--
nosy: +paul.j3

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39955] argparse print_help breaks when help is blank space

2020-03-13 Thread Ying Zhang


New submission from Ying Zhang :

Code is attached. Comments in line. 

from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter

parser1 = ArgumentParser(formatter_class=ArgumentDefaultsHelpFormatter)
parser1.add_argument('--foo',
default='default_value_for_foo', required=False)
# this will not print the default value for foo. I think this is not the  most 
natural choice, given that the user has asked for 
ArgumentDefaultsHelpFormatter, but acceptable since the user didn't define help 
here. 

parser1.add_argument('--bar', help='',
default='default_value_for_bar', required=False)
# this will not print the default value for bar. Again, acceptable but I feel 
not the most natural. 

parser1.add_argument('--baz', help=' ',
default='default_value_for_baz', required=False)
# this will print the default value for baz. 


parser1.print_help()


parser2 = ArgumentParser()
parser2.add_argument('--baz', help=' ',
default='default_value_for_baz', required=False)

# this will break, which surprises me.
parser2.print_help()



Result:
python argparse_help_demo.py 
usage: argparse_help_demo.py [-h] [--foo FOO] [--bar BAR] [--baz BAZ]

optional arguments:
  -h, --help  show this help message and exit
  --foo FOO
  --bar BAR
  --baz BAZ   (default: default_value_for_baz)
Traceback (most recent call last):
  File "argparse_help_demo.py", line 21, in 
parser2.print_help()
  File 
"/nfs/statbuild/zhangyi/conda_envs/net37_env0/lib/python3.7/argparse.py", line 
2474, in print_help
self._print_message(self.format_help(), file)
  File 
"/nfs/statbuild/zhangyi/conda_envs/net37_env0/lib/python3.7/argparse.py", line 
2458, in format_help
return formatter.format_help()
  File 
"/nfs/statbuild/zhangyi/conda_envs/net37_env0/lib/python3.7/argparse.py", line 
284, in format_help
help = self._root_section.format_help()
  File 
"/nfs/statbuild/zhangyi/conda_envs/net37_env0/lib/python3.7/argparse.py", line 
215, in format_help
item_help = join([func(*args) for func, args in self.items])
  File 
"/nfs/statbuild/zhangyi/conda_envs/net37_env0/lib/python3.7/argparse.py", line 
215, in 
item_help = join([func(*args) for func, args in self.items])
  File 
"/nfs/statbuild/zhangyi/conda_envs/net37_env0/lib/python3.7/argparse.py", line 
215, in format_help
item_help = join([func(*args) for func, args in self.items])
  File 
"/nfs/statbuild/zhangyi/conda_envs/net37_env0/lib/python3.7/argparse.py", line 
215, in 
item_help = join([func(*args) for func, args in self.items])
  File 
"/nfs/statbuild/zhangyi/conda_envs/net37_env0/lib/python3.7/argparse.py", line 
527, in _format_action
parts.append('%*s%s\n' % (indent_first, '', help_lines[0]))
IndexError: list index out of range

--
components: Library (Lib)
messages: 364091
nosy: Ying Zhang
priority: normal
severity: normal
status: open
title: argparse print_help breaks when help is blank space
type: crash
versions: Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com