Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(28894)

Side by Side Diff: Modules/_gdbmmodule.c

Issue 34248: dbm errors should contain file names
Patch Set: Created 1 year, 1 month ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* DBM module using dictionary interface */ 2 /* DBM module using dictionary interface */
3 /* Author: Anthony Baxter, after dbmmodule.c */ 3 /* Author: Anthony Baxter, after dbmmodule.c */
4 /* Doc strings: Mitch Chapman */ 4 /* Doc strings: Mitch Chapman */
5 5
6 6
7 #include "Python.h" 7 #include "Python.h"
8 8
9 #include <sys/types.h> 9 #include <sys/types.h>
10 #include <sys/stat.h> 10 #include <sys/stat.h>
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 { 68 {
69 dbmobject *dp; 69 dbmobject *dp;
70 70
71 dp = PyObject_New(dbmobject, &Dbmtype); 71 dp = PyObject_New(dbmobject, &Dbmtype);
72 if (dp == NULL) 72 if (dp == NULL)
73 return NULL; 73 return NULL;
74 dp->di_size = -1; 74 dp->di_size = -1;
75 errno = 0; 75 errno = 0;
76 if ((dp->di_dbm = gdbm_open((char *)file, 0, flags, mode, NULL)) == 0) { 76 if ((dp->di_dbm = gdbm_open((char *)file, 0, flags, mode, NULL)) == 0) {
77 if (errno != 0) 77 if (errno != 0)
78 PyErr_SetFromErrno(DbmError); 78 PyErr_SetFromErrnoWithFilename(DbmError, file);
79 else 79 else
80 PyErr_SetString(DbmError, gdbm_strerror(gdbm_errno)); 80 PyErr_SetString(DbmError, gdbm_strerror(gdbm_errno));
81 Py_DECREF(dp); 81 Py_DECREF(dp);
82 return NULL; 82 return NULL;
83 } 83 }
84 return (PyObject *)dp; 84 return (PyObject *)dp;
85 } 85 }
86 86
87 /* Methods */ 87 /* Methods */
88 88
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 d = PyModule_GetDict(m); 651 d = PyModule_GetDict(m);
652 DbmError = PyErr_NewException("_gdbm.error", PyExc_IOError, NULL); 652 DbmError = PyErr_NewException("_gdbm.error", PyExc_IOError, NULL);
653 if (DbmError != NULL) { 653 if (DbmError != NULL) {
654 PyDict_SetItemString(d, "error", DbmError); 654 PyDict_SetItemString(d, "error", DbmError);
655 s = PyUnicode_FromString(dbmmodule_open_flags); 655 s = PyUnicode_FromString(dbmmodule_open_flags);
656 PyDict_SetItemString(d, "open_flags", s); 656 PyDict_SetItemString(d, "open_flags", s);
657 Py_DECREF(s); 657 Py_DECREF(s);
658 } 658 }
659 return m; 659 return m;
660 } 660 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+