diff -r 997ab4f1530f Lib/test/test_funcattrs.py --- a/Lib/test/test_funcattrs.py Wed Oct 24 23:06:25 2012 +0300 +++ b/Lib/test/test_funcattrs.py Tue Oct 30 23:53:58 2012 +0100 @@ -1,6 +1,8 @@ from test import support import types import unittest +import subprocess +import sys class FuncAttrsTest(unittest.TestCase): def setUp(self): @@ -302,6 +304,14 @@ self.assertTrue(cell(-36) == cell(-36.0)) self.assertTrue(cell(True) > empty_cell()) + def test_cell_methods(self): + # Issue16268: In a new interpreter, a cell object seems to not + # inherit methods from the base object type. + p = subprocess.Popen([sys.executable, "-c", + 'def f(x): return lambda: x\n' + 'format(f(1).__closure__[0])']) + self.assertEqual(p.wait(), 0) + class StaticMethodAttrsTest(unittest.TestCase): def test_func_attribute(self): diff -r 997ab4f1530f Objects/object.c --- a/Objects/object.c Wed Oct 24 23:06:25 2012 +0300 +++ b/Objects/object.c Tue Oct 30 23:53:58 2012 +0100 @@ -1618,6 +1618,9 @@ if (PyType_Ready(&PyDictProxy_Type) < 0) Py_FatalError("Can't initialize dict proxy type"); + if (PyType_Ready(&PyCell_Type) < 0) + Py_FatalError("Can't initialize cell type"); + if (PyType_Ready(&PyGen_Type) < 0) Py_FatalError("Can't initialize generator type");