summaryrefslogtreecommitdiffstats
path: root/Modules/_sqlite
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2007-10-23 19:24:22 (GMT)
committerGeorg Brandl <georg@python.org>2007-10-23 19:24:22 (GMT)
commite1a0d11c5cceeb71b22f3e3148f8f7d6bc0b4d8f (patch)
treeb189190df6a08b5249bef4e33385049f4ccf3d04 /Modules/_sqlite
parent083bea49a8b74a5f758c6641c299f0cc8c114616 (diff)
downloadcpython-e1a0d11c5cceeb71b22f3e3148f8f7d6bc0b4d8f.zip
cpython-e1a0d11c5cceeb71b22f3e3148f8f7d6bc0b4d8f.tar.gz
cpython-e1a0d11c5cceeb71b22f3e3148f8f7d6bc0b4d8f.tar.bz2
#1316: remove redundant PyLong_Check calls when PyInt_Check was already called.
Diffstat (limited to 'Modules/_sqlite')
-rw-r--r--Modules/_sqlite/row.c7
-rw-r--r--Modules/_sqlite/statement.c11
2 files changed, 8 insertions, 10 deletions
diff --git a/Modules/_sqlite/row.c b/Modules/_sqlite/row.c
index b2f105a..2f3ba69 100644
--- a/Modules/_sqlite/row.c
+++ b/Modules/_sqlite/row.c
@@ -76,12 +76,7 @@ PyObject* pysqlite_row_subscript(pysqlite_Row* self, PyObject* idx)
PyObject* item;
- if (PyInt_Check(idx)) {
- _idx = PyInt_AsLong(idx);
- item = PyTuple_GetItem(self->data, _idx);
- Py_XINCREF(item);
- return item;
- } else if (PyLong_Check(idx)) {
+ if (PyLong_Check(idx)) {
_idx = PyLong_AsLong(idx);
item = PyTuple_GetItem(self->data, _idx);
Py_XINCREF(item);
diff --git a/Modules/_sqlite/statement.c b/Modules/_sqlite/statement.c
index 9080c9b..1cc3cdd 100644
--- a/Modules/_sqlite/statement.c
+++ b/Modules/_sqlite/statement.c
@@ -80,9 +80,10 @@ int pysqlite_statement_create(pysqlite_Statement* self, pysqlite_Connection* con
int pysqlite_statement_bind_parameter(pysqlite_Statement* self, int pos, PyObject* parameter)
{
int rc = SQLITE_OK;
- long longval;
#ifdef HAVE_LONG_LONG
PY_LONG_LONG longlongval;
+#else
+ long longval;
#endif
const char* buffer;
char* string;
@@ -91,14 +92,16 @@ int pysqlite_statement_bind_parameter(pysqlite_Statement* self, int pos, PyObjec
if (parameter == Py_None) {
rc = sqlite3_bind_null(self->st, pos);
- } else if (PyInt_CheckExact(parameter)) {
- longval = PyInt_AsLong(parameter);
- rc = sqlite3_bind_int64(self->st, pos, (sqlite_int64)longval);
#ifdef HAVE_LONG_LONG
} else if (PyLong_Check(parameter)) {
longlongval = PyLong_AsLongLong(parameter);
/* in the overflow error case, longlongval is -1, and an exception is set */
rc = sqlite3_bind_int64(self->st, pos, (sqlite_int64)longlongval);
+#else
+ } else if (PyLong_Check(parameter)) {
+ longval = PyLong_AsLong(parameter);
+ /* in the overflow error case, longval is -1, and an exception is set */
+ rc = sqlite3_bind_int64(self->st, pos, (sqlite_int64)longval);
#endif
} else if (PyFloat_Check(parameter)) {
rc = sqlite3_bind_double(self->st, pos, PyFloat_AsDouble(parameter));