diff --git a/vm/src/builtins/classmethod.rs b/vm/src/builtins/classmethod.rs index 78a8941ae..4f536d048 100644 --- a/vm/src/builtins/classmethod.rs +++ b/vm/src/builtins/classmethod.rs @@ -61,7 +61,7 @@ impl PyClassMethod { PyClassMethod { callable }.into_ref_with_type(vm, cls) } - #[pyproperty(name = "__func__")] + #[pyproperty(magic)] fn func(&self) -> PyObjectRef { self.callable.clone() } diff --git a/vm/src/builtins/complex.rs b/vm/src/builtins/complex.rs index d58bc0f4e..1c2f0145e 100644 --- a/vm/src/builtins/complex.rs +++ b/vm/src/builtins/complex.rs @@ -89,12 +89,12 @@ impl PyComplex { self.value } - #[pyproperty(name = "real")] + #[pyproperty] fn real(&self) -> f64 { self.value.re } - #[pyproperty(name = "imag")] + #[pyproperty] fn imag(&self) -> f64 { self.value.im } diff --git a/vm/src/builtins/range.rs b/vm/src/builtins/range.rs index ab1105047..3e708299e 100644 --- a/vm/src/builtins/range.rs +++ b/vm/src/builtins/range.rs @@ -201,17 +201,17 @@ impl PyRange { PyRange { start, stop, step }.into_ref_with_type(vm, cls) } - #[pyproperty(name = "start")] + #[pyproperty] fn start(&self) -> PyIntRef { self.start.clone() } - #[pyproperty(name = "stop")] + #[pyproperty] fn stop(&self) -> PyIntRef { self.stop.clone() } - #[pyproperty(name = "step")] + #[pyproperty] fn step(&self) -> PyIntRef { self.step.clone() } diff --git a/vm/src/builtins/slice.rs b/vm/src/builtins/slice.rs index 4e88061bb..f94914b7a 100644 --- a/vm/src/builtins/slice.rs +++ b/vm/src/builtins/slice.rs @@ -30,7 +30,7 @@ pub type PySliceRef = PyRef; #[pyimpl(with(Hashable, Comparable))] impl PySlice { - #[pyproperty(name = "start")] + #[pyproperty] fn start(&self, vm: &VirtualMachine) -> PyObjectRef { self.start.clone().into_pyobject(vm) } @@ -42,12 +42,12 @@ impl PySlice { } } - #[pyproperty(name = "stop")] + #[pyproperty] fn stop(&self, _vm: &VirtualMachine) -> PyObjectRef { self.stop.clone() } - #[pyproperty(name = "step")] + #[pyproperty] fn step(&self, vm: &VirtualMachine) -> PyObjectRef { self.step.clone().into_pyobject(vm) } diff --git a/vm/src/exceptions.rs b/vm/src/exceptions.rs index 4134b262f..8721c8959 100644 --- a/vm/src/exceptions.rs +++ b/vm/src/exceptions.rs @@ -89,7 +89,7 @@ impl PyBaseException { Ok(()) } - #[pyproperty(name = "__traceback__")] + #[pyproperty(magic)] pub fn traceback(&self) -> Option { self.traceback.read().clone() } @@ -99,7 +99,7 @@ impl PyBaseException { *self.traceback.write() = traceback; } - #[pyproperty(name = "__cause__")] + #[pyproperty(magic)] pub fn cause(&self) -> Option { self.cause.read().clone() } @@ -111,7 +111,7 @@ impl PyBaseException { *c = cause; } - #[pyproperty(name = "__context__")] + #[pyproperty(magic)] pub fn context(&self) -> Option { self.context.read().clone() } diff --git a/vm/src/stdlib/hashlib.rs b/vm/src/stdlib/hashlib.rs index 06d3919c1..91be45fd9 100644 --- a/vm/src/stdlib/hashlib.rs +++ b/vm/src/stdlib/hashlib.rs @@ -60,12 +60,12 @@ mod hashlib { .into_object()) } - #[pyproperty(name = "name")] + #[pyproperty] fn name(&self) -> String { self.name.clone() } - #[pyproperty(name = "digest_size")] + #[pyproperty] fn digest_size(&self, vm: &VirtualMachine) -> PyResult { Ok(vm.ctx.new_int(self.read().digest_size())) } diff --git a/vm/src/stdlib/re.rs b/vm/src/stdlib/re.rs index 442f5ed71..b40741f9f 100644 --- a/vm/src/stdlib/re.rs +++ b/vm/src/stdlib/re.rs @@ -332,7 +332,7 @@ impl PyPattern { self.sub(repl, text, vm) } - #[pyproperty(name = "pattern")] + #[pyproperty] fn pattern(&self, vm: &VirtualMachine) -> PyResult { Ok(vm.ctx.new_str(self.pattern.clone())) }