Skip to content

Commit 7c4ce6f

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 d249782 commit 7c4ce6f

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
@@ -767,6 +767,13 @@ Other codes may be available on your platform. See documentation for\n\
767767
the C library strftime function.\n"
768768

769769
#ifdef HAVE_STRFTIME
770+
// gh-154460: OpenBSD's wcsftime() computes %V incorrectly: it returns 53
771+
// whenever the ISO 8601 week belongs to a different year than tm_year.
772+
// strftime() is not affected.
773+
#ifdef __OpenBSD__
774+
# undef HAVE_WCSFTIME
775+
#endif
776+
770777
#ifdef HAVE_WCSFTIME
771778
#define time_char wchar_t
772779
#define format_time wcsftime

0 commit comments

Comments
 (0)