R. David Murray added the comment:

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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue23174>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to