diff options
author | Erlend Egeberg Aasland <erlend.aasland@innova.no> | 2021-10-29 20:21:58 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-29 20:21:58 (GMT) |
commit | e2e62b3808691e15fa44b883270023e42dcad958 (patch) | |
tree | 93cbd5374ba0948ada5d92e4608e1d794a2ec174 | |
parent | b17cfd150f4dc2816975d304a71110a2d445eaf0 (diff) | |
download | cpython-e2e62b3808691e15fa44b883270023e42dcad958.zip cpython-e2e62b3808691e15fa44b883270023e42dcad958.tar.gz cpython-e2e62b3808691e15fa44b883270023e42dcad958.tar.bz2 |
bpo-45581: Raise `MemoryError` in `sqlite3.connect` if SQLite signals memory error (GH-29171)
-rw-r--r-- | Misc/NEWS.d/next/Library/2021-10-22-21-57-02.bpo-45581.rlH6ay.rst | 2 | ||||
-rw-r--r-- | Modules/_sqlite/connection.c | 4 |
2 files changed, 6 insertions, 0 deletions
diff --git a/Misc/NEWS.d/next/Library/2021-10-22-21-57-02.bpo-45581.rlH6ay.rst b/Misc/NEWS.d/next/Library/2021-10-22-21-57-02.bpo-45581.rlH6ay.rst new file mode 100644 index 0000000..13a3b23 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2021-10-22-21-57-02.bpo-45581.rlH6ay.rst @@ -0,0 +1,2 @@ +:meth:`sqlite3.connect` now correctly raises :exc:`MemoryError` if the +underlying SQLite API signals memory error. Patch by Erlend E. Aasland. diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c index da2f12e..94c38ad 100644 --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -165,6 +165,10 @@ pysqlite_connection_init_impl(pysqlite_Connection *self, (uri ? SQLITE_OPEN_URI : 0), NULL); Py_END_ALLOW_THREADS + if (self->db == NULL && rc == SQLITE_NOMEM) { + PyErr_NoMemory(); + return -1; + } if (rc != SQLITE_OK) { _pysqlite_seterror(state, self->db); return -1; |