classification
Title: dbm errors should contain file names
Type: enhancement Stage: resolved
Components: Extension Modules Versions: Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: berker.peksag, csernazs, sam-s
Priority: normal Keywords: patch

Created on 2018-07-27 13:33 by sam-s, last changed 2018-09-27 19:55 by berker.peksag. This issue is now closed.

Files
File name Uploaded Description Edit
patch.diff csernazs, 2018-07-31 20:19 review
Pull Requests
URL Status Linked Edit
PR 8590 merged csernazs, 2018-07-31 20:56
Messages (6)
msg322492 - (view) Author: sds (sam-s) Date: 2018-07-27 13:33
`dbm` errors should contain file names when appropriate, just like `OSError`.
E.g.:
```
>>> open("fooooo")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
FileNotFoundError: [Errno 2] No such file or directory: 'fooooo'
>>> import dbm.gnu
>>> dbm.gnu.open("fooooo")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
_gdbm.error: [Errno 2] No such file or directory
```
the `_gdbm.error` should report the file name `'fooooo'` just like `FileNotFoundError` does (and `exn.args` should contain the file name too!)
msg322815 - (view) Author: Zsolt Cserna (csernazs) * Date: 2018-07-31 20:19
I've made a patch which works for me.

>>> dbm.gnu.open("/tmp/zzzzz")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
_gdbm.error: [Errno 2] No such file or directory: '/tmp/zzzzz'
>>> 


Could you please give it a try?
msg322816 - (view) Author: sds (sam-s) Date: 2018-07-31 20:37
thanks for the patch.
alas, I do not build python myself, so I cannot try it.
msg322821 - (view) Author: Zsolt Cserna (csernazs) * Date: 2018-07-31 21:01
Alright, I created a PR for this. We will see if this can be merged to upstream or not.
msg323178 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2018-08-06 06:28
PR 8590 only changes dbm.gnu. If we do this, we should update dbm.ndbm as well:

    https://github.com/python/cpython/blob/4a745333406a4b9c5b0194bdac4a77d9fadd5457/Modules/_dbmmodule.c#L65
msg326590 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2018-09-27 19:54
New changeset 9df346bf98069a87de14a3c2f69009d800994c63 by Berker Peksag (Zsolt Cserna) in branch 'master':
bpo-34248: Add filename to error raised in {gnu,ndbm}.open() (GH-8590)
https://github.com/python/cpython/commit/9df346bf98069a87de14a3c2f69009d800994c63
History
Date User Action Args
2018-09-27 19:55:04berker.peksagsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2018-09-27 19:54:38berker.peksagsetmessages: + msg326590
2018-08-06 06:28:35berker.peksagsetversions: - Python 2.7, Python 3.4, Python 3.5, Python 3.6, Python 3.7
nosy: + berker.peksag

messages: + msg323178

type: enhancement
2018-07-31 21:01:48csernazssetmessages: + msg322821
2018-07-31 20:56:26csernazssetstage: patch review
pull_requests: + pull_request8100
2018-07-31 20:37:55sam-ssetmessages: + msg322816
2018-07-31 20:19:59csernazssetfiles: + patch.diff

nosy: + csernazs
messages: + msg322815

keywords: + patch
2018-07-27 13:33:58sam-screate