From 9df346bf98069a87de14a3c2f69009d800994c63 Mon Sep 17 00:00:00 2001 From: Zsolt Cserna Date: Thu, 27 Sep 2018 21:54:34 +0200 Subject: bpo-34248: Add filename to error raised in {gnu,ndbm}.open() (GH-8590) Report the filename to the exception when raising {gdbm,dbm.ndbm}.error in dbm.gnu.open() and dbm.ndbm.open() functions, so it gets printed when the exception is raised, and can also be obtained by the filename attribute of the exception object. --- Modules/_gdbmmodule.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Modules/_gdbmmodule.c') diff --git a/Modules/_gdbmmodule.c b/Modules/_gdbmmodule.c index 10560040e4..ceb744b99b 100644 --- a/Modules/_gdbmmodule.c +++ b/Modules/_gdbmmodule.c @@ -75,7 +75,7 @@ newdbmobject(const char *file, int flags, int mode) errno = 0; if ((dp->di_dbm = gdbm_open((char *)file, 0, flags, mode, NULL)) == 0) { if (errno != 0) - PyErr_SetFromErrno(DbmError); + PyErr_SetFromErrnoWithFilename(DbmError, file); else PyErr_SetString(DbmError, gdbm_strerror(gdbm_errno)); Py_DECREF(dp); -- cgit v1.2.1