Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions crates/vm/src/builtins/property.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*! Python `property` descriptor class.

*/
use super::{PyStrRef, PyType};
use super::PyType;
use crate::common::lock::PyRwLock;
use crate::function::{IntoFuncArgs, PosArgs};
use crate::{
Expand Down Expand Up @@ -41,8 +41,6 @@ pub struct PropertyArgs {
fdel: Option<PyObjectRef>,
#[pyarg(any, default)]
doc: Option<PyObjectRef>,
#[pyarg(any, default)]
name: Option<PyStrRef>,
}

impl GetDescriptor for PyProperty {
Expand Down Expand Up @@ -221,7 +219,6 @@ impl PyProperty {
fset: new_setter.or_else(|| zelf.fset()),
fdel: new_deleter.or_else(|| zelf.fdel()),
doc,
name: None,
};

// Create new property using py_new and init
Expand Down Expand Up @@ -401,7 +398,6 @@ impl Initializer for PyProperty {
*zelf.getter.write() = args.fget;
*zelf.setter.write() = args.fset;
*zelf.deleter.write() = args.fdel;
*zelf.name.write() = args.name.map(|a| a.as_object().to_owned());
zelf.getter_doc.store(getter_doc, Ordering::Relaxed);

Ok(())
Expand Down
7 changes: 7 additions & 0 deletions extra_tests/snippets/builtin_property.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,10 @@ def foo(self):

p2 = property("a", doc="pdoc")
# assert p2.__doc__ == 'pdoc'


# property() takes at most four arguments, and `name` is not one of them:
# the name slot is filled by __set_name__ and the __name__ setter instead.
assert_raises(TypeError, property, None, None, None, None, None)
assert_raises(TypeError, property, "a", "b", "c", "d", "e")
assert_raises(TypeError, property, name="x")
Loading