diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2018-12-10 14:06:08 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-10 14:06:08 (GMT) |
commit | fc662ac332443a316a120fa5287c235dc4f8739b (patch) | |
tree | 3283170105c2e3b2dafa7233f4819cabab9fbb8d /Modules/_sqlite/cache.c | |
parent | dffccc6b594951fc798973e521da205785823f0f (diff) | |
download | cpython-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.c | 8 |
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. */ |