summaryrefslogtreecommitdiffstats
path: root/Modules/_sqlite/cache.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2018-12-10 14:06:08 (GMT)
committerGitHub <noreply@github.com>2018-12-10 14:06:08 (GMT)
commitfc662ac332443a316a120fa5287c235dc4f8739b (patch)
tree3283170105c2e3b2dafa7233f4819cabab9fbb8d /Modules/_sqlite/cache.c
parentdffccc6b594951fc798973e521da205785823f0f (diff)
downloadcpython-fc662ac332443a316a120fa5287c235dc4f8739b.zip
cpython-fc662ac332443a316a120fa5287c235dc4f8739b.tar.gz
cpython-fc662ac332443a316a120fa5287c235dc4f8739b.tar.bz2
bpo-32788: Better error handling in sqlite3. (GH-3723)
Propagate unexpected errors (like MemoryError and KeyboardInterrupt) to user.
Diffstat (limited to 'Modules/_sqlite/cache.c')
-rw-r--r--Modules/_sqlite/cache.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/Modules/_sqlite/cache.c b/Modules/_sqlite/cache.c
index 72b1f2c..4270473 100644
--- a/Modules/_sqlite/cache.c
+++ b/Modules/_sqlite/cache.c
@@ -119,7 +119,7 @@ PyObject* pysqlite_cache_get(pysqlite_Cache* self, PyObject* args)
pysqlite_Node* ptr;
PyObject* data;
- node = (pysqlite_Node*)PyDict_GetItem(self->mapping, key);
+ node = (pysqlite_Node*)PyDict_GetItemWithError(self->mapping, key);
if (node) {
/* an entry for this key already exists in the cache */
@@ -157,7 +157,11 @@ PyObject* pysqlite_cache_get(pysqlite_Cache* self, PyObject* args)
}
ptr->prev = node;
}
- } else {
+ }
+ else if (PyErr_Occurred()) {
+ return NULL;
+ }
+ else {
/* There is no entry for this key in the cache, yet. We'll insert a new
* entry in the cache, and make space if necessary by throwing the
* least used item out of the cache. */