@@ -52,6 +52,10 @@ the Oracle Berkeley DB.
5252.. |flag_n | replace ::
5353 Always create a new, empty database, open for reading and writing.
5454
55+ .. |mode_param_doc | replace ::
56+ The Unix file access mode of the file (default: octal ``0o666``),
57+ used only when the database has to be created.
58+
5559.. |incompat_note | replace ::
5660 The file formats created by :mod: `dbm.gnu` and :mod:`dbm.ndbm` are incompatible
5761 and can not be used interchangeably.
@@ -69,14 +73,13 @@ the Oracle Berkeley DB.
6973 :type file: :term: `path-like object `
7074
7175 :param str flag:
72- * ``'r' `` (default), |flag_r |
73- * ``'w' ``, |flag_w |
74- * ``'c' ``, |flag_c |
75- * ``'n' ``, |flag_n |
76+ * ``'r' `` (default): |flag_r |
77+ * ``'w' ``: |flag_w |
78+ * ``'c' ``: |flag_c |
79+ * ``'n' ``: |flag_n |
7680
7781 :param int mode:
78- The Unix file access mode of the file (default: octal ``0o666 ``),
79- used only when the database has to be created.
82+ |mode_param_doc |
8083
8184 .. versionchanged :: 3.11
8285 *file * accepts a :term: `path-like object `.
@@ -171,47 +174,45 @@ and the :meth:`!items` and :meth:`!values` methods are not supported.
171174
172175.. function :: open(filename, flag="r", mode=0o666, /)
173176
174- Open a GDBM database and return a :class: `!gdbm ` object. The *filename *
175- argument is the name of the database file.
176-
177- The optional *flag * argument can be:
177+ Open a GDBM database and return a :class: `!gdbm ` object.
178178
179- .. csv-table ::
180- :header: "Value", "Meaning"
179+ :param filename:
180+ The database file to open.
181+ :type filename: :term: `path-like object `
181182
182- ``'r' `` (default), |flag_r |
183- ``'w' ``, |flag_w |
184- ``'c' ``, |flag_c |
185- ``'n' ``, |flag_n |
183+ :param str flag:
184+ * ``'r' `` (default): |flag_r |
185+ * ``'w' ``: |flag_w |
186+ * ``'c' ``: |flag_c |
187+ * ``'n' ``: |flag_n |
186188
187- The following additional characters may be appended to the flag to control
188- how the database is opened:
189+ The following additional characters may be appended
190+ to control how the database is opened:
189191
190- +---------+--------------------------------------------+
191- | Value | Meaning |
192- +=========+============================================+
193- | ``'f' `` | Open the database in fast mode. Writes |
194- | | to the database will not be synchronized. |
195- +---------+--------------------------------------------+
196- | ``'s' `` | Synchronized mode. This will cause changes |
197- | | to the database to be immediately written |
198- | | to the file. |
199- +---------+--------------------------------------------+
200- | ``'u' `` | Do not lock database. |
201- +---------+--------------------------------------------+
192+ * ``'f' ``: Open the database in fast mode.
193+ Writes to the database will not be synchronized.
194+ * ``'s' ``: Synchronized mode.
195+ Changes to the database will be written immediately to the file.
196+ * ``'u' ``: Do not lock database.
202197
203- Not all flags are valid for all versions of GDBM. The module constant
204- :const: `open_flags ` is a string of supported flag characters. The exception
205- :exc: `error ` is raised if an invalid flag is specified.
198+ Not all flags are valid for all versions of GDBM.
199+ See the :data: `open_flags ` member for a list of supported flag characters.
206200
207- The optional * mode * argument is the Unix mode of the file, used only when the
208- database has to be created. It defaults to octal `` 0o666 ``.
201+ :param int mode:
202+ | mode_param_doc |
209203
210- In addition to the dictionary-like methods, :class: ` gdbm ` objects have the
211- following methods:
204+ :raises error:
205+ If an invalid * flag * argument is passed.
212206
213207 .. versionchanged :: 3.11
214- Accepts :term: `path-like object ` for filename.
208+ *filename * accepts a :term: `path-like object `.
209+
210+ .. data :: open_flags
211+
212+ A string of characters the *flag * parameter of :meth: `~dbm.gnu.open ` supports.
213+
214+ In addition to the dictionary-like methods, :class: `gdbm ` objects have the
215+ following methods and attributes:
215216
216217 .. method :: gdbm.firstkey()
217218
@@ -298,22 +299,20 @@ This module can be used with the "classic" NDBM interface or the
298299.. function :: open(filename, flag="r", mode=0o666, /)
299300
300301 Open an NDBM database and return an :class: `!ndbm ` object.
301- The *filename * argument is the name of the database file
302- (without the :file: `.dir ` or :file: `.pag ` extensions).
303-
304- The optional *flag * argument must be one of these values:
305302
306- .. csv-table ::
307- :header: "Value", "Meaning"
303+ :param filename:
304+ The basename of the database file
305+ (without the :file: `.dir ` or :file: `.pag ` extensions).
306+ :type filename: :term: `path-like object `
308307
309- ``'r' `` (default), |flag_r |
310- ``'w' ``, |flag_w |
311- ``'c' ``, |flag_c |
312- ``'n' ``, |flag_n |
308+ :param str flag:
309+ * ``'r' `` (default): |flag_r |
310+ * ``'w' ``: |flag_w |
311+ * ``'c' ``: |flag_c |
312+ * ``'n' ``: |flag_n |
313313
314- The optional *mode * argument is the Unix mode of the file, used only when the
315- database has to be created. It defaults to octal ``0o666 `` (and will be
316- modified by the prevailing umask).
314+ :param int mode:
315+ |mode_param_doc |
317316
318317 In addition to the dictionary-like methods, :class: `!ndbm ` objects
319318 provide the following method:
@@ -382,25 +381,21 @@ The :mod:`!dbm.dumb` module defines the following:
382381 :type database: :term: `path-like object `
383382
384383 :param str flag:
385- .. csv-table ::
386- :header: "Value", "Meaning"
387-
388- ``'r' ``, |flag_r |
389- ``'w' ``, |flag_w |
390- ``'c' `` (default), |flag_c |
391- ``'n' ``, |flag_n |
384+ * ``'r' ``: |flag_r |
385+ * ``'w' ``: |flag_w |
386+ * ``'c' `` (default): |flag_c |
387+ * ``'n' ``: |flag_n |
392388
393389 :param int mode:
394- The Unix file access mode of the file (default: ``0o666 ``),
395- used only when the database has to be created.
390+ |mode_param_doc |
396391
397392 .. warning ::
398393 It is possible to crash the Python interpreter when loading a database
399394 with a sufficiently large/complex entry due to stack depth limitations in
400395 Python's AST compiler.
401396
402397 .. versionchanged :: 3.5
403- :func: `open ` always creates a new database when *flag * is ``'n' ``.
398+ :func: `~dbm.dumb. open ` always creates a new database when *flag * is ``'n' ``.
404399
405400 .. versionchanged :: 3.8
406401 A database opened read-only if *flag * is ``'r' ``.
0 commit comments