-
Notifications
You must be signed in to change notification settings - Fork 682
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
chrono::DateTime::to_object()
can panic
#4029
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The range of possible values of
chrono::DateTime
is much larger than that of Python'sdatetime
(which is limited by 1 <= year <= 9999), so there cannot be a one to one mapping. As a consequence, the functionchrono::DateTime::to_object()
panics for dates far in the future or far in the past. (tested with version 0.21.0)In most situations this is probably not an issue. In my personal use case however, I am deserializing data received over the network in an extension module, and hand the results over to a Python process. In this case, a malicious actor could crash my module by simply sending some date with year >= 10k.
Do you mind adding something like
chrono::DateTime::try_to_object()
which fails savely?The text was updated successfully, but these errors were encountered: