changeset: 106261:1754722ec296 branch: 3.6 parent: 106258:409ffea5cccf parent: 106260:98cde683b9c6 user: Xiang Zhang date: Sun Jan 22 14:39:20 2017 +0800 files: Lib/argparse.py Lib/test/test_argparse.py Misc/NEWS description: Issue #29290: Merge 3.5. diff -r 409ffea5cccf -r 1754722ec296 Lib/argparse.py --- a/Lib/argparse.py Sun Jan 22 13:04:17 2017 +0800 +++ b/Lib/argparse.py Sun Jan 22 14:39:20 2017 +0800 @@ -182,7 +182,7 @@ self._root_section = self._Section(self, None) self._current_section = self._root_section - self._whitespace_matcher = _re.compile(r'\s+') + self._whitespace_matcher = _re.compile(r'\s+', _re.ASCII) self._long_break_matcher = _re.compile(r'\n\n\n+') # =============================== diff -r 409ffea5cccf -r 1754722ec296 Lib/test/test_argparse.py --- a/Lib/test/test_argparse.py Sun Jan 22 13:04:17 2017 +0800 +++ b/Lib/test/test_argparse.py Sun Jan 22 14:39:20 2017 +0800 @@ -1943,6 +1943,23 @@ ++foo foo help ''')) + def test_help_non_breaking_spaces(self): + parser = ErrorRaisingArgumentParser( + prog='PROG', description='main description') + parser.add_argument( + "--non-breaking", action='store_false', + help='help message containing non-breaking spaces shall not ' + 'wrap\N{NO-BREAK SPACE}at non-breaking spaces') + self.assertEqual(parser.format_help(), textwrap.dedent('''\ + usage: PROG [-h] [--non-breaking] + + main description + + optional arguments: + -h, --help show this help message and exit + --non-breaking help message containing non-breaking spaces shall not + wrap\N{NO-BREAK SPACE}at non-breaking spaces + ''')) def test_help_alternate_prefix_chars(self): parser = self._get_parser(prefix_chars='+:/') diff -r 409ffea5cccf -r 1754722ec296 Misc/NEWS --- a/Misc/NEWS Sun Jan 22 13:04:17 2017 +0800 +++ b/Misc/NEWS Sun Jan 22 14:39:20 2017 +0800 @@ -47,6 +47,9 @@ Library ------- +- Issue #29290: Fix a regression in argparse that help messages would wrap at + non-breaking spaces. + - Issue #28735: Fixed the comparison of mock.MagickMock with mock.ANY. - Issue #29316: Restore the provisional status of typing module, add