mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-22 17:06:33 +03:00
Fixed .execute() segfault.
This commit is contained in:
parent
5322b4e92f
commit
b300cd2550
|
@ -1,3 +1,8 @@
|
|||
2005-06-02 Federico Di Gregorio <fog@debian.org>
|
||||
|
||||
* psycopg/cursor_type.c (_psyco_curs_execute): fixed segfault when
|
||||
not passing string or unicode to .execute().
|
||||
|
||||
2005-05-31 Federico Di Gregorio <fog@debian.org>
|
||||
|
||||
* psycopg/cursor_type.c (_psyco_curs_execute): if a
|
||||
|
|
|
@ -259,6 +259,12 @@ _psyco_curs_execute(cursorObject *self,
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
else if (!PyString_Check(operation)) {
|
||||
/* the operation is not unicode or string, raise an error */
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"argument 1 must be a string or unicode object");
|
||||
return 0;
|
||||
}
|
||||
|
||||
IFCLEARPGRES(self->pgres);
|
||||
|
||||
|
|
|
@ -52,6 +52,14 @@ class TypesBasicTests(TestCase):
|
|||
r = str(self.execute("SELECT %s::bytea AS foo", (b,)))
|
||||
self.failUnless(r == s, "wrong binary quoting")
|
||||
|
||||
def testArray(self):
|
||||
s = self.execute("SELECT %s AS foo", ([[1,2],[3,4]],))
|
||||
self.failUnless(s == [[1,2],[3,4]], "wrong array quoting " + str(s))
|
||||
s = self.execute("SELECT %s AS foo", (['one', 'two', 'three'],))
|
||||
self.failUnless(s == ['one', 'two', 'three'],
|
||||
"wrong array quoting " + str(s))
|
||||
|
||||
|
||||
class TypesBasicSuite(TestSuite):
|
||||
"""Build a suite of all tests."""
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user