New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
argparse breaks long lines on NO-BREAK SPACE #73476
Comments
argparse help incorrectly breaks long lines on U+u00A0 NO-BREAK SPACE. The attached script has been run on Python 3.5.3rc1 in a terminal window 80 columns wide, and it produces output::
I expected the last line should have broken just before the "M+ 1M", rather than in the middle. See also bpo-20491. |
Here's a slightly simpler demo, without the (fortunately harmless) typo. |
Maybe a duplicate of bpo-16623 |
textwrap has been fixed in bpo-20491 but this problem still exists. The reason seems to be that argparse replaces the non-break spaces with spaces: before self.whitespace_matcher.sub |
I think this is a regression when coming to 3.x. In 2.7, r'\s+' is by default in ASCII mode and won't match unicode non-breaking spaces. In 3.x it's by default unicode mode so non-breaking spaces are replaced by spaces. I think we can just use [ \t\n\r\f\v]+. Since here are more active core devs I am going to close bpo-16623 and move this forward here. |
v2 addresses the comments. I didn't receive the review notification mail so just saw them today. :-( |
LGTM. You perhaps need to change your email provider Xiang. It fails too often. |
New changeset 98cde683b9c6 by Xiang Zhang in branch '3.5': New changeset 1754722ec296 by Xiang Zhang in branch '3.6': New changeset c47a72627f0c by Xiang Zhang in branch 'default': |
Thanks Serhiy. BTW, bpo-16623 is about 2.7 and the cause is wrap doesn't handle unicode non-breaking spaces right. So it's not the same thing as here. |
The test "test_help_non_breaking_spaces" from Zhang's commit fails on my platform (other 1563 tests in the module all pass). Interestingly, if running the entire test suite, it doesn't fail. It's only when executing the test_argparse.py module directly that causes the failure. I guess there is some mutable state, or the test doesn't entirely setup correctly. |
I can't reproduce the failure in anyway. :-( Could you do some investigation and give more info? |
Misc/NEWS
so that it is managed by towncrier #552Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: