Skip to content
Merged
Show file tree
Hide file tree
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
validate timetuple as a tuple; cache result of _can_support_c99 upon …
…error
  • Loading branch information
blhsing committed Aug 22, 2024
commit 3530288d42ceffc9222b9ae3983884dd7261a6bb
2 changes: 1 addition & 1 deletion Lib/_pydatetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def _can_support_c99():
_supports_c99 = (
_time.strftime("%F", (1900, 1, 1, 0, 0, 0, 0, 1, 0)) == "1900-01-01")
except ValueError:
return False
_supports_c99 = False
return _supports_c99

# Correctly substitute for %z and %Z escapes in strftime formats.
Expand Down
3 changes: 3 additions & 0 deletions Modules/_datetimemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1961,6 +1961,9 @@ wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple,
#endif
) {
/* 0-pad year with century as necessary */
if (!PyTuple_Check(timetuple)) {
goto Done;
Comment thread
blhsing marked this conversation as resolved.
Outdated
}
PyObject *item = PyTuple_GetItem(timetuple, 0);
Comment thread
blhsing marked this conversation as resolved.
Outdated
if (item == NULL) {
goto Done;
Expand Down