GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-73267: Normalize strptime day of year after rollover by zolaski333 · Pull Request #158459 · python/cpython

Conversation

@zolaski333

@zolaski333 zolaski333 commented Sep 29, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Bug

time.strptime("2016 52 0", "%Y %W %w") resolves to 2017-01-01 but currently returns tm_yday=367. This is outside the documented 1–366 range; on Windows, passing the result to time.strftime() raises ValueError. A rollover from %U or %j can also leave a valid-looking but incorrect tm_yday.

_strptime converts the ordinal to a date and updates its year, month, and day, but leaves julian relative to the input year. Recompute julian from the resolved date when the year changes.

Tests

  • Added regression cases for %W, %U, and %j crossing into the next year. These failed before the fix and pass afterward.
  • PCbuild\amd64\python.exe -X dev -m test test_strptime test_time test_datetime: 1,292 tests run, 123 skipped; success.
  • PCbuild\amd64\python.exe Tools\patchcheck\patchcheck.py: success.
  • Full local Windows suite (-X dev -m test -j4): 50,966 tests run; 443 test files passed, 3 unrelated files failed. test_os.test_device_encoding fails because this runner presents stdin as a TTY but os.device_encoding(0) is None (the module passes with piped stdin). test_posixpath.test_realpath_invalid_paths expects FileNotFoundError for a NUL path but gets ValueError (reproduces in isolation). test_ssl.test_pha_required_nocert saw a localized Windows connection-reset message that did not match its English regex (the module passes in isolation).

Fixes #73267.

AI assistance was used to investigate and prepare this change. The patch and test results were reviewed before submission.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@zolaski333
pythongh-73267: Normalize strptime day of year after rollover
5ae9da0
@python-cla-bot

python-cla-bot Bot commented Sep 29, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot mentioned this pull request Sep 29, 2026
time.strptime() with year rollover returns out-of-range tm_yday #73267
Open
@zolaski333
zolaski333 marked this pull request as ready for review September 29, 2026 23:20
@zolaski333
zolaski333 requested review from StanFromIreland and pganssle as code owners September 29, 2026 23:20
@bedevere-app bedevere-app Bot added the awaiting review label Sep 29, 2026
@zolaski333 zolaski333 closed this Oct 24, 2026
@Pixeless001 Pixeless001 mentioned this pull request Nov 11, 2026
gh-73267: Fix tm_yday in time.strptime() when a week rolls over a year #161828
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@pganssle pganssle Awaiting requested review from pganssle pganssle is a code owner
@StanFromIreland StanFromIreland Awaiting requested review from StanFromIreland StanFromIreland is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting review

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

time.strptime() with year rollover returns out-of-range tm_yday

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@zolaski333
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.