Skip to content

Commit 2994e3f

Browse files
committed
Add SetNameArgs
1 parent e9d37bf commit 2994e3f

1 file changed

Lines changed: 11 additions & 16 deletions

File tree

vm/src/builtins/property.rs

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
/*! Python `property` descriptor class.
22
33
*/
4-
use super::{PyType, PyTypeRef};
4+
use super::{PyStrRef, PyType, PyTypeRef};
55
use crate::common::lock::PyRwLock;
6-
use crate::function::PosArgs;
76
use crate::{
87
class::PyClassImpl,
98
function::{FuncArgs, PySetterValue},
@@ -88,6 +87,14 @@ impl GetDescriptor for PyProperty {
8887
}
8988
}
9089

90+
#[derive(FromArgs)]
91+
struct SetNameArgs {
92+
#[pyarg(positional)]
93+
owner: PyObjectRef,
94+
#[pyarg(positional)]
95+
str: PyStrRef,
96+
}
97+
9198
#[pyclass(with(Constructor, Initializer, GetDescriptor), flags(BASETYPE))]
9299
impl PyProperty {
93100
// Descriptor methods
@@ -156,20 +163,8 @@ impl PyProperty {
156163
}
157164

158165
#[pymethod(magic)]
159-
fn set_name(&self, args: PosArgs, vm: &VirtualMachine) -> PyResult<()> {
160-
let arg_len = args.into_vec().len();
161-
162-
if arg_len != 2 {
163-
Err(vm.new_exception_msg(
164-
vm.ctx.exceptions.type_error.to_owned(),
165-
format!(
166-
"__set_name__() takes 2 positional arguments but {} were given",
167-
arg_len
168-
),
169-
))
170-
} else {
171-
Ok(())
172-
}
166+
fn set_name(&self, _args: SetNameArgs, _vm: &VirtualMachine) -> PyResult<()> {
167+
Ok(())
173168
}
174169

175170
// Python builder functions

0 commit comments

Comments
 (0)