Index: Doc/library/shelve.rst =================================================================== --- Doc/library/shelve.rst (revision 74875) +++ Doc/library/shelve.rst (working copy) @@ -30,9 +30,9 @@ Because of Python semantics, a shelf cannot know when a mutable persistent-dictionary entry is modified. By default modified objects are - written only when assigned to the shelf (see :ref:`shelve-example`). If + written *only* when assigned to the shelf (see :ref:`shelve-example`). If the optional *writeback* parameter is set to *True*, all entries accessed - are cached in memory, and written back at close time; this can make it + are also cached in memory, and written back at close time; this can make it handier to mutate mutable entries in the persistent dictionary, but, if many entries are accessed, it can consume vast amounts of memory for the cache, and it can make the close operation very slow since all accessed Index: Lib/test/test_shelve.py =================================================================== --- Lib/test/test_shelve.py (revision 74875) +++ Lib/test/test_shelve.py (working copy) @@ -88,7 +88,21 @@ self.assertEqual(len(d1), 1) self.assertEqual(len(d2), 1) + def test_issue5754(self): + d = {} + s = shelve.Shelf(d, writeback=True) + s['key'] = [1] + try: + p1 = d['key'] + except KeyError: + self.fail( + "Shelf should update immediately even with writeback=True") + s['key'].append(2) + s.close() + p2 = d['key'] + self.assertNotEqual(p1, p2, "Shelf should update on .close()") + from test import mapping_tests class TestShelveBase(mapping_tests.BasicTestMappingProtocol):