[pypy-dev] [pypy-commit] pypy default: Fix a bug in _sqlite3.py: memory is freed too early
arigo at tunes.org
Mon Aug 15 08:49:26 CEST 2011
On Sun, Aug 14, 2011 at 10:50 AM, Antonio Cuni <anto.cuni at gmail.com> wrote:
> why is this needed? Does the sqlite API requires that the SQL buffer stays
> alive even after the call to sqlite3_prepare?
Yes, because the output argument 'next_value' receives a pointer to
the middle of the same buffer that was passed in as 'sql'. So passing
'sql' as a Python string doesn't work: it gets converted to a C string
when passed to the function, and discarded after the call. It works
anyway on CPython because the C string pointer is actually inside the
PyStringObject, which happens to stay alive.
More information about the pypy-dev