gh-102402: Fix floating point math issue by using time.time_ns() in logging.LogRecord#102412
Merged
vsajip merged 24 commits intopython:mainfrom Apr 16, 2024
dougthor42:fix-gh-102402-logging-msecs
Merged
gh-102402: Fix floating point math issue by using time.time_ns() in logging.LogRecord#102412vsajip merged 24 commits intopython:mainfrom dougthor42:fix-gh-102402-logging-msecs
time.time_ns() in logging.LogRecord#102412vsajip merged 24 commits intopython:mainfrom
dougthor42:fix-gh-102402-logging-msecs
Conversation
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.
gh-102402: Fix floating point math issue by using
time.time_ns()inlogging.LogRecord.logging.LogRecordto usetime.time_ns()instead oftime.time().LogRecord.msecsto be robust against floating point / binary representation arithmetic errorsNotes / Open Questions:
LogRecord.msecsis a float so I kept it that way. Why is it a float even though it always has.0?LogRecord.createdas a float in seconds.logging.__init__so I didn't add any for the new code. Would you like me to add some annotations?I opted to use string manipulation to grab themsecs. I have an integer math-based approach, but it's, IMO, more verbose and harder to read/understand. LMK if you want me to switch back to that (there are still some minor fixes to apply to it).msecs-related bug.Fixes #102402.