Require 3.7.15 or newer and use sqlite3_close_v2 explicitly.
This commit is contained in:
parent
2748334ffd
commit
44f1c39205
2 changed files with 2 additions and 34 deletions
|
|
@ -250,7 +250,7 @@ void pysqlite_connection_dealloc(pysqlite_Connection* self)
|
||||||
|
|
||||||
/* Clean up if user has not called .close() explicitly. */
|
/* Clean up if user has not called .close() explicitly. */
|
||||||
if (self->db) {
|
if (self->db) {
|
||||||
SQLITE3_CLOSE(self->db);
|
sqlite3_close_v2(self->db);
|
||||||
}
|
}
|
||||||
|
|
||||||
Py_XDECREF(self->isolation_level);
|
Py_XDECREF(self->isolation_level);
|
||||||
|
|
@ -424,7 +424,7 @@ PyObject* pysqlite_connection_close(pysqlite_Connection* self, PyObject* args)
|
||||||
pysqlite_close_all_blobs(self);
|
pysqlite_close_all_blobs(self);
|
||||||
|
|
||||||
if (self->db) {
|
if (self->db) {
|
||||||
rc = SQLITE3_CLOSE(self->db);
|
rc = sqlite3_close_v2(self->db);
|
||||||
|
|
||||||
if (rc != SQLITE_OK) {
|
if (rc != SQLITE_OK) {
|
||||||
_pysqlite_seterror(self->db, NULL);
|
_pysqlite_seterror(self->db, NULL);
|
||||||
|
|
@ -1781,33 +1781,7 @@ pysqlite_connection_backup(pysqlite_Connection *self, PyObject *args, PyObject *
|
||||||
if (rc == SQLITE_NOMEM) {
|
if (rc == SQLITE_NOMEM) {
|
||||||
(void)PyErr_NoMemory();
|
(void)PyErr_NoMemory();
|
||||||
} else {
|
} else {
|
||||||
#if SQLITE_VERSION_NUMBER > 3007015
|
|
||||||
PyErr_SetString(pysqlite_OperationalError, sqlite3_errstr(rc));
|
PyErr_SetString(pysqlite_OperationalError, sqlite3_errstr(rc));
|
||||||
#else
|
|
||||||
switch (rc) {
|
|
||||||
case SQLITE_ERROR:
|
|
||||||
/* Description of SQLITE_ERROR in SQLite 3.7.14 and older
|
|
||||||
releases. */
|
|
||||||
PyErr_SetString(pysqlite_OperationalError,
|
|
||||||
"SQL logic error or missing database");
|
|
||||||
break;
|
|
||||||
case SQLITE_READONLY:
|
|
||||||
PyErr_SetString(pysqlite_OperationalError,
|
|
||||||
"attempt to write a readonly database");
|
|
||||||
break;
|
|
||||||
case SQLITE_BUSY:
|
|
||||||
PyErr_SetString(pysqlite_OperationalError, "database is locked");
|
|
||||||
break;
|
|
||||||
case SQLITE_LOCKED:
|
|
||||||
PyErr_SetString(pysqlite_OperationalError,
|
|
||||||
"database table is locked");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
PyErr_Format(pysqlite_OperationalError,
|
|
||||||
"unrecognized error code: %d", rc);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,10 +39,4 @@ int _pysqlite_seterror(sqlite3* db, sqlite3_stmt* st);
|
||||||
|
|
||||||
sqlite_int64 _pysqlite_long_as_int64(PyObject * value);
|
sqlite_int64 _pysqlite_long_as_int64(PyObject * value);
|
||||||
|
|
||||||
#if SQLITE_VERSION_NUMBER >= 3007014
|
|
||||||
#define SQLITE3_CLOSE sqlite3_close_v2
|
|
||||||
#else
|
|
||||||
#define SQLITE3_CLOSE sqlite3_close
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue