@@ -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
@@ -253,29 +255,31 @@ and the :meth:`!items` and :meth:`!values` methods are not supported.
253
255
.. versionadded :: 3.13
254
256
255
257
256
- :mod: `dbm.ndbm ` --- Interface based on ndbm
257
- -------------------------------------------
258
+ :mod: `dbm.ndbm ` --- New Database Manager
259
+ ----------------------------------------
258
260
259
261
.. module :: dbm.ndbm
260
262
:platform: Unix
261
- :synopsis: The standard "database" interface, based on ndbm.
263
+ :synopsis: The New Database Manager
262
264
263
265
**Source code: ** :source: `Lib/dbm/ndbm.py `
264
266
265
267
--------------
266
268
267
- The :mod: `dbm.ndbm ` module provides an interface to the Unix "(n)dbm" library.
268
- Dbm objects behave like mappings (dictionaries), except that keys and values are
269
- always stored as bytes. Printing a ``dbm `` object doesn't print the keys and
270
- values, and the :meth: `items ` and :meth: `values ` methods are not supported.
269
+ The :mod: `dbm.ndbm ` module provides an interface to the
270
+ :abbr: `NDBM ( New Database Manager ) ` library.
271
+ :class: `!ndbm ` objects behave similar to :term: `mappings <mapping> `,
272
+ except that keys and values are always stored as :class: `bytes `,
273
+ and the :meth: `!items ` and :meth: `!values ` methods are not supported.
274
+
275
+ This module can be used with the "classic" NDBM interface or the
276
+ :abbr: `GDBM ( GNU dbm ) ` compatibility interface.
271
277
272
- This module can be used with the "classic" ndbm interface or the GNU GDBM
273
- compatibility interface. On Unix, the :program: `configure ` script will attempt
274
- to locate the appropriate header file to simplify building this module.
278
+ .. note :: |incompat_note|
275
279
276
280
.. warning ::
277
281
278
- The ndbm library shipped as part of macOS has an undocumented limitation on the
282
+ The NDBM library shipped as part of macOS has an undocumented limitation on the
279
283
size of values, which can result in corrupted database files
280
284
when storing values larger than this limit. Reading such corrupted files can
281
285
result in a hard crash (segmentation fault).
@@ -288,13 +292,14 @@ to locate the appropriate header file to simplify building this module.
288
292
289
293
.. data :: library
290
294
291
- Name of the `` ndbm `` implementation library used.
295
+ Name of the NDBM implementation library used.
292
296
293
297
294
- .. function :: open(filename[ , flag[ , mode]] )
298
+ .. function :: open(filename, flag="r" , mode=0o666, / )
295
299
296
- Open a dbm database and return a ``ndbm `` object. The *filename * argument is the
297
- name of the database file (without the :file: `.dir ` or :file: `.pag ` extensions).
300
+ 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).
298
303
299
304
The optional *flag * argument must be one of these values:
300
305
@@ -310,19 +315,19 @@ to locate the appropriate header file to simplify building this module.
310
315
database has to be created. It defaults to octal ``0o666 `` (and will be
311
316
modified by the prevailing umask).
312
317
313
- In addition to the dictionary-like methods, `` ndbm ` ` objects
318
+ In addition to the dictionary-like methods, :class: ` ! ndbm ` objects
314
319
provide the following method:
315
320
316
321
.. versionchanged :: 3.11
317
322
Accepts :term: `path-like object ` for filename.
318
323
319
324
.. method :: ndbm.close()
320
325
321
- Close the `` ndbm `` database.
326
+ Close the NDBM database.
322
327
323
328
.. method :: ndbm.clear()
324
329
325
- Remove all items from the `` ndbm `` database.
330
+ Remove all items from the NDBM database.
326
331
327
332
.. versionadded :: 3.13
328
333
0 commit comments