Commit 23ca12a9 authored by Raymond Hettinger's avatar Raymond Hettinger

Inline the advisory text on how to use the shelve module.

parent ce7554f0
...@@ -44,17 +44,12 @@ lots of shared sub-objects. The keys are ordinary strings. ...@@ -44,17 +44,12 @@ lots of shared sub-objects. The keys are ordinary strings.
determine which accessed entries are mutable, nor which ones were actually determine which accessed entries are mutable, nor which ones were actually
mutated). mutated).
.. note:: Like file objects, shelve objects should closed explicitly to assure
that the peristent data is flushed to disk.
Do not rely on the shelf being closed automatically; always call Since the :mod:`shelve` module stores objects using :mod:`pickle`, the same
:meth:`close` explicitly when you don't need it any more, or use a security precautions apply. Accordingly, you should avoid loading a shelf
:keyword:`with` statement with :func:`contextlib.closing`. from an untrusted source.
.. warning::
Because the :mod:`shelve` module is backed by :mod:`pickle`, it is insecure
to load a shelf from an untrusted source. Like with pickle, loading a shelf
can execute arbitrary code.
Shelf objects support all methods supported by dictionaries. This eases the Shelf objects support all methods supported by dictionaries. This eases the
transition from dictionary based scripts to those requiring persistent storage. transition from dictionary based scripts to those requiring persistent storage.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment