diff options
| author | Xiang Zhang <angwerzx@126.com> | 2017-01-22 14:41:42 +0800 |
|---|---|---|
| committer | Xiang Zhang <angwerzx@126.com> | 2017-01-22 14:41:42 +0800 |
| commit | d528791096694307884762eebc8ec6fed279f302 (patch) | |
| tree | 8a2982306e0a083a6d5137f14c1de209496290da /Lib | |
| parent | 1dfaa6c38aa8607a29728db209072a5c95481bc1 (diff) | |
| parent | b1681189af1157d9b6161c8a3a645c2eb816b415 (diff) | |
| download | cpython-git-d528791096694307884762eebc8ec6fed279f302.tar.gz | |
Issue #29290: Merge 3.6.
Diffstat (limited to 'Lib')
| -rw-r--r-- | Lib/argparse.py | 2 | ||||
| -rw-r--r-- | Lib/test/test_argparse.py | 17 |
2 files changed, 18 insertions, 1 deletions
diff --git a/Lib/argparse.py b/Lib/argparse.py index 209b4e99c1..b69c5adfa0 100644 --- a/Lib/argparse.py +++ b/Lib/argparse.py @@ -182,7 +182,7 @@ class HelpFormatter(object): 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 --git a/Lib/test/test_argparse.py b/Lib/test/test_argparse.py index bc83161630..a5c4a8ec97 100644 --- a/Lib/test/test_argparse.py +++ b/Lib/test/test_argparse.py @@ -1943,6 +1943,23 @@ class TestAddSubparsers(TestCase): ++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='+:/') |
