-
Notifications
You must be signed in to change notification settings - Fork 309
Properly coerce fractions as int #1757
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
Conversation
src/input/input_python.rs
Outdated
#[cfg(Py_3_11)] | ||
let as_int = self.call_method0("__int__"); | ||
#[cfg(not(Py_3_11))] | ||
let as_int = self.call_method0("__trunc__"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if there's a better way: maybe pyo3 can do the coercion directly? I've tried downcasting with no success.
CodSpeed Performance ReportMerging #1757 will not alter performanceComparing Summary
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think this needs to check the denominator is 1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise LGTM 👍
Original-commit-hash: eeb51e8
Change Summary
Fixes pydantic/pydantic#12063.
Related issue number
Checklist
pydantic-core
(except for expected changes)