Issue #1445: Fix a SystemError when accessing the ``cell_contents``
attribute of an empty cell object. Now a ValueError is raised.
diff --git a/Lib/test/test_funcattrs.py b/Lib/test/test_funcattrs.py
index 7a083b7..a32be38 100644
--- a/Lib/test/test_funcattrs.py
+++ b/Lib/test/test_funcattrs.py
@@ -242,6 +242,17 @@
verify(c[0].__class__.__name__ == "cell") # don't have a type object handy
cantset(f, "func_closure", c)
+def test_empty_cell():
+ def f(): print a
+ try:
+ f.func_closure[0].cell_contents
+ except ValueError:
+ pass
+ else:
+ raise TestFailed, "shouldn't be able to read an empty cell"
+
+ a = 12
+
def test_func_doc():
def f(): pass
verify(f.__doc__ is None)
@@ -385,6 +396,7 @@
def testmore():
test_func_closure()
+ test_empty_cell()
test_func_doc()
test_func_globals()
test_func_name()