forked from Rust-related/RustPython
Remove PyPaylod::special_retrieve
This commit is contained in:
@@ -53,10 +53,6 @@ impl PyPayload for PyInt {
|
||||
fn into_pyobject(self, vm: &VirtualMachine) -> PyObjectRef {
|
||||
vm.ctx.new_int(self.value).into()
|
||||
}
|
||||
|
||||
fn special_retrieve(vm: &VirtualMachine, obj: &PyObject) -> Option<PyResult<PyRef<Self>>> {
|
||||
Some(obj.try_index(vm))
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! impl_into_pyobject_int {
|
||||
|
||||
@@ -44,14 +44,11 @@ impl PyObject {
|
||||
F: Fn(&T) -> PyResult<R>,
|
||||
{
|
||||
let class = T::class(vm);
|
||||
let special;
|
||||
let py_ref = if self.fast_isinstance(class) {
|
||||
self.downcast_ref()
|
||||
.ok_or_else(|| vm.new_downcast_runtime_error(class, self))?
|
||||
} else {
|
||||
special = T::special_retrieve(vm, self)
|
||||
.unwrap_or_else(|| Err(vm.new_downcast_type_error(class, self)))?;
|
||||
&special
|
||||
return Err(vm.new_downcast_type_error(class, self));
|
||||
};
|
||||
f(py_ref)
|
||||
}
|
||||
@@ -74,8 +71,7 @@ where
|
||||
obj.downcast()
|
||||
.map_err(|obj| vm.new_downcast_runtime_error(class, &obj))
|
||||
} else {
|
||||
T::special_retrieve(vm, &obj)
|
||||
.unwrap_or_else(|| Err(vm.new_downcast_type_error(class, &obj)))
|
||||
Err(vm.new_downcast_type_error(class, &obj))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use super::{Py, PyObject, PyObjectRef, PyRef, PyResult};
|
||||
use super::{Py, PyObjectRef, PyRef, PyResult};
|
||||
use crate::{
|
||||
builtins::{PyBaseExceptionRef, PyType, PyTypeRef},
|
||||
types::PyTypeFlags,
|
||||
@@ -23,11 +23,6 @@ pub trait PyPayload: std::fmt::Debug + PyThreadingConstraint + Sized + 'static {
|
||||
self.into_ref(vm).into()
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn special_retrieve(_vm: &VirtualMachine, _obj: &PyObject) -> Option<PyResult<PyRef<Self>>> {
|
||||
None
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn _into_ref(self, cls: PyTypeRef, vm: &VirtualMachine) -> PyRef<Self> {
|
||||
let dict = if cls.slots.flags.has_feature(PyTypeFlags::HAS_DICT) {
|
||||
|
||||
Reference in New Issue
Block a user