This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author r.david.murray
Recipients docs@python, krichter, r.david.murray
Date 2015-01-06.08:22:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1420532578.74.0.0816548372148.issue23174@psf.upfronthosting.co.za>
In-reply-to
Content
The problem is that this is not the only situation in which that error can be generated.  If someone passed in an "old" (and possibly non-empty) file with no extension, the same code path would get executed.

The shelve/anydbm API is database agnostic, so there is no way to know a-priori what the valid extensions are.  The whichdbm module (which anydbm uses) could provide this information in theory, but it doesn't currently, and if it did that would be a new API.

Your problem is that the shelve API is designed so that you either pass it the base name of an existing database, *or* you pass it the base name of a *non* existent database, which it then creates all the right files for (there may be more than one file).  The fact that you are passing it a new existing file is the problem, and I'm not sure the error message can be effectively improved to handle that particular mistaken use of the API without breaking the message for the places it is more meaningful.

The best I can think of is to add the filename to the error message and list all the extensions and (if there are any) the 'magic' type guesses that whichdbm tried, but as I said that would be a new feature and thus could only go into 3.5.
History
Date User Action Args
2015-01-06 08:22:58r.david.murraysetrecipients: + r.david.murray, docs@python, krichter
2015-01-06 08:22:58r.david.murraysetmessageid: <1420532578.74.0.0816548372148.issue23174@psf.upfronthosting.co.za>
2015-01-06 08:22:58r.david.murraylinkissue23174 messages
2015-01-06 08:22:58r.david.murraycreate