mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-01-31 09:24:07 +03:00
Merge remote-tracking branch 'fix_lobject_mode'
This commit is contained in:
commit
bd34c86aba
|
@ -398,7 +398,7 @@ static int
|
|||
lobject_init(PyObject *obj, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
Oid oid = InvalidOid, new_oid = InvalidOid;
|
||||
const char *smode = "";
|
||||
const char *smode = NULL;
|
||||
const char *new_file = NULL;
|
||||
PyObject *conn = NULL;
|
||||
|
||||
|
@ -407,6 +407,9 @@ lobject_init(PyObject *obj, PyObject *args, PyObject *kwds)
|
|||
&oid, &smode, &new_oid, &new_file))
|
||||
return -1;
|
||||
|
||||
if (!smode)
|
||||
smode = "";
|
||||
|
||||
return lobject_setup((lobjectObject *)obj,
|
||||
(connectionObject *)conn, oid, smode, new_oid, new_file);
|
||||
}
|
||||
|
|
|
@ -110,6 +110,13 @@ class LargeObjectTests(LargeObjectTestCase):
|
|||
self.assertEqual(lo2.oid, lo.oid)
|
||||
self.assertEqual(lo2.closed, True)
|
||||
|
||||
def test_mode_defaults(self):
|
||||
lo = self.conn.lobject()
|
||||
lo2 = self.conn.lobject(mode=None)
|
||||
lo3 = self.conn.lobject(mode="")
|
||||
self.assertEqual(lo.mode, lo2.mode)
|
||||
self.assertEqual(lo.mode, lo3.mode)
|
||||
|
||||
def test_close_connection_gone(self):
|
||||
lo = self.conn.lobject()
|
||||
self.conn.close()
|
||||
|
|
Loading…
Reference in New Issue
Block a user