Skip to content

gh-154460: Do not use wcsftime() on OpenBSD#154461

Merged
ambv merged 2 commits into
python:mainfrom
serhiy-storchaka:wcsftime-openbsd
Jul 22, 2026
Merged

gh-154460: Do not use wcsftime() on OpenBSD#154461
ambv merged 2 commits into
python:mainfrom
serhiy-storchaka:wcsftime-openbsd

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Jul 22, 2026

Copy link
Copy Markdown
Member

OpenBSD's wcsftime() returns 53 for %V whenever the ISO 8601 week belongs to other year than tm_year, while its strftime() is correct. Both carry the same obsolete XPG4-1994 override, but strftime.c guards it with #ifdef XPG4_1994_04_09 (never defined) and wcsftime.c lost that guard when it was created in 2011. Reported to bugs@openbsd.org.

HAVE_WCSFTIME is used only here, and OpenBSD supports only the C and UTF-8 encodings for LC_CTYPE, so decoding the result of strftime() with the locale encoding is safe.

Verified on OpenBSD 7.9: %G-%V now matches date.isocalendar() for all tested dates, and 16 test_strptime failures are gone.

OpenBSD's wcsftime() computes the ISO 8601 week number (%V) incorrectly,
while its strftime() is correct.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@StanFromIreland

Copy link
Copy Markdown
Member

You reported this previously in #75816, and Paul reported the wcstrftime() bug to OpenBSD in 2018 (email).

Comment thread Modules/timemodule.c Outdated
Co-authored-by: Stan Ulbrych <stan@python.org>
@serhiy-storchaka

Copy link
Copy Markdown
Member Author

Yes, I referred the old issue. I reported the bug upstream again, this time with a simple 2-line fix.

@ambv
ambv merged commit f195b2e into python:main Jul 22, 2026
96 of 98 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @serhiy-storchaka for the PR, and @ambv for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Jul 22, 2026

Copy link
Copy Markdown

GH-154474 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Jul 22, 2026
@bedevere-app

bedevere-app Bot commented Jul 22, 2026

Copy link
Copy Markdown

GH-154475 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Jul 22, 2026
@bedevere-app

bedevere-app Bot commented Jul 22, 2026

Copy link
Copy Markdown

GH-154476 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Jul 22, 2026
serhiy-storchaka added a commit that referenced this pull request Jul 22, 2026
…4476)

(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>
serhiy-storchaka added a commit that referenced this pull request Jul 22, 2026
…4475)

(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>
serhiy-storchaka added a commit that referenced this pull request Jul 22, 2026
…4474)

(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>
@StanFromIreland

Copy link
Copy Markdown
Member

In the future, could you please wait for a CODEOWNER (me/Paul currently) to review before merging, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants