Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Commit b168118

Browse files
committed
Issue python#29290: Merge 3.5.
2 parents 4459e00 + 7fe28ad commit b168118

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

Lib/argparse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def __init__(self,
182182
self._root_section = self._Section(self, None)
183183
self._current_section = self._root_section
184184

185-
self._whitespace_matcher = _re.compile(r'\s+')
185+
self._whitespace_matcher = _re.compile(r'\s+', _re.ASCII)
186186
self._long_break_matcher = _re.compile(r'\n\n\n+')
187187

188188
# ===============================

Lib/test/test_argparse.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1943,6 +1943,23 @@ def test_help_extra_prefix_chars(self):
19431943
++foo foo help
19441944
'''))
19451945

1946+
def test_help_non_breaking_spaces(self):
1947+
parser = ErrorRaisingArgumentParser(
1948+
prog='PROG', description='main description')
1949+
parser.add_argument(
1950+
"--non-breaking", action='store_false',
1951+
help='help message containing non-breaking spaces shall not '
1952+
'wrap\N{NO-BREAK SPACE}at non-breaking spaces')
1953+
self.assertEqual(parser.format_help(), textwrap.dedent('''\
1954+
usage: PROG [-h] [--non-breaking]
1955+
1956+
main description
1957+
1958+
optional arguments:
1959+
-h, --help show this help message and exit
1960+
--non-breaking help message containing non-breaking spaces shall not
1961+
wrap\N{NO-BREAK SPACE}at non-breaking spaces
1962+
'''))
19461963

19471964
def test_help_alternate_prefix_chars(self):
19481965
parser = self._get_parser(prefix_chars='+:/')

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ Core and Builtins
4747
Library
4848
-------
4949

50+
- Issue #29290: Fix a regression in argparse that help messages would wrap at
51+
non-breaking spaces.
52+
5053
- Issue #28735: Fixed the comparison of mock.MagickMock with mock.ANY.
5154

5255
- Issue #29316: Restore the provisional status of typing module, add

0 commit comments

Comments
 (0)