mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-35911: add cell constructor (GH-11771)
Add a cell constructor, expose the cell type in the types module.
This commit is contained in:
parent
f289084c83
commit
df8d2cde63
6 changed files with 71 additions and 2 deletions
|
@ -83,6 +83,15 @@ class FunctionPropertiesTest(FuncAttrsTest):
|
|||
self.assertEqual(c[0].__class__.__name__, "cell")
|
||||
self.cannot_set_attr(f, "__closure__", c, AttributeError)
|
||||
|
||||
def test_cell_new(self):
|
||||
cell_obj = types.CellType(1)
|
||||
self.assertEqual(cell_obj.cell_contents, 1)
|
||||
|
||||
cell_obj = types.CellType()
|
||||
msg = "shouldn't be able to read an empty cell"
|
||||
with self.assertRaises(ValueError, msg=msg):
|
||||
cell_obj.cell_contents
|
||||
|
||||
def test_empty_cell(self):
|
||||
def f(): print(a)
|
||||
try:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue