Skip to content

Commit fab3e6c

Browse files
serhiy-storchakaclaudeStanFromIreland
authored andcommitted
gh-154460: Do not use wcsftime() on OpenBSD (GH-154461)
(cherry picked from commit f195b2e) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> Co-authored-by: Stan Ulbrych <stan@python.org>
1 parent 71fa9b4 commit fab3e6c

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix :func:`time.strftime` and :meth:`datetime.datetime.strftime` returning a
2+
wrong ISO 8601 week number (``%V``) on OpenBSD.

Modules/timemodule.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,13 @@ Other codes may be available on your platform. See documentation for\n\
763763
the C library strftime function.\n"
764764

765765
#ifdef HAVE_STRFTIME
766+
// gh-154460: OpenBSD's wcsftime() computes %V incorrectly: it returns 53
767+
// whenever the ISO 8601 week belongs to a different year than tm_year.
768+
// strftime() is not affected.
769+
#ifdef __OpenBSD__
770+
# undef HAVE_WCSFTIME
771+
#endif
772+
766773
#ifdef HAVE_WCSFTIME
767774
#define time_char wchar_t
768775
#define format_time wcsftime

0 commit comments

Comments
 (0)