We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7b08953 commit 5d6ce6cCopy full SHA for 5d6ce6c
vm/src/stdlib/os.rs
@@ -130,9 +130,9 @@ pub(crate) enum OsPathOrFd {
130
131
impl TryFromObject for OsPathOrFd {
132
fn try_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<Self> {
133
- let r = match obj.downcast::<PyInt>() {
134
- Ok(int) => Self::Fd(int.try_to_primitive(vm)?),
135
- Err(obj) => Self::Path(obj.try_into_value(vm)?),
+ let r = match obj.try_index_opt(vm) {
+ Some(int) => Self::Fd(int?.try_to_primitive(vm)?),
+ None => Self::Path(obj.try_into_value(vm)?),
136
};
137
Ok(r)
138
}
0 commit comments