Skip to content

Commit 06c5de3

Browse files
Docs: reword dbm.gnu introduction (#114548)
Also... - consistently spell GDBM as GDBM - silence gdbm class refs - improve accuracy of dbm.gdbm.open() spec
1 parent 01d970c commit 06c5de3

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

Doc/library/dbm.rst

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -137,37 +137,38 @@ then prints out the contents of the database::
137137
The individual submodules are described in the following sections.
138138

139139

140-
:mod:`dbm.gnu` --- GNU's reinterpretation of dbm
141-
------------------------------------------------
140+
:mod:`dbm.gnu` --- GNU database manager
141+
---------------------------------------
142142

143143
.. module:: dbm.gnu
144144
:platform: Unix
145-
:synopsis: GNU's reinterpretation of dbm.
145+
:synopsis: GNU database manager
146146

147147
**Source code:** :source:`Lib/dbm/gnu.py`
148148

149149
--------------
150150

151-
This module is quite similar to the :mod:`dbm` module, but uses the GNU library
152-
``gdbm`` instead to provide some additional functionality. Please note that the
153-
file formats created by :mod:`dbm.gnu` and :mod:`dbm.ndbm` are incompatible.
151+
The :mod:`dbm.gnu` module provides an interface to the :abbr:`GDBM (GNU dbm)`
152+
library, similar to the :mod:`dbm.ndbm` module, but with additional
153+
functionality like crash tolerance.
154154

155-
The :mod:`dbm.gnu` module provides an interface to the GNU DBM library.
156-
``dbm.gnu.gdbm`` objects behave like mappings (dictionaries), except that keys and
157-
values are always converted to bytes before storing. Printing a ``gdbm``
158-
object doesn't print the
159-
keys and values, and the :meth:`items` and :meth:`values` methods are not
160-
supported.
155+
:class:`!gdbm` objects behave similar to :term:`mappings <mapping>`,
156+
except that keys and values are always converted to :class:`bytes` before storing,
157+
and the :meth:`!items` and :meth:`!values` methods are not supported.
158+
159+
.. note::
160+
The file formats created by :mod:`dbm.gnu` and :mod:`dbm.ndbm` are
161+
incompatible and can not be used interchangeably.
161162

162163
.. exception:: error
163164

164165
Raised on :mod:`dbm.gnu`-specific errors, such as I/O errors. :exc:`KeyError` is
165166
raised for general mapping errors like specifying an incorrect key.
166167

167168

168-
.. function:: open(filename[, flag[, mode]])
169+
.. function:: open(filename, flag="r", mode=0o666, /)
169170

170-
Open a ``gdbm`` database and return a :class:`gdbm` object. The *filename*
171+
Open a GDBM database and return a :class:`!gdbm` object. The *filename*
171172
argument is the name of the database file.
172173

173174
The optional *flag* argument can be:
@@ -196,14 +197,14 @@ supported.
196197
| ``'u'`` | Do not lock database. |
197198
+---------+--------------------------------------------+
198199

199-
Not all flags are valid for all versions of ``gdbm``. The module constant
200+
Not all flags are valid for all versions of GDBM. The module constant
200201
:const:`open_flags` is a string of supported flag characters. The exception
201202
:exc:`error` is raised if an invalid flag is specified.
202203

203204
The optional *mode* argument is the Unix mode of the file, used only when the
204205
database has to be created. It defaults to octal ``0o666``.
205206

206-
In addition to the dictionary-like methods, ``gdbm`` objects have the
207+
In addition to the dictionary-like methods, :class:`gdbm` objects have the
207208
following methods:
208209

209210
.. versionchanged:: 3.11
@@ -212,7 +213,7 @@ supported.
212213
.. method:: gdbm.firstkey()
213214

214215
It's possible to loop over every key in the database using this method and the
215-
:meth:`nextkey` method. The traversal is ordered by ``gdbm``'s internal
216+
:meth:`nextkey` method. The traversal is ordered by GDBM's internal
216217
hash values, and won't be sorted by the key values. This method returns
217218
the starting key.
218219

@@ -230,7 +231,7 @@ supported.
230231
.. method:: gdbm.reorganize()
231232

232233
If you have carried out a lot of deletions and would like to shrink the space
233-
used by the ``gdbm`` file, this routine will reorganize the database. ``gdbm``
234+
used by the GDBM file, this routine will reorganize the database. :class:`!gdbm`
234235
objects will not shorten the length of a database file except by using this
235236
reorganization; otherwise, deleted file space will be kept and reused as new
236237
(key, value) pairs are added.
@@ -242,11 +243,11 @@ supported.
242243

243244
.. method:: gdbm.close()
244245

245-
Close the ``gdbm`` database.
246+
Close the GDBM database.
246247

247248
.. method:: gdbm.clear()
248249

249-
Remove all items from the ``gdbm`` database.
250+
Remove all items from the GDBM database.
250251

251252
.. versionadded:: 3.13
252253

0 commit comments

Comments
 (0)