Skip to content

Commit 90bac9c

Browse files
author
Erlend E. Aasland
committed
_pysqlite_connection_begin() now returns an int
1 parent b2ec37a commit 90bac9c

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

Modules/_sqlite/connection.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,8 @@ int pysqlite_check_connection(pysqlite_Connection* con)
372372
}
373373
}
374374

375-
PyObject* _pysqlite_connection_begin(pysqlite_Connection* self)
375+
int
376+
_pysqlite_connection_begin(pysqlite_Connection *self)
376377
{
377378
int rc;
378379
sqlite3_stmt* statement;
@@ -402,10 +403,9 @@ PyObject* _pysqlite_connection_begin(pysqlite_Connection* self)
402403

403404
error:
404405
if (PyErr_Occurred()) {
405-
return NULL;
406-
} else {
407-
Py_RETURN_NONE;
406+
return -1;
408407
}
408+
return 0;
409409
}
410410

411411
/*[clinic input]

Modules/_sqlite/connection.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ typedef struct
108108

109109
extern PyTypeObject *pysqlite_ConnectionType;
110110

111-
PyObject* _pysqlite_connection_begin(pysqlite_Connection* self);
111+
int _pysqlite_connection_begin(pysqlite_Connection *self);
112112

113113
int pysqlite_connection_register_cursor(pysqlite_Connection* connection, PyObject* cursor);
114114
int pysqlite_check_thread(pysqlite_Connection* self);

Modules/_sqlite/cursor.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,6 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* operation
404404
int i;
405405
int rc;
406406
PyObject* func_args;
407-
PyObject* result;
408407
int numcols;
409408
PyObject* column_name;
410409
sqlite_int64 lastrowid;
@@ -505,11 +504,9 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* operation
505504
SELECT is the only exception. See #9924. */
506505
if (self->connection->begin_statement && self->statement->is_dml) {
507506
if (sqlite3_get_autocommit(self->connection->db)) {
508-
result = _pysqlite_connection_begin(self->connection);
509-
if (!result) {
507+
if (_pysqlite_connection_begin(self->connection) < 0) {
510508
goto error;
511509
}
512-
Py_DECREF(result);
513510
}
514511
}
515512

0 commit comments

Comments
 (0)