Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b0b3919

Browse files
authored
Fix cell_contents (#5822)
1 parent b1ecdf3 commit b0b3919

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

Lib/test/test_funcattrs.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,6 @@ def f(): print(a)
140140
self.fail("shouldn't be able to read an empty cell")
141141
a = 12
142142

143-
# TODO: RUSTPYTHON
144-
@unittest.expectedFailure
145143
def test_set_cell(self):
146144
a = 12
147145
def f(): return a

vm/src/builtins/function.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -759,8 +759,11 @@ impl PyCell {
759759
.ok_or_else(|| vm.new_value_error("Cell is empty".to_owned()))
760760
}
761761
#[pygetset(setter)]
762-
fn set_cell_contents(&self, x: PyObjectRef) {
763-
self.set(Some(x))
762+
fn set_cell_contents(&self, x: PySetterValue) {
763+
match x {
764+
PySetterValue::Assign(value) => self.set(Some(value)),
765+
PySetterValue::Delete => self.set(None),
766+
}
764767
}
765768
}
766769

0 commit comments

Comments
 (0)