Public bug reported:

Running Ubuntu 10.04 with python-psycopg2 version 2.0.13-2ubuntu2 and
python version 2.6.5-0ubuntu1.

Reporting the bug here because I have no idea how to contact the
psycopg2 maintainer (the psycopg2 website simply says "the mailing lists
are currently unavailable").

Executing the following commands will produce a segfault:

$ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41) 
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import psycopg2.extensions
>>> val = psycopg2.extensions.adapt([1,2,3])
>>> str(val)
Segmentation fault

After patching the function list_str in adapt_list.c (line 88) to use
the correct Python calling convention, the bug is resolved:

$ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41) 
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import psycopg2.extensions
>>> val = psycopg2.extensions.adapt([1,2,3])
>>> str(val)
'ARRAY[1, 2, 3]'

See attached patch;  it's a simple one-line change.  I don't recall this
particular code giving me trouble before, so I suspect that python 2.5
and earlier had a different implementation of PyArg_ParseTuple() which
would return to the caller immediately if the format string was empty,
and thus this bug has gone unnoticed.

** Affects: psycopg2 (Ubuntu)
     Importance: Undecided
         Status: New

-- 
psycopg2 segfaults when trying to adapt() a Python list
https://bugs.launchpad.net/bugs/663211
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to