mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
Make property.__get__ owner parameter optional
This commit is contained in:
1 parent
a5f6a7b10d
commit
4ad8d5ed9b
2 files changed
+13
-4
No files matched your search
@@ -51,8 +51,7 @@ assert type(null_property) is property
|
||||
|
||||
p = property(lambda x: x[0])
|
||||
assert p.__get__((2,), tuple) == 2
|
||||
# TODO owner parameter is optional
|
||||
# assert p.__get__((2,)) == 2
|
||||
assert p.__get__((2,)) == 2
|
||||
|
||||
with assertRaises(AttributeError):
|
||||
null_property.__get__((), tuple)
|
||||
|
||||
@@ -24,7 +24,12 @@ impl PyValue for PyReadOnlyProperty {
|
||||
pub type PyReadOnlyPropertyRef = PyRef<PyReadOnlyProperty>;
|
||||
|
||||
impl PyReadOnlyPropertyRef {
|
||||
fn get(self, obj: PyObjectRef, _owner: PyClassRef, vm: &mut VirtualMachine) -> PyResult {
|
||||
fn get(
|
||||
self,
|
||||
obj: PyObjectRef,
|
||||
_owner: OptionalArg<PyClassRef>,
|
||||
vm: &mut VirtualMachine,
|
||||
) -> PyResult {
|
||||
if obj.is(&vm.ctx.none) {
|
||||
Ok(self.into_object())
|
||||
} else {
|
||||
@@ -81,7 +86,12 @@ impl PyPropertyRef {
|
||||
}
|
||||
}
|
||||
|
||||
fn get(self, obj: PyObjectRef, _owner: PyClassRef, vm: &mut VirtualMachine) -> PyResult {
|
||||
fn get(
|
||||
self,
|
||||
obj: PyObjectRef,
|
||||
_owner: OptionalArg<PyClassRef>,
|
||||
vm: &mut VirtualMachine,
|
||||
) -> PyResult {
|
||||
if let Some(getter) = self.getter.as_ref() {
|
||||
if obj.is(&vm.ctx.none) {
|
||||
Ok(self.into_object())
|
||||
|
||||
Reference in new issue
Block a user