Skip to content

Commit e52a5f9

Browse files
committed
remove PyPayload::into_pyresult_with_type
1 parent 082f4bd commit e52a5f9

37 files changed

+147
-73
lines changed

stdlib/src/json.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ mod _json {
6060
parse_constant,
6161
ctx,
6262
}
63-
.into_pyresult_with_type(vm, cls)
63+
.into_ref_with_type(vm, cls)
64+
.map(Into::into)
6465
}
6566
}
6667

stdlib/src/pystruct.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,9 @@ pub(crate) mod _struct {
250250
fn py_new(cls: PyTypeRef, fmt: Self::Args, vm: &VirtualMachine) -> PyResult {
251251
let spec = fmt.format_spec(vm)?;
252252
let format = fmt.0;
253-
PyStruct { spec, format }.into_pyresult_with_type(vm, cls)
253+
PyStruct { spec, format }
254+
.into_ref_with_type(vm, cls)
255+
.map(Into::into)
254256
}
255257
}
256258

stdlib/src/random.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ mod _random {
7373
PyRandom {
7474
rng: PyMutex::default(),
7575
}
76-
.into_pyresult_with_type(vm, cls)
76+
.into_ref_with_type(vm, cls)
77+
.map(Into::into)
7778
}
7879
}
7980

stdlib/src/socket.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ mod _socket {
547547
impl PySocket {
548548
#[pyslot]
549549
fn slot_new(cls: PyTypeRef, _args: FuncArgs, vm: &VirtualMachine) -> PyResult {
550-
Self::default().into_pyresult_with_type(vm, cls)
550+
Self::default().into_ref_with_type(vm, cls).map(Into::into)
551551
}
552552

553553
#[pymethod(magic)]

stdlib/src/ssl.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,8 @@ mod _ssl {
489489
check_hostname: AtomicCell::new(check_hostname),
490490
protocol: proto,
491491
}
492-
.into_pyresult_with_type(vm, cls)
492+
.into_ref_with_type(vm, cls)
493+
.map(Into::into)
493494
}
494495
}
495496

vm/src/builtins/bytearray.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ pub(crate) fn init(context: &Context) {
100100
impl PyByteArray {
101101
#[pyslot]
102102
fn slot_new(cls: PyTypeRef, _args: FuncArgs, vm: &VirtualMachine) -> PyResult {
103-
PyByteArray::default().into_pyresult_with_type(vm, cls)
103+
PyByteArray::default()
104+
.into_ref_with_type(vm, cls)
105+
.map(Into::into)
104106
}
105107

106108
#[pymethod(magic)]

vm/src/builtins/classmethod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ impl Constructor for PyClassMethod {
6161
type Args = PyObjectRef;
6262

6363
fn py_new(cls: PyTypeRef, callable: Self::Args, vm: &VirtualMachine) -> PyResult {
64-
PyClassMethod { callable }.into_pyresult_with_type(vm, cls)
64+
PyClassMethod { callable }
65+
.into_ref_with_type(vm, cls)
66+
.map(Into::into)
6567
}
6668
}
6769

vm/src/builtins/complex.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,9 @@ impl Constructor for PyComplex {
142142
let value = parse_str(s.as_str().trim()).ok_or_else(|| {
143143
vm.new_value_error("complex() arg is a malformed string".to_owned())
144144
})?;
145-
return Self::from(value).into_pyresult_with_type(vm, cls);
145+
return Self::from(value)
146+
.into_ref_with_type(vm, cls)
147+
.map(Into::into);
146148
} else {
147149
return Err(vm.new_type_error(format!(
148150
"complex() first argument must be a string or a number, not '{}'",
@@ -184,7 +186,9 @@ impl Constructor for PyComplex {
184186
imag.re
185187
};
186188
let value = Complex64::new(final_real, final_imag);
187-
Self::from(value).into_pyresult_with_type(vm, cls)
189+
Self::from(value)
190+
.into_ref_with_type(vm, cls)
191+
.map(Into::into)
188192
}
189193
}
190194

vm/src/builtins/dict.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ impl PyDict {
8383

8484
#[pyslot]
8585
fn slot_new(cls: PyTypeRef, _args: FuncArgs, vm: &VirtualMachine) -> PyResult {
86-
PyDict::default().into_pyresult_with_type(vm, cls)
86+
PyDict::default()
87+
.into_ref_with_type(vm, cls)
88+
.map(Into::into)
8789
}
8890

8991
#[pymethod(magic)]

vm/src/builtins/enumerate.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ impl Constructor for PyEnumerate {
4444
counter: PyRwLock::new(counter),
4545
iterator,
4646
}
47-
.into_pyresult_with_type(vm, cls)
47+
.into_ref_with_type(vm, cls)
48+
.map(Into::into)
4849
}
4950
}
5051

0 commit comments

Comments
 (0)