-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
dbm.open(..., flag="n") does not work and does not give a warning #62239
Comments
I use Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:03:43) [MSC v.1600 32 bit (Intel)] on win32. dbm.open(..., flag="n") is supposed to "Always create a new, empty database, open for reading and writing". http://docs.python.org/3/library/dbm.html#module-dbm.dumb If it is ignored, there should be at least a warning. How am I supposed to now that this is a known bug? |
I can't reproduce it on Windows 7 with Python 3.3.2. Attaching my test script. Here's the output: C:\Python33>python.exe -V C:\Python33>python.exe dbmopen.py Could you run it and paste here the output? |
Here is the output. *** Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:03:43) [MSC v.1600 32 bit (Intel)] on win32. ***
*** Remote Python engine is active ***
>>>
*** Remote Interpreter Reinitialized ***
>>>
<dbm.dumb._Database object at 0x02B95210>
yoqaA.dat exists? True
yoqaA.dir exists? True
b'hello' b'there'
>>> I would like to focus your attention, that flag "n" creates a database, but does not overwrite it once it is created. So in Windows case there is no difference between "c" and "n" flag. |
Here's a patch which adds support for the My output (after a couple of runs): D:\Projects\snippets\DBM>py -3 a.py u7 |
And the patch. |
Can anyone review this patch? |
Serhiy, could you please have a look at this patch? Given the fact that you committed my last dbm patch, I hope you have a couple of minutes to have a look at this one as well. |
With this patch 2 of 4 modes ('c' and 'n') work as for other dbm modules. So it would be better to document that 'r' and 'w' work nonstandard, than document that 'n' is not ignored. And while you are here, may be add a warning in 'r' and 'w' mode when the file does not exist? |
Thanks, Serhiy. Here's the new version of the patch. Hope that the warning message is clear enough. |
Thanks for the reviews, Serhiy. Here's the new version of the patch. |
New changeset 3f944f44ee41 by Serhiy Storchaka in branch 'default': |
Isn't this change going to cause unexpected data loss for (possibly mythical) people depending on the existing behavior? At an absolute minimum it needs an entry in the What's New porting section, but I'm wondering if a deprecation period is more appropriate. |
I think the chance of this is pretty small. I can imagine that some people use default, 'r' or 'w' mode unintentionally, and all works for them even when database is missed (for example our tests do this). But it is very unlikely that someone use the 'n' mode and expect that database will be not cleaned. |
Yeah, hopefully you are right. (I didn't mean to reopen the issue, by the way). |
with
in test and minor doc fixesNote: 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: