Skip to content

Commit 6d97937

Browse files
committed
Clarify encoding behavior in dbm module documentation
1 parent 539a4ca commit 6d97937

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Doc/library/dbm.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,13 @@ The :meth:`!keys` method returns a list instead of a view object.
9999
The :meth:`!setdefault` method requires two arguments.
100100

101101
Key and values are always stored as :class:`bytes`. This means that when
102-
strings are used they are implicitly converted to the default encoding before
103-
being stored.
102+
strings are used they are implicitly converted to bytes before being stored.
103+
The specific encoding used for this conversion is backend-dependent and may
104+
vary between different dbm implementations and systems. The encoding choice
105+
is determined by the underlying database implementation. For consistent
106+
behavior across different backends and to maintain control over the encoding
107+
process, it is strongly recommended to explicitly convert strings to bytes
108+
using a specific encoding before storing them.
104109

105110
These objects also support being used in a :keyword:`with` statement, which
106111
will automatically close them when done.

0 commit comments

Comments
 (0)