Skip to content

gh-77566: Clarify setdefault() behavior for dbm objects #137911

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

furkanonder
Copy link
Contributor

@furkanonder furkanonder commented Aug 18, 2025

@furkanonder
Copy link
Contributor Author

Perhaps we could use dbm.error instead of dbm.sqlite3.error and _dbm.error for consistency and clarity.

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only methods which are not common for all mappings are documented. I do not think that it is worth to document setdefault().

On other hand, not all mapping methods are implemented, and not all missing methods are mentioned.

@@ -95,6 +95,10 @@ The object returned by :func:`~dbm.open` supports the same basic functionality a
deleted, and the :keyword:`in` operator and the :meth:`!keys` method are
available, as well as :meth:`!get` and :meth:`!setdefault` methods.

.. note::
Unlike the standard :class:`dict` type, the :meth:`dict.setdefault` method
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is self-contradictory. You need to refer to :meth:`!setdefault` instead of :meth:`dict.setdefault` .

Also, I suggest to refer to :term:`mapping` instead of :class:`dict` above.

@@ -204,6 +208,14 @@ or any other SQLite browser, including the SQLite CLI.

.. versionadded:: next

.. method:: sqlite3.setdefault(key, default)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No other methods are documented here, except reorganize(). Even close() is barely mentioned.

@serhiy-storchaka
Copy link
Member

Many other documentation changes are needed. So I created other PR for them, and the setdefault notes are a small part of it.

@serhiy-storchaka
Copy link
Member

See #137919.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting review docs Documentation in the Doc dir needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes skip news stdlib Python modules in the Lib dir
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

2 participants