Resolve SOURCE_DATE_EPOCH=0 bug.#3795
Merged
lovelydinosaur merged 2 commits intomasterfrom Aug 28, 2024
Merged
Conversation
Not clear to me if... * There may also be a timezone issue here leading to the negative value. And furthermore... * Non-integer values will still raise an exception here. But this does at least resolve the immediate issue.
pawamoy
reviewed
Aug 1, 2024
Contributor
pawamoy
left a comment
There was a problem hiding this comment.
Thanks for the quick fix @tomchristie. Just wondering what the issue exactly was.
mkdocs/utils/__init__.py
Outdated
| else: | ||
| dt = get_build_datetime() | ||
| return int(dt.timestamp()) | ||
| return max(int(dt.timestamp()), 0) |
Contributor
There was a problem hiding this comment.
I'm not sure to understand the fix (but believe you that it actually fixes the issue). Is it a timezone-aware/naive issue? I gather int(dt.timestamp()) would return a negative integer when there are no pages and SOURCE_DATE_EPOCH=0? But why 🤔?
Contributor
There was a problem hiding this comment.
Should we add an actual test by the way? To prevent any regression.
lovelydinosaur
commented
Aug 23, 2024
| # Lexicographic comparison is OK for ISO date. | ||
| date_string = max(p.update_date for p in pages) | ||
| dt = datetime.fromisoformat(date_string) | ||
| dt = datetime.fromisoformat(date_string).replace(tzinfo=timezone.utc) |
Member
Author
There was a problem hiding this comment.
The issue is that we're using utc timezone datetimes everywhere, except here.
The robust fix is that we update this naive timezone into a utc based timezone.
Contributor
|
Thanks! |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #3794
Not clear to me if...
And furthermore...
But this does at least resolve the immediate issue.
Thanks to @vedranmiletic for raising the issue and @pawamoy for the confimation.