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
Deprecate nonstandard behavior of a dumbdbm database #65907
Comments
Unlike to other dbm implementations, a dumpdbm database is always opened for update, and will be created if it does not exist. We can fix this discrepancy and implement common behavior for 'r' and 'w' modes, but this will change current behavior and some deprecation period is needed. Here is a patch (based on patch by Claudiu Popa, submitted in bpo-18039), which adds deprecation warnings for cases when current behavior differs from desired: invalid values for the flag parameter (will raise ValueError in future), opening non-existing database in 'r' or 'w' mode (will raise dbm.dumb.error), modifying a database opened for reading only (will raise dbm.dumb.error). This patch needs approving by other core developer. |
The core idea is reasonable. The patch overreaches by adding readonly warnings to __setitem__ and __delitem__ which will spew-out on every call (these could be ignored or set to warn once by the user but that is PITA). Minor nit. We have a little PEP-8 overkill on the string splits: + with self.assertWarnsRegex(DeprecationWarning, |
Thanks Raymond for your attention. Readonly warnings are emitted only when dumpdbm database opened in read only mode. They will be turned into exceptions in future (3.6 or 3.7). Annoying warnings on changed in future operations is desirable effect. If you worry about performance hit of such checks, __setitem__ and __delitem__ are expensive operations doing file I/O. |
I'm not worries about the performance. I think the warnings and checks don't need to be there are all (API creep). AFAICT, this has never been requested or needed in the entire history of the dumbdbm. Your original goal of changing the default update mode is worthwhile. |
The point is to make the API consistent. So if the other dbm modules raise an error when __setitem__/delitem are called on an R/O db, then the warnings are appropriate (but should mention that this will be an error in the future). The warnings will only be printed once per run of python, unless I'm completely misremembering how deprecation warnings work. |
Feel free to ignore my advice and make unnecessary changes to a very old, stable API. |
Warnings are not raised by default. They are raised only when the database is opened with the 'r' mode and then modified. The earlier we start deprecation period, the earlier we could add true "read-only" and "update existing" modes to dbm.dumb. |
Patch updated. Added What's New entry. We already lost 2 years and the 3.5 release. I don't want to lost 3.6 too. |
New changeset 62da75b29b29 by Serhiy Storchaka in branch 'default': |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: