Skip to content

Commit b6f5b9d

Browse files
sir-sigurdserhiy-storchaka
authored andcommitted
Replace _pysqlite_long_from_int64() with PyLong_FromLongLong() (GH-16882)
1 parent ea6041c commit b6f5b9d

File tree

4 files changed

+3
-20
lines changed

4 files changed

+3
-20
lines changed

Modules/_sqlite/connection.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ PyObject* _pysqlite_build_py_params(sqlite3_context *context, int argc, sqlite3_
550550
cur_value = argv[i];
551551
switch (sqlite3_value_type(argv[i])) {
552552
case SQLITE_INTEGER:
553-
cur_py_value = _pysqlite_long_from_int64(sqlite3_value_int64(cur_value));
553+
cur_py_value = PyLong_FromLongLong(sqlite3_value_int64(cur_value));
554554
break;
555555
case SQLITE_FLOAT:
556556
cur_py_value = PyFloat_FromDouble(sqlite3_value_double(cur_value));

Modules/_sqlite/cursor.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ _pysqlite_fetch_one_row(pysqlite_Cursor* self)
277277
Py_INCREF(Py_None);
278278
converted = Py_None;
279279
} else if (coltype == SQLITE_INTEGER) {
280-
converted = _pysqlite_long_from_int64(sqlite3_column_int64(self->statement->st, i));
280+
converted = PyLong_FromLongLong(sqlite3_column_int64(self->statement->st, i));
281281
} else if (coltype == SQLITE_FLOAT) {
282282
converted = PyFloat_FromDouble(sqlite3_column_double(self->statement->st, i));
283283
} else if (coltype == SQLITE_TEXT) {
@@ -558,7 +558,7 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* args)
558558
Py_BEGIN_ALLOW_THREADS
559559
lastrowid = sqlite3_last_insert_rowid(self->connection->db);
560560
Py_END_ALLOW_THREADS
561-
self->lastrowid = _pysqlite_long_from_int64(lastrowid);
561+
self->lastrowid = PyLong_FromLongLong(lastrowid);
562562
}
563563

564564
if (rc == SQLITE_ROW) {

Modules/_sqlite/util.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -103,22 +103,6 @@ int _pysqlite_seterror(sqlite3* db, sqlite3_stmt* st)
103103
# define IS_LITTLE_ENDIAN 1
104104
#endif
105105

106-
PyObject *
107-
_pysqlite_long_from_int64(sqlite_int64 value)
108-
{
109-
# if SIZEOF_LONG_LONG < 8
110-
if (value > PY_LLONG_MAX || value < PY_LLONG_MIN) {
111-
return _PyLong_FromByteArray(&value, sizeof(value),
112-
IS_LITTLE_ENDIAN, 1 /* signed */);
113-
}
114-
# endif
115-
# if SIZEOF_LONG < SIZEOF_LONG_LONG
116-
if (value > LONG_MAX || value < LONG_MIN)
117-
return PyLong_FromLongLong(value);
118-
# endif
119-
return PyLong_FromLong(Py_SAFE_DOWNCAST(value, sqlite_int64, long));
120-
}
121-
122106
sqlite_int64
123107
_pysqlite_long_as_int64(PyObject * py_val)
124108
{

Modules/_sqlite/util.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ int pysqlite_step(sqlite3_stmt* statement, pysqlite_Connection* connection);
3737
*/
3838
int _pysqlite_seterror(sqlite3* db, sqlite3_stmt* st);
3939

40-
PyObject * _pysqlite_long_from_int64(sqlite_int64 value);
4140
sqlite_int64 _pysqlite_long_as_int64(PyObject * value);
4241

4342
#if SQLITE_VERSION_NUMBER >= 3007014

0 commit comments

Comments
 (0)