8000 gh-122272: guarantee specifiers %F and %C for datetime.strftime to be 0-padded by blhsing · Pull Request #122436 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-122272: guarantee specifiers %F and %C for datetime.strftime to be 0-padded #122436

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
allocate 6 more bytes for the formatted date buffer only when %F is s…
…upported
  • Loading branch information
blhsing committed Jul 31, 2024
commit fd8dd3099de4a4817bfabd8a88205e7e17aef172
11 changes: 7 additions & 4 deletions Modules/_datetimemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1852,10 +1852,13 @@ wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple,
Py_ssize_t ntoappend; /* # of bytes to append to output buffer */

#ifdef Py_NORMALIZE_CENTURY
/* Buffer of maximum size of formatted year permitted by long.
* Adding 6 just to accomodate %F with dashes, 2-digit month and day.
*/
char buf[SIZEOF_LONG*5/2+2+6];
/* Buffer of maximum size of formatted year permitted by long. */
char buf[SIZEOF_LONG * 5 / 2 + 2
#ifdef Py_STRFTIME_C99_SUPPORT
/* Need 6 more to accomodate dashes, 2-digit month and day for %F. */
+ 6
#endif
];
#endif

assert(object && format && timetuple);
Expand Down
Loading
0