msg177012 - (view) |
Author: Roy Smith (roysmith) |
Date: 2012-12-05 22:03 |
Running this code: --------------------------------------- import argparse p = argparse.ArgumentParser() p.add_argument('--foo', help=u'This is a very long help string. ex: "--s3\u00A0s3://my.bucket/dir1/dir2"') p.parse_args() --------------------------------------- produces: --------------------------------------- $ ./arg.py --help usage: arg.py [-h] [--foo FOO] optional arguments: -h, --help show this help message and exit --foo FOO This is a very long help string. ex: "--s3 s3://my.bucket/dir1/dir2" --------------------------------------- It should not be breaking the line at a non-breaking space. I'm running: Python 2.7.3 (default, Aug 1 2012, 05:14:39) [GCC 4.6.3] on linux2 |
|
|
msg222931 - (view) |
Author: Mark Lawrence (BreamoreBoy) * |
Date: 2014-07-13 14:26 |
The example code works fine using 3.4.1 and 3.5.0a0 on Windows 7. |
|
|
msg222981 - (view) |
Author: paul j3 (paul.j3) *  |
Date: 2014-07-13 23:58 |
The issue here is how `textwrap` handles the non-breaking space. That's being address here: http://bugs.python.org/issue20491 textwrap: Non-breaking space not honored Temporarily an `argparse` user can get around it with `formatter_class=argparse.RawTextHelpFormatter`. That suppresses all automatic wrapping, so it's not perfect. |
|
|
msg285612 - (view) |
Author: Xiang Zhang (xiang.zhang) *  |
Date: 2017-01-17 06:09 |
#29290 reports the same problem as here. |
|
|
msg285613 - (view) |
Author: Xiang Zhang (xiang.zhang) *  |
Date: 2017-01-17 06:13 |
Ahh, sorry. I made a mistake. It's not the same as 29290. This is about 2.7. Although #20491 is closed but 2.7 seems not patched. Nosy Serhiy. |
|
|
msg354188 - (view) |
Author: Hai Shi (shihai1991) *  |
Date: 2019-10-08 11:49 |
I checked the help format. the help_lines' width in python2.7 is different python3. The width is more likely a hardcode in https://github.com/python/cpython/blob/2.7/Lib/argparse.py#L165. , so the help_lines = [u'This is a very long help string. ex: "--s3', u's3://my.bucket/dir1/dir2"'](when joining this help_lines it will add a '\n' in the middle) Since python 3.3, the width is a dynamic value in https://github.com/python/cpython/blob/master/Lib/argparse.py#L170 , so the help_lines = ['This is a very long help string. ex: "--s3\xa0s3://my.bucket/dir1/dir2"'] |
|
|
msg354190 - (view) |
Author: Hai Shi (shihai1991) *  |
Date: 2019-10-08 11:52 |
oh, typo error. the help_lines' width in python2.7 is different python3.-->the help_lines' width in python2.7 is different with python3.x |
|
|
msg372092 - (view) |
Author: Zackery Spytz (ZackerySpytz) *  |
Date: 2020-06-22 14:53 |
Python 2 is EOL, so I think this issue should be closed. |
|
|
msg372413 - (view) |
Author: Hai Shi (shihai1991) *  |
Date: 2020-06-26 08:15 |
> Python 2 is EOL, so I think this issue should be closed. +1, if someone need create a PR, we can reopen it again. |
|
|