File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -44,13 +44,18 @@ lots of shared sub-objects. The keys are ordinary strings.
4444
4545 By default, :mod: `shelve ` uses :func: `pickle.dumps ` and :func: `pickle.loads `
4646 for serializing and deserializing. This can be changed by supplying
47- *serializer * and *deserializer *, respectively. The *serializer * argument
48- should be a function that takes an object and the *protocol * argument passed
49- to the open function and returns its representation as a
50- :term: `bytes-like object `; *protocol * argument that may be ignored by the
51- function. *deserializer * should be a function that takes :class: `bytes ` and
52- returns the corresponding object. If one of these is given, the other must
53- be given as well. Otherwise :mod: `shelve ` will raise a :exc: `ShelveError `.
47+ *serializer * and *deserializer *, respectively.
48+
49+ The *serializer * argument must be a callable which takes an object ``obj ``
50+ and the *protocol * as inputs and returns the representation ``obj `` as a
51+ :term: `bytes-like object `; the *protocol * value may be ignored by the
52+ serializer.
53+
54+ The *deserializer * argument must be callable which takes a serialized object
55+ given as a :class: `bytes ` object and returns the corresponding object.
56+
57+ A :exc: `ShelveError ` is raised if *serializer * is given but *deserializer *
58+ is not, or vice-versa.
5459
5560 .. versionchanged :: 3.10
5661 :const: `pickle.DEFAULT_PROTOCOL ` is now used as the default pickle
You can’t perform that action at this time.
0 commit comments