classification
Title: shelve.open of temporary file fails with error "anydbm.error: db type could not be determined"
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.7, Python 3.6, Python 3.3, Python 3.4, Python 3.5, Python 2.7
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: Stephen Larroque, r.david.murray
Priority: normal Keywords:

Created on 2017-08-05 16:26 by Stephen Larroque, last changed 2017-08-06 13:02 by r.david.murray. This issue is now closed.

Messages (3)
msg299790 - (view) Author: Stephen Larroque (Stephen Larroque) Date: 2017-08-05 16:26
This is a followup of issue 23174.

When using `shelve.open(tempfile.mkstemp()[1])`, the shelve (or anydbm or dumbdbm) fail with "anydbm.error: db type could not be determined".

Instead, the module could detect the file is empty and use it as if it were not existing before ('c' or 'n' flag). For the moment, there is no way around except creating the temporary file and then delete it.
msg299797 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2017-08-06 13:01
No, it should not.  A DBM is not necessarily a single file.  What you should be doing is creating a temporary *directory*, and opening your DB inside that.
msg299798 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2017-08-06 13:02
By the way, if you want to open a doc issue with a suggestion of how to clarify this in the docs, that would be welcome.
History
Date User Action Args
2017-08-06 13:02:58r.david.murraysetmessages: + msg299798
2017-08-06 13:01:52r.david.murraysetstatus: open -> closed

components: + Library (Lib), - IO

nosy: + r.david.murray
messages: + msg299797
resolution: rejected
stage: resolved
2017-08-05 16:26:59Stephen Larroquecreate