Skip to content

Commit e325a00

Browse files
jopemachineyouknowone
authored andcommitted
Revert "Add SetNameArgs"
This reverts commit 2994e3f.
1 parent e967e5e commit e325a00

1 file changed

Lines changed: 16 additions & 11 deletions

File tree

vm/src/builtins/property.rs

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

58-
#[derive(FromArgs)]
59-
struct SetNameArgs {
60-
#[pyarg(positional)]
61-
owner: PyObjectRef,
62-
#[pyarg(positional)]
63-
str: PyStrRef,
64-
}
65-
6659
#[pyclass(with(Constructor, Initializer, GetDescriptor), flags(BASETYPE))]
6760
impl PyProperty {
6861
// Descriptor methods
@@ -131,8 +124,20 @@ impl PyProperty {
131124
}
132125

133126
#[pymethod(magic)]
134-
fn set_name(&self, _args: SetNameArgs, _vm: &VirtualMachine) -> PyResult<()> {
135-
Ok(())
127+
fn set_name(&self, args: PosArgs, vm: &VirtualMachine) -> PyResult<()> {
128+
let arg_len = args.into_vec().len();
129+
130+
if arg_len != 2 {
131+
Err(vm.new_exception_msg(
132+
vm.ctx.exceptions.type_error.to_owned(),
133+
format!(
134+
"__set_name__() takes 2 positional arguments but {} were given",
135+
arg_len
136+
),
137+
))
138+
} else {
139+
Ok(())
140+
}
136141
}
137142

138143
// Python builder functions

0 commit comments

Comments
 (0)