[pypy-dev] [pypy-commit] pypy default: Fix a bug in _sqlite3.py: memory is freed too early
Antonio Cuni
anto.cuni at gmail.com
Sun Aug 14 10:50:14 CEST 2011
On 13/08/11 22:15, arigo wrote:
> Log: Fix a bug in _sqlite3.py: memory is freed too early
>
> diff --git a/lib_pypy/_sqlite3.py b/lib_pypy/_sqlite3.py
> --- a/lib_pypy/_sqlite3.py
> +++ b/lib_pypy/_sqlite3.py
> @@ -891,7 +891,8 @@
>
> self.statement = c_void_p()
> next_char = c_char_p()
> - ret = sqlite.sqlite3_prepare_v2(self.con.db, sql, -1, byref(self.statement), byref(next_char))
> + sql_char = c_char_p(sql)
> + ret = sqlite.sqlite3_prepare_v2(self.con.db, sql_char, -1, byref(self.statement), byref(next_char))
> if ret == SQLITE_OK and self.statement.value is None:
> # an empty statement, we work around that, as it's the least trouble
> ret = sqlite.sqlite3_prepare_v2(self.con.db, "select 42", -1, byref(self.statement), byref(next_char))
> @@ -903,6 +904,7 @@
> if _check_remaining_sql(next_char.value):
> raise Warning, "One and only one statement required: %r" % (
> next_char.value,)
> + # sql_char should remain alive until here
>
> self._build_row_cast_map()
why is this needed? Does the sqlite API requires that the SQL buffer stays
alive even after the call to sqlite3_prepare?
ciao,
Anto
More information about the pypy-dev
mailing list