
This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
Created on2019-11-16 17:43 byfedericobond, last changed2022-04-11 14:59 byadmin. This issue is nowclosed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 17192 | merged | python-dev,2019-11-16 17:52 | |
| PR 17288 | merged | miss-islington,2019-11-20 13:29 | |
| PR 17289 | merged | miss-islington,2019-11-20 13:30 | |
| Messages (5) | |||
|---|---|---|---|
| msg356761 -(view) | Author: Federico Bond (federicobond)* | Date: 2019-11-16 17:43 | |
The call to 'ngettext' in 'ArgumentParser._match_argument' (Lib/argparse.py) uses a non-integer value, which causes it to fail with a nonsensical exception. Non-integer values were deprecated inbpo-28692.This happens because the 'default' error message is computed unconditionally, even when the value of 'action.nargs' is 'None' and another message will be ultimately selected.This issue is similar tobpo-35785 which was not reproduced by other people at the moment and was eventually closed. I could not create a short reproducer but could match several of the points described in that issue. A little debugging turned up that gettext was loading a catalog from the 'natural' PyPI package which uses 'Plural-Forms' too. File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/argparse.py", line 1755, in parse_args args, argv = self.parse_known_args(args, namespace) File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/argparse.py", line 1787, in parse_known_args namespace, args = self._parse_known_args(args, namespace) File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/argparse.py", line 1993, in _parse_known_args start_index = consume_optional(start_index) File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/argparse.py", line 1923, in consume_optional arg_count = match_argument(action, selected_patterns) File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/argparse.py", line 2086, in _match_argument action.nargs) % action.nargs File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/gettext.py", line 631, in ngettext return dngettext(_current_domain, msgid1, msgid2, n) File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/gettext.py", line 610, in dngettext return t.ngettext(msgid1, msgid2, n) File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/gettext.py", line 462, in ngettext tmsg = self._catalog[(msgid1, self.plural(n))] File "<string>", line 4, in func File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/gettext.py", line 168, in _as_int (n.__class__.__name__,)) from NoneTypeError: Plural value must be an integer, got NoneType | |||
| msg357069 -(view) | Author: Tal Einat (taleinat)*![]() | Date: 2019-11-20 13:29 | |
New changesetbe5c79e0338005d675a64ba6e5b137e850d556d1 by Tal Einat (Federico Bond) in branch 'master':bpo-38821: Fix crash in argparse when using gettext (GH-17192)https://github.com/python/cpython/commit/be5c79e0338005d675a64ba6e5b137e850d556d1 | |||
| msg357070 -(view) | Author: Tal Einat (taleinat)*![]() | Date: 2019-11-20 13:32 | |
Thanks for the report and the PR with a fix, Federico!As discussed on in the PR comments, the PR did not include tests since there are currently no tests for argparse i18n. Please create a new issue for that, referencing this one. | |||
| msg357071 -(view) | Author: miss-islington (miss-islington) | Date: 2019-11-20 13:48 | |
New changesetecb2afc1bc1c2f3f9f99b09dd866100c3c7dcab7 by Miss Islington (bot) in branch '3.7':bpo-38821: Fix crash in argparse when using gettext (GH-17192)https://github.com/python/cpython/commit/ecb2afc1bc1c2f3f9f99b09dd866100c3c7dcab7 | |||
| msg357072 -(view) | Author: miss-islington (miss-islington) | Date: 2019-11-20 13:48 | |
New changeset836f137f7ae0799de937e5281cb1da2bfdb8a69d by Miss Islington (bot) in branch '3.8':bpo-38821: Fix crash in argparse when using gettext (GH-17192)https://github.com/python/cpython/commit/836f137f7ae0799de937e5281cb1da2bfdb8a69d | |||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:59:23 | admin | set | github: 83002 |
| 2019-11-20 13:48:29 | miss-islington | set | messages: +msg357072 |
| 2019-11-20 13:48:24 | miss-islington | set | nosy: +miss-islington messages: +msg357071 |
| 2019-11-20 13:32:39 | taleinat | set | status: open -> closed stage: patch review -> resolved resolution: fixed versions: + Python 3.7 |
| 2019-11-20 13:32:29 | taleinat | set | messages: +msg357070 |
| 2019-11-20 13:30:03 | miss-islington | set | pull_requests: +pull_request16782 |
| 2019-11-20 13:29:42 | miss-islington | set | pull_requests: +pull_request16781 |
| 2019-11-20 13:29:33 | taleinat | set | nosy: +taleinat messages: +msg357069 |
| 2019-11-18 17:44:48 | paul.j3 | set | nosy: +paul.j3 |
| 2019-11-16 17:52:50 | python-dev | set | keywords: +patch stage: patch review pull_requests: +pull_request16698 |
| 2019-11-16 17:43:26 | federicobond | create | |