@@ -52,6 +52,10 @@ the Oracle Berkeley DB.
52
52
.. |flag_n | replace ::
53
53
Always create a new, empty database, open for reading and writing.
54
54
55
+ .. |incompat_note | replace ::
56
+ The file formats created by :mod: `dbm.gnu` and :mod:`dbm.ndbm` are incompatible
57
+ and can not be used interchangeably.
58
+
55
59
.. function :: open(file, flag='r', mode=0o666)
56
60
57
61
Open the database file *file * and return a corresponding object.
@@ -157,9 +161,7 @@ functionality like crash tolerance.
157
161
except that keys and values are always converted to :class: `bytes ` before storing,
158
162
and the :meth: `!items ` and :meth: `!values ` methods are not supported.
159
163
160
- .. note ::
161
- The file formats created by :mod: `dbm.gnu ` and :mod: `dbm.ndbm ` are
162
- incompatible and can not be used interchangeably.
164
+ .. note :: |incompat_note|
163
165
164
166
.. exception :: error
165
167
@@ -246,29 +248,32 @@ and the :meth:`!items` and :meth:`!values` methods are not supported.
246
248
247
249
Close the GDBM database.
248
250
249
- :mod: `dbm.ndbm ` --- Interface based on ndbm
250
- -------------------------------------------
251
+
252
+ :mod: `dbm.ndbm ` --- New Database Manager
253
+ ----------------------------------------
251
254
252
255
.. module :: dbm.ndbm
253
256
:platform: Unix
254
- :synopsis: The standard "database" interface, based on ndbm.
257
+ :synopsis: The New Database Manager
255
258
256
259
**Source code: ** :source: `Lib/dbm/ndbm.py `
257
260
258
261
--------------
259
262
260
- The :mod: `dbm.ndbm ` module provides an interface to the Unix "(n)dbm" library.
261
- Dbm objects behave like mappings (dictionaries), except that keys and values are
262
- always stored as bytes. Printing a ``dbm `` object doesn't print the keys and
263
- values, and the :meth: `items ` and :meth: `values ` methods are not supported.
263
+ The :mod: `dbm.ndbm ` module provides an interface to the
264
+ :abbr: `NDBM ( New Database Manager ) ` library.
265
+ :class: `!ndbm ` objects behave similar to :term: `mappings <mapping> `,
266
+ except that keys and values are always stored as :class: `bytes `,
267
+ and the :meth: `!items ` and :meth: `!values ` methods are not supported.
264
268
265
- This module can be used with the "classic" ndbm interface or the GNU GDBM
266
- compatibility interface. On Unix, the :program: `configure ` script will attempt
267
- to locate the appropriate header file to simplify building this module.
269
+ This module can be used with the "classic" NDBM interface or the
270
+ :abbr: `GDBM ( GNU dbm ) ` compatibility interface.
271
+
272
+ .. note :: |incompat_note|
268
273
269
274
.. warning ::
270
275
271
- The ndbm library shipped as part of macOS has an undocumented limitation on the
276
+ The NDBM library shipped as part of macOS has an undocumented limitation on the
272
277
size of values, which can result in corrupted database files
273
278
when storing values larger than this limit. Reading such corrupted files can
274
279
result in a hard crash (segmentation fault).
@@ -281,13 +286,14 @@ to locate the appropriate header file to simplify building this module.
281
286
282
287
.. data :: library
283
288
284
- Name of the `` ndbm `` implementation library used.
289
+ Name of the NDBM implementation library used.
285
290
286
291
287
- .. function :: open(filename[ , flag[ , mode]] )
292
+ .. function :: open(filename, flag="r" , mode=0o666, / )
288
293
289
- Open a dbm database and return a ``ndbm `` object. The *filename * argument is the
290
- name of the database file (without the :file: `.dir ` or :file: `.pag ` extensions).
294
+ Open an NDBM database and return an :class: `!ndbm ` object.
295
+ The *filename * argument is the name of the database file
296
+ (without the :file: `.dir ` or :file: `.pag ` extensions).
291
297
292
298
The optional *flag * argument must be one of these values:
293
299
@@ -303,15 +309,15 @@ to locate the appropriate header file to simplify building this module.
303
309
database has to be created. It defaults to octal ``0o666 `` (and will be
304
310
modified by the prevailing umask).
305
311
306
- In addition to the dictionary-like methods, `` ndbm ` ` objects
312
+ In addition to the dictionary-like methods, :class: ` ! ndbm ` objects
307
313
provide the following method:
308
314
309
315
.. versionchanged :: 3.11
310
316
Accepts :term: `path-like object ` for filename.
311
317
312
318
.. method :: ndbm.close()
313
319
314
- Close the `` ndbm `` database.
320
+ Close the NDBM database.
315
321
316
322
317
323
:mod: `dbm.dumb ` --- Portable DBM implementation
0 commit comments