This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: 2.7.3: sqlite module does not build on centos 5 and Mac OS X 10.4
Type: compile error Stage: resolved
Components: Build Versions: Python 2.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Joakim.Sernbrant, Marc.Abramowitz, dmalcolm, lemburg, ned.deily, petri.lehtinen, python-dev
Priority: normal Keywords: patch

Created on 2012-04-13 22:09 by Joakim.Sernbrant, last changed 2022-04-11 14:57 by admin. This issue is now closed.

File name Uploaded Description Edit
sqlite3_int64.patch Marc.Abramowitz, 2012-05-19 07:09 Patch for sqlite3_int64 undeclared build error review
sqlite3_int64_v2.patch ned.deily, 2012-05-20 00:35
Messages (16)
msg158238 - (view) Author: Joakim Sernbrant (Joakim.Sernbrant) Date: 2012-04-13 22:09
Python-2.7.3/Modules/_sqlite/connection.c: In function ‘_pysqlite_set_result’:
Python-2.7.3/Modules/_sqlite/connection.c:552: error: ‘sqlite3_int64’ undeclared (first use in this function)

The centos 5 version of sqlite3 (sqlite-devel-3.3.6-5) does not export the type sqlite3_int64. 2.7.0 did build without problems.

Newer versions declare both sqlite3_int64 and sqlite_int64:


diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c
index 26678c7..a646513 100644
--- a/Modules/_sqlite/connection.c
+++ b/Modules/_sqlite/connection.c
@@ -549,7 +549,7 @@ void _pysqlite_set_result(sqlite3_context* context, PyObject* py_val)
     } else if (py_val == Py_None) {
     } else if (PyInt_Check(py_val)) {
-        sqlite3_result_int64(context, (sqlite3_int64)PyInt_AsLong(py_val));
+        sqlite3_result_int64(context, (sqlite_int64)PyInt_AsLong(py_val));
     } else if (PyLong_Check(py_val)) {
         sqlite3_result_int64(context, PyLong_AsLongLong(py_val));
     } else if (PyFloat_Check(py_val)) {
@@ -580,7 +580,7 @@ PyObject* _pysqlite_build_py_params(sqlite3_context *context, int argc, sqlite3_
     sqlite3_value* cur_value;
     PyObject* cur_py_value;
     const char* val_str;
-    sqlite3_int64 val_int;
+    sqlite_int64 val_int;
     Py_ssize_t buflen;
     void* raw_buffer;
msg159089 - (view) Author: Marc Abramowitz (Marc.Abramowitz) * Date: 2012-04-23 21:53
This patch worked for me as well. Thanks, Joakim!

$ cat /etc/redhat-release 
CentOS release 5.5 (Final)
msg159917 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2012-05-04 10:29
Mac OS X 10.4 is also affected and for the same reason. SQLite builds fine for Python 2.5 and 2.6, but not for 2.7.
msg161076 - (view) Author: Marc Abramowitz (Marc.Abramowitz) * Date: 2012-05-18 19:08
Just to make this a tad easier, I put Joakim's patch into a gist:

    [marca@logger01.prod1 Python-2.7.3]$ pwd

    [marca@logger01.prod1 Python-2.7.3]$ curl -sk | patch -p1
    patching file Modules/_sqlite/connection.c

I suppose this could be fixed in the Python code with some autoconf stuff, but I'm not too comfortable with autoconf.
msg161077 - (view) Author: Marc Abramowitz (Marc.Abramowitz) * Date: 2012-05-18 19:09
curl -sk | patch -p1
msg161095 - (view) Author: Marc Abramowitz (Marc.Abramowitz) * Date: 2012-05-19 07:09
OK, here's a patch for which seems to fix this problem -- if folks could review and test it that would be great.
msg161172 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2012-05-20 00:35
Thanks for the patch to It appears to work on OS X 10.4 and it should on any other system with an older version of sqlite3 installed. However, I think a better approach is to just change the two problematic references in Modules/_sqlite/connection.c to the older backwards compatible form.  The current sqlite3.h file explicitly supports the older type for backward compatibility for exactly this kind of case.  If so, why add unnecessary magic to Python's configure?  Presumably the sqlite3 project will need to continue to support both definitions indefinitely.  Perhaps Petri can chime in here as he made the change to include the new types.  Attached is a new patch tested on OS X 10.4 and 10.7.
msg161173 - (view) Author: Marc Abramowitz (Marc.Abramowitz) * Date: 2012-05-20 00:55
My guess would be that the code was switched to use the new typedef because the SQLite docs say they're preferred.

Maybe they are planning to deprecate the old typedef at some point?
msg161174 - (view) Author: Marc Abramowitz (Marc.Abramowitz) * Date: 2012-05-20 01:02
Probably either approach will have the exact same effect for the foreseeable
future, so I don't feel strongly either way. It would be nice to have one of them so folks can have a sqlite3 module without having to search around and apply patches. Big win.
msg161184 - (view) Author: Petri Lehtinen (petri.lehtinen) * (Python committer) Date: 2012-05-20 04:26
Changing the code to use sqlite_int64 (Ned's patch) sounds better to me.
msg161185 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-05-20 06:36
New changeset e31597b3bd15 by Ned Deily in branch '2.7':
Issue #14572: Prevent build failures with pre-3.5.0 versions of
msg161186 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2012-05-20 06:39
OK, the patch, as originally suggested by Joakim, is applied for release in 2.7.4.  Thanks everyone.
msg161194 - (view) Author: Petri Lehtinen (petri.lehtinen) * (Python committer) Date: 2012-05-20 09:48
Isn't 3.2 or 3.3 affected by this?
msg161214 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2012-05-20 15:36
> Isn't 3.2 or 3.3 affected by this?

No, since the developer who made the original changes used sqlite3_int64 for 2.7 (789a3ea97083) but chose to hardwire the type to PyLong_AsLongLong for 3.x (e67715b87131). [corrected ids]
msg161217 - (view) Author: Marc Abramowitz (Marc.Abramowitz) * Date: 2012-05-20 16:43
Ned, thanks for applying this patch!
msg187975 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-04-28 11:17
New changeset 44fe1f5b07e3 by Serhiy Storchaka in branch '2.7':
Issue #17857: Prevent build failures with pre-3.5.0 versions of sqlite3,
Date User Action Args
2022-04-11 14:57:29adminsetgithub: 58777
2013-04-28 11:17:57python-devsetmessages: + msg187975
2012-05-20 16:43:35Marc.Abramowitzsetmessages: + msg161217
2012-05-20 15:36:29ned.deilysetmessages: + msg161214
2012-05-20 15:34:49ned.deilysetmessages: - msg161213
2012-05-20 15:33:27ned.deilysetmessages: + msg161213
2012-05-20 09:48:50petri.lehtinensetmessages: + msg161194
2012-05-20 06:39:48ned.deilysetstatus: open -> closed
resolution: fixed
messages: + msg161186

stage: patch review -> resolved
2012-05-20 06:36:12python-devsetnosy: + python-dev
messages: + msg161185
2012-05-20 04:26:09petri.lehtinensetmessages: + msg161184
2012-05-20 01:02:49Marc.Abramowitzsetmessages: + msg161174
2012-05-20 00:55:50Marc.Abramowitzsetmessages: + msg161173
2012-05-20 00:35:09ned.deilysetfiles: + sqlite3_int64_v2.patch

nosy: + ned.deily, petri.lehtinen
messages: + msg161172

stage: patch review
2012-05-19 22:25:15pitrousetnosy: + dmalcolm
2012-05-19 07:09:23Marc.Abramowitzsetfiles: + sqlite3_int64.patch
keywords: + patch
messages: + msg161095
2012-05-18 19:09:15Marc.Abramowitzsetmessages: + msg161077
2012-05-18 19:08:23Marc.Abramowitzsetmessages: + msg161076
2012-05-04 10:29:25lemburgsetnosy: + lemburg

messages: + msg159917
title: 2.7.3: sqlite module does not build on centos 5 -> 2.7.3: sqlite module does not build on centos 5 and Mac OS X 10.4
2012-04-23 21:53:03Marc.Abramowitzsetnosy: + Marc.Abramowitz
messages: + msg159089
2012-04-13 22:09:11Joakim.Sernbrantcreate