mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-22 17:06:33 +03:00
parent
6ab1ec1c37
commit
e11d0d39ec
2
NEWS
2
NEWS
|
@ -8,6 +8,8 @@ What's new in psycopg 2.5.2
|
||||||
(:ticket:`#170`).
|
(:ticket:`#170`).
|
||||||
- Meaningful connection errors report a meaningful message, thanks to
|
- Meaningful connection errors report a meaningful message, thanks to
|
||||||
Alexey Borzenkov (:ticket:`#173`).
|
Alexey Borzenkov (:ticket:`#173`).
|
||||||
|
- Manually creating `lobject` with the wrong parameter doesn't segfault
|
||||||
|
(:ticket:`#187`).
|
||||||
|
|
||||||
|
|
||||||
What's new in psycopg 2.5.1
|
What's new in psycopg 2.5.1
|
||||||
|
|
|
@ -355,10 +355,12 @@ lobject_dealloc(PyObject* obj)
|
||||||
{
|
{
|
||||||
lobjectObject *self = (lobjectObject *)obj;
|
lobjectObject *self = (lobjectObject *)obj;
|
||||||
|
|
||||||
if (lobject_close(self) < 0)
|
if (self->conn) { /* if not, init failed */
|
||||||
PyErr_Print();
|
if (lobject_close(self) < 0)
|
||||||
Py_XDECREF((PyObject*)self->conn);
|
PyErr_Print();
|
||||||
PyMem_Free(self->smode);
|
Py_XDECREF((PyObject*)self->conn);
|
||||||
|
PyMem_Free(self->smode);
|
||||||
|
}
|
||||||
|
|
||||||
Dprintf("lobject_dealloc: deleted lobject object at %p, refcnt = "
|
Dprintf("lobject_dealloc: deleted lobject object at %p, refcnt = "
|
||||||
FORMAT_CODE_PY_SSIZE_T, obj, Py_REFCNT(obj));
|
FORMAT_CODE_PY_SSIZE_T, obj, Py_REFCNT(obj));
|
||||||
|
@ -372,10 +374,11 @@ lobject_init(PyObject *obj, PyObject *args, PyObject *kwds)
|
||||||
int oid = (int)InvalidOid, new_oid = (int)InvalidOid;
|
int oid = (int)InvalidOid, new_oid = (int)InvalidOid;
|
||||||
const char *smode = "";
|
const char *smode = "";
|
||||||
const char *new_file = NULL;
|
const char *new_file = NULL;
|
||||||
PyObject *conn;
|
PyObject *conn = NULL;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "O|iziz",
|
if (!PyArg_ParseTuple(args, "O!|iziz",
|
||||||
&conn, &oid, &smode, &new_oid, &new_file))
|
&connectionType, &conn,
|
||||||
|
&oid, &smode, &new_oid, &new_file))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return lobject_setup((lobjectObject *)obj,
|
return lobject_setup((lobjectObject *)obj,
|
||||||
|
|
|
@ -77,6 +77,10 @@ class LargeObjectTests(LargeObjectTestCase):
|
||||||
self.assertNotEqual(lo, None)
|
self.assertNotEqual(lo, None)
|
||||||
self.assertEqual(lo.mode[0], "w")
|
self.assertEqual(lo.mode[0], "w")
|
||||||
|
|
||||||
|
def test_connection_needed(self):
|
||||||
|
self.assertRaises(TypeError,
|
||||||
|
psycopg2.extensions.lobject, [])
|
||||||
|
|
||||||
def test_open_non_existent(self):
|
def test_open_non_existent(self):
|
||||||
# By creating then removing a large object, we get an Oid that
|
# By creating then removing a large object, we get an Oid that
|
||||||
# should be unused.
|
# should be unused.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user