Skip to content

Commit

Permalink
fix int subclass upcasting
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhewitt committed Aug 21, 2023
1 parent 47f1887 commit 16e10e0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/input/input_python.rs
Expand Up @@ -298,7 +298,13 @@ impl<'a> Input<'a> for PyAny {
} else {
Exactness::Strict
};
return Ok(ValidationMatch::new(EitherInt::Py(self), exactness));
// extract a Rust value so that the subclass gets upcast to an int
return if let Ok(i64) = self.extract() {
Ok(ValidationMatch::new(EitherInt::I64(i64), exactness))
} else {
let big_int = self.extract()?;
Ok(ValidationMatch::new(EitherInt::BigInt(big_int), exactness))
};
}

if !strict {
Expand Down

0 comments on commit 16e10e0

Please sign in to comment.