Changeset 645 for trunk


Ignore:
Timestamp:
Nov 27, 2015, 10:22:56 AM (4 years ago)
Author:
cito
Message:

Fixed small issue with large object

When an object was already unlinked, getting its attributes would
return without error, but leave an error indicator set. Also fixed
a similar issue with the destructor.

Location:
trunk/module
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/module/pgmodule.c

    r635 r645  
    604604largeDealloc(largeObject *self)
    605605{
    606         if (self->lo_fd >= 0 && check_cnx_obj(self->pgcnx))
     606        if (self->lo_fd >= 0 && self->pgcnx->valid)
    607607                lo_close(self->pgcnx->cnx, self->lo_fd);
    608608
     
    987987                        return (PyObject *) (self->pgcnx);
    988988                }
    989 
     989                PyErr_Clear();
    990990                Py_INCREF(Py_None);
    991991                return Py_None;
     
    997997                if (check_lo_obj(self, 0))
    998998                        return PyInt_FromLong(self->lo_oid);
    999 
     999                PyErr_Clear();
    10001000                Py_INCREF(Py_None);
    10011001                return Py_None;
  • trunk/module/tests/test_classic_largeobj.py

    r640 r645  
    363363        # unlinking when object is still open
    364364        self.obj.open(pg.INV_WRITE)
     365        self.assertIsNotNone(self.obj.oid)
     366        self.assertNotEqual(0, self.obj.oid)
    365367        self.assertRaises(IOError, unlink)
    366368        data = b'some data to be sold'
    367369        self.obj.write(data)
    368370        self.obj.close()
    369         oid = self.obj.oid
    370         self.assertIsInstance(oid, int)
    371         self.assertNotEqual(oid, 0)
    372         obj = self.pgcnx.getlo(oid)
    373         try:
    374             self.assertIsNot(obj, self.obj)
    375             self.assertEqual(obj.oid, oid)
    376             obj.open(pg.INV_READ)
    377             r = obj.read(80)
    378             obj.close()
    379             self.assertIsInstance(r, bytes)
    380             self.assertEqual(r, data)
    381         finally:
    382             del obj
     371        # unlinking after object has been closed
    383372        unlink()
    384         try:
    385             self.assertIsNone(self.obj.oid)
    386         except SystemError:
    387             pass
     373        self.assertIsNone(self.obj.oid)
    388374
    389375    def testSize(self):
Note: See TracChangeset for help on using the changeset viewer.