Bugs item #1212223, was opened at 2005-05-31 19:32 Message generated for change (Settings changed) made by jafo You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1212223&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Library Group: None >Status: Closed >Resolution: Wont Fix Priority: 5 Submitted By: Jack Moffitt (jackiem) Assigned to: Nobody/Anonymous (nobody) Summary: anydbm and 'n' flag Initial Comment: When a 0 length file exists and anydbm is asked to create a new database with that file name via the anydbm.open(fn, 'n') call, the call fails as whichdb detection fails. whichdb should not be invoked with the 'n' flag, since the purpose of this flag is to always create a database, not only if it is missing. This bug prevents creating a secure temporary file with mkstemp and then uisng that file to open a database. The workaround is to unlink the file then call open, but this is leaving a small hole. ---------------------------------------------------------------------- >Comment By: Sean Reifschneider (jafo) Date: 2005-06-01 03:00 Message: Logged In: YES user_id=81797 I'm torn as to what should happen here. In the documentation, it says that in the event that the file exists, the whichdb module will be used to determine the type of the database. In the case of an unrecognised database format, that function returns the empty string, and anydbm raises that as an exception. On the other hand, the documentation says that if "n" is passed a new database will always be created, which in this case it definitely is not. I'd be reluctant to change anydbm.open(), since the reason for anydbm to exist is that it determines the database type of an existing file, and in the case that it doesn't understand the database type it says so. One could imagine a "textdb" type being added later where an empty file would be a valid, empty, textdb file, but a change to anydbm here could lead to problems in the future. The real solution, I would propose, is that in the event that you're trying to create a temporary database, call mkstemp, then call "anydbm._defaultmod.open" on the resulting file name, for example. Call the module directly instead of relying on anydbm. I'm inclined to close this as Wont Fix, please re-open if you think the assessment is wrong. Sean ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1212223&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com