This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Date formats in help messages of argparse
Type: enhancement Stage: patch review
Components: Library (Lib) Versions: Python 3.11
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Julian,, paul.j3, python-dev, rhettinger
Priority: normal Keywords: patch

Created on 2021-08-23 23:22 by, last changed 2022-04-11 14:59 by admin.

File name Uploaded Description Edit, 2021-08-23 23:22
Pull Requests
URL Status Linked Edit
PR 27923 open python-dev, 2021-08-23 23:26
Messages (3)
msg400183 - (view) Author: Matías Senger ( * Date: 2021-08-23 23:22
If the help message of an argument in argparse contains a date format, e.g. %Y-%m-%d, it crashes when printing the help after being invoked with the -h option. Uploaded an example.
msg400246 - (view) Author: Julian Berman (Julian) * Date: 2021-08-25 07:34
This is documented already I believe:

> As the help string supports %-formatting, if you want a literal % to appear in the help string, you must escape it as %%.
msg400327 - (view) Author: Matías Senger ( * Date: 2021-08-26 09:16
With this change there should be no need to escape anything, and it is still compatible with the old formatting. Plus, with the current implementation if you forget to escape something like %Y the error message is not helpful at all and only happens when invoked with -h option.
Date User Action Args
2022-04-11 14:59:49adminsetgithub: 89149
2021-09-03 00:59:17paul.j3setnosy: + paul.j3
2021-08-26 + msg400327
2021-08-25 07:34:14Juliansetnosy: + Julian
messages: + msg400246
2021-08-25 00:09:01rhettingersetmessages: - msg400243
2021-08-24 23:25:04rhettingersettype: crash -> enhancement

messages: + msg400243
nosy: + rhettinger
2021-08-23 23:26:17python-devsetkeywords: + patch
nosy: + python-dev

pull_requests: + pull_request26375
stage: patch review