Skip to content

Commit 1848dd9

Browse files
authored
Merge pull request RustPython#2181 from edwardycl/pyvalue
Remove PyValue::into_object & Rename PyValue::into_simple_object to PyValue::into_object
2 parents c1a355f + 380e5a4 commit 1848dd9

File tree

3 files changed

+7
-30
lines changed

3 files changed

+7
-30
lines changed

vm/src/obj/objint.rs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use num_traits::{One, Pow, Signed, ToPrimitive, Zero};
99
use super::objbool::IntoPyBool;
1010
use super::objbytearray::PyByteArray;
1111
use super::objbytes::PyBytes;
12-
use super::objdict::PyDictRef;
1312
use super::objfloat;
1413
use super::objmemory::PyMemoryView;
1514
use super::objstr::{PyString, PyStringRef};
@@ -19,7 +18,7 @@ use crate::format::FormatSpec;
1918
use crate::function::{OptionalArg, PyFuncArgs};
2019
use crate::pyobject::{
2120
BorrowValue, IdProtocol, IntoPyObject, IntoPyResult, PyArithmaticValue, PyClassImpl,
22-
PyComparisonValue, PyContext, PyObject, PyObjectRef, PyRef, PyResult, PyValue, TryFromObject,
21+
PyComparisonValue, PyContext, PyObjectRef, PyRef, PyResult, PyValue, TryFromObject,
2322
TypeProtocol,
2423
};
2524
use crate::stdlib::array::PyArray;
@@ -76,22 +75,9 @@ impl PyValue for PyInt {
7675
vm.ctx.types.int_type.clone()
7776
}
7877

79-
fn into_simple_object(self, vm: &VirtualMachine) -> PyObjectRef {
78+
fn into_object(self, vm: &VirtualMachine) -> PyObjectRef {
8079
vm.ctx.new_int(self.value)
8180
}
82-
83-
fn into_object(
84-
self,
85-
vm: &VirtualMachine,
86-
cls: PyClassRef,
87-
dict: Option<PyDictRef>,
88-
) -> PyObjectRef {
89-
if cls.is(&Self::class(vm)) {
90-
vm.ctx.new_int(self.value)
91-
} else {
92-
PyObject::new(self, cls, dict)
93-
}
94-
}
9581
}
9682

9783
macro_rules! impl_into_pyobject_int {

vm/src/pyobject.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,7 @@ where
10361036
T: PyValue + Sized,
10371037
{
10381038
fn into_pyobject(self, vm: &VirtualMachine) -> PyObjectRef {
1039-
PyValue::into_simple_object(self, vm)
1039+
PyValue::into_object(self, vm)
10401040
}
10411041
}
10421042

@@ -1148,19 +1148,10 @@ cfg_if::cfg_if! {
11481148
pub trait PyValue: fmt::Debug + PyThreadingConstraint + Sized + 'static {
11491149
fn class(vm: &VirtualMachine) -> PyClassRef;
11501150

1151-
fn into_simple_object(self, vm: &VirtualMachine) -> PyObjectRef {
1151+
fn into_object(self, vm: &VirtualMachine) -> PyObjectRef {
11521152
self.into_ref(vm).into_object()
11531153
}
11541154

1155-
fn into_object(
1156-
self,
1157-
_vm: &VirtualMachine,
1158-
cls: PyClassRef,
1159-
dict: Option<PyDictRef>,
1160-
) -> PyObjectRef {
1161-
PyObject::new(self, cls, dict)
1162-
}
1163-
11641155
fn into_ref(self, vm: &VirtualMachine) -> PyRef<Self> {
11651156
self.into_ref_with_type_unchecked(Self::class(vm), vm)
11661157
}

vm/src/stdlib/array.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ macro_rules! def_array_enum {
214214
let obj = PyArray {
215215
array: PyRwLock::new(sliced)
216216
}
217-
.into_simple_object(vm);
217+
.into_object(vm);
218218
Ok(obj)
219219
})*
220220
}
@@ -432,7 +432,7 @@ macro_rules! def_array_enum {
432432
let obj = PyArray {
433433
array: PyRwLock::new(sliced)
434434
}
435-
.into_simple_object(vm);
435+
.into_object(vm);
436436
Ok(obj)
437437
} else {
438438
Err(vm.new_type_error("bad argument type for built-in operation".to_owned()))
@@ -460,7 +460,7 @@ macro_rules! def_array_enum {
460460
PyArray {
461461
array: PyRwLock::new(sliced)
462462
}
463-
.into_simple_object(vm)
463+
.into_object(vm)
464464
})*
465465
}
466466
}

0 commit comments

Comments
 (0)