diff --git a/Lib/argparse.py b/Lib/argparse.py index a300828f9e3d2ea..3b444c4a87c5be8 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..2d3aa4f9a75a0ed --- /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 :mod:`argparse`.