From 92af9d0c16b88c0c6b17a9b970e6382ce48e72b4 Mon Sep 17 00:00:00 2001 From: Jakub Kulik Date: Wed, 7 Aug 2019 14:51:44 +0200 Subject: [PATCH 1/3] bpo-37785: argparse uses %s in gettext calls causing xgettext warnings --- Lib/argparse.py | 5 +++-- .../next/Library/2019-08-07-14-49-22.bpo-37785.y7OlT8.rst | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2019-08-07-14-49-22.bpo-37785.y7OlT8.rst diff --git a/Lib/argparse.py b/Lib/argparse.py index a300828f9e3d2ea..02b584bbab7be64 100644 --- a/Lib/argparse.py +++ b/Lib/argparse.py @@ -1207,8 +1207,9 @@ def __call__(self, string): return open(string, self._mode, self._bufsize, self._encoding, self._errors) except OSError as e: - message = _("can't open '%s': %s") - raise ArgumentTypeError(message % (string, e)) + args = {'filename': string, 'error': e} + message = _("can't open '%(filename)s': %(error)s") + raise ArgumentTypeError(message % (args)) def __repr__(self): args = self._mode, self._bufsize diff --git a/Misc/NEWS.d/next/Library/2019-08-07-14-49-22.bpo-37785.y7OlT8.rst b/Misc/NEWS.d/next/Library/2019-08-07-14-49-22.bpo-37785.y7OlT8.rst new file mode 100644 index 000000000000000..b28be1e490706cf --- /dev/null +++ b/Misc/NEWS.d/next/Library/2019-08-07-14-49-22.bpo-37785.y7OlT8.rst @@ -0,0 +1 @@ +Fix xgettext warnings in the argparse module. From 30abc071a5951524369b3c160cfe30d71ccb715b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Kul=C3=ADk?= Date: Mon, 12 Aug 2019 10:14:13 +0200 Subject: [PATCH 2/3] Minor improvements Co-Authored-By: Sanyam Khurana <8039608+CuriousLearner@users.noreply.github.com> --- Lib/argparse.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/argparse.py b/Lib/argparse.py index 02b584bbab7be64..3b444c4a87c5be8 100644 --- a/Lib/argparse.py +++ b/Lib/argparse.py @@ -1209,7 +1209,7 @@ def __call__(self, string): except OSError as e: args = {'filename': string, 'error': e} message = _("can't open '%(filename)s': %(error)s") - raise ArgumentTypeError(message % (args)) + raise ArgumentTypeError(message % args) def __repr__(self): args = self._mode, self._bufsize From 77c98633c028880e4520d857f3051ccd14a223a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Kul=C3=ADk?= Date: Mon, 12 Aug 2019 10:48:52 +0200 Subject: [PATCH 3/3] Minor documentation fix Co-Authored-By: Sanyam Khurana <8039608+CuriousLearner@users.noreply.github.com> --- .../next/Library/2019-08-07-14-49-22.bpo-37785.y7OlT8.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2019-08-07-14-49-22.bpo-37785.y7OlT8.rst b/Misc/NEWS.d/next/Library/2019-08-07-14-49-22.bpo-37785.y7OlT8.rst index b28be1e490706cf..2d3aa4f9a75a0ed 100644 --- a/Misc/NEWS.d/next/Library/2019-08-07-14-49-22.bpo-37785.y7OlT8.rst +++ b/Misc/NEWS.d/next/Library/2019-08-07-14-49-22.bpo-37785.y7OlT8.rst @@ -1 +1 @@ -Fix xgettext warnings in the argparse module. +Fix xgettext warnings in :mod:`argparse`.