[issue14046] argparse: assertion failure if optional argument has square/round brackets in metavar

2018-06-08 Thread miss-islington


miss-islington  added the comment:


New changeset 4e6bd247aa955056626bf0cf8dc1c65a587b871f by Miss Islington (bot) 
in branch '2.7':
bpo-11874: fix assertion failure in argparse metavar handling (GH-1826)
https://github.com/python/cpython/commit/4e6bd247aa955056626bf0cf8dc1c65a587b871f


--

___
Python tracker 

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



[issue14046] argparse: assertion failure if optional argument has square/round brackets in metavar

2018-06-08 Thread miss-islington


Change by miss-islington :


--
pull_requests: +7187

___
Python tracker 

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



[issue14046] argparse: assertion failure if optional argument has square/round brackets in metavar

2018-06-08 Thread miss-islington


miss-islington  added the comment:


New changeset 842985f6c70484ed7b8fc30d0bc05aec73236a98 by Miss Islington (bot) 
in branch '3.7':
bpo-11874: fix assertion failure in argparse metavar handling (GH-1826)
https://github.com/python/cpython/commit/842985f6c70484ed7b8fc30d0bc05aec73236a98


--

___
Python tracker 

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



[issue14046] argparse: assertion failure if optional argument has square/round brackets in metavar

2018-06-08 Thread miss-islington


Change by miss-islington :


--
pull_requests: +7168

___
Python tracker 

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



[issue14046] argparse: assertion failure if optional argument has square/round brackets in metavar

2018-06-08 Thread miss-islington


miss-islington  added the comment:


New changeset 376c272d68cca0975ff0be3d12abf5f67da342d7 by Miss Islington (bot) 
in branch '3.6':
bpo-11874: fix assertion failure in argparse metavar handling (GH-1826)
https://github.com/python/cpython/commit/376c272d68cca0975ff0be3d12abf5f67da342d7


--
nosy: +miss-islington

___
Python tracker 

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



[issue14046] argparse: assertion failure if optional argument has square/round brackets in metavar

2018-06-08 Thread miss-islington


Change by miss-islington :


--
pull_requests: +7162

___
Python tracker 

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



[issue14046] argparse: assertion failure if optional argument has square/round brackets in metavar

2018-06-08 Thread miss-islington


Change by miss-islington :


--
pull_requests: +7158

___
Python tracker 

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



[issue14046] argparse: assertion failure if optional argument has square/round brackets in metavar

2018-06-08 Thread Nick Coghlan


Nick Coghlan  added the comment:


New changeset 66f02aa32f1e4adb9f24cf186f8c495399d5ce9b by Nick Coghlan (wim 
glenn) in branch 'master':
bpo-11874: fix assertion failure in argparse metavar handling (GH-1826)
https://github.com/python/cpython/commit/66f02aa32f1e4adb9f24cf186f8c495399d5ce9b


--
nosy: +ncoghlan

___
Python tracker 

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



[issue14046] argparse: assertion failure if optional argument has square/round brackets in metavar

2016-01-16 Thread Martin Panter

Changes by Martin Panter :


--
status: open -> closed
type: crash -> behavior

___
Python tracker 

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



[issue14046] argparse: assertion failure if optional argument has square/round brackets in metavar

2015-06-29 Thread John Jones

John Jones added the comment:

Im kind of surprised this bug has lasted for so many years :)

setting part_regexp to:
r'\(.*?\(.*?\).*?\)+|\[.*?\[.*?\].*?\]+|\S+'
fixes the issue for me, although its not very elegant

--
nosy: +John Jones

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



[issue14046] argparse: assertion failure if optional argument has square/round brackets in metavar

2013-05-12 Thread paul j3

Changes by paul j3 ajipa...@gmail.com:


--
nosy: +paul.j3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14046
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14046] argparse: assertion failure if optional argument has square/round brackets in metavar

2012-02-25 Thread Steven Bethard

Steven Bethard steven.beth...@gmail.com added the comment:

Yes, this is a known bug (Issue 11874). Patches welcome.

--
resolution:  - duplicate
superseder:  - argparse assertion failure with brackets in metavars

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14046
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14046] argparse: assertion failure if optional argument has square/round brackets in metavar

2012-02-24 Thread Terry J. Reedy

Changes by Terry J. Reedy tjre...@udel.edu:


--
nosy: +bethard

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14046
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14046] argparse: assertion failure if optional argument has square/round brackets in metavar

2012-02-17 Thread Mansour

New submission from Mansour mans...@oxplot.com:

I have a web server written in python which takes an optional argument telling 
it what IP and port to bind to. Here's the definition:

parser.add_argument(
  '-b', '--bind',
  metavar=[ip]:port,
  type=unicode,
  help=IP and port to bind to.
)

There are several other arguments as well. When the usage is printed (due to 
parse failures or -h), if the command line is longer than terminal width, it is 
wrapped. Here is the (relevant) code in argparse.py:311 which deals with this 
scenario:

# wrap the usage parts if it's too long
text_width = self._width - self._current_indent 
if len(prefix) + len(usage)  text_width: 
 
  # break usage into wrappable parts 
  part_regexp = r'\(.*?\)+|\[.*?\]+|\S+' 
  opt_usage = format(optionals, groups) 
  pos_usage = format(positionals, groups) 
  opt_parts = _re.findall(part_regexp, opt_usage) 
  pos_parts = _re.findall(part_regexp, pos_usage) 
  assert ' '.join(opt_parts) == opt_usage
  assert ' '.join(pos_parts) == pos_usage

Note how part_regexp extracts words, and text surrounded with round/square 
brackets. Now the argument I defined above, when displayed in usage text, looks 
like this: [-b [ip]:port]

part_regexp however, will cut it into [-b [ip] and :port] and concatenated 
later with  , it will have an extra space which causes the first assertion to 
fail.

I fiddled with part_regexp but that proved unreliable at best. I think the 
opt_parts should be obtained, not from the final formatted text, but from 
actual argument objects.

For a demonstration, see the attachment.

--
components: Library (Lib)
files: argparse_wrap_test.py
messages: 153632
nosy: oxplot
priority: normal
severity: normal
status: open
title: argparse: assertion failure if optional argument has square/round 
brackets in metavar
type: crash
versions: Python 2.7
Added file: http://bugs.python.org/file24554/argparse_wrap_test.py

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14046
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com