8000 gh-130718: Normalize edge cases in `datetime.timestamp` and `datetime.astimezone` by donBarbos · Pull Request #130752 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-130718: Normalize edge cases in datetime.timestamp and datetime.astimezone #130752

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
Add Py_DECREF
  • Loading branch information
donBarbos committed Mar 2, 2025
commit a65ef2fa8385fd71a204f639fe13e422bd8ac3dd
1 change: 1 addition & 0 deletions Modules/_datetimemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -5429,6 +5429,7 @@
// Check edge cases
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be more specific — what this code does is very opaque, so we should have a "why" comment here. Something like "When the year is outside the allowed year boundaries, return the original utc timestamp because ".

int year = local_time.tm_year + 1900;
if (year < MINYEAR || year > MAXYEAR) {
Py_DECREF(year);

Check warning on line 5432 in Modules/_datetimemodule.c

View workflow job for this annotation

GitHub Actions / Windows / build (arm64)

'type cast': conversion from 'int' to 'PyObject *' of greater size [D:\a\cpython\cpython\PCbuild\pythoncore.vcxproj]

Check warning on line 5432 in Modules/_datetimemodule.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / build (arm64)

'type cast': conversion from 'int' to 'PyObject *' of greater size [D:\a\cpython\cpython\PCbuild\pythoncore.vcxproj]

Check warning on line 5432 in Modules/_datetimemodule.c

View workflow job for this annotation

GitHub Actions / Windows / build and test (x64)

'type cast': conversion from 'int' to 'PyObject *' of greater size [D:\a\cpython\cpython\PCbuild\pythoncore.vcxproj]

Check warning on line 5432 in Modules/_datetimemodule.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / build and test (x64)

'type cast': conversion from 'int' to 'PyObject *' of greater size [D:\a\cpython\cpython\PCbuild\pythoncore.vcxproj]
return old_u;
}
return utc_to_seconds(year,
Expand Down
Loading
0