Bugs item #1210377, was opened at 2005-05-28 12:48 Message generated for change (Comment added) made by gbrandl You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1210377&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Library Group: Python 2.4 >Status: Closed >Resolution: Fixed Priority: 5 Submitted By: Ragnar Ouchterlony (ragnar) Assigned to: Nobody/Anonymous (nobody) Summary: Cursors not correctly closed after exception. Initial Comment: If an exception occurs when going through a database, the cursors will not be correctly reset. If I manually set the cursor to None (by doing db.dbc = None) it will work fine. >>> db = bsddb.btopen('/tmp/test.db', 'c') >>> db.first() Traceback (most recent call last): File "<stdin>", line 1, in ? File "/usr/lib/python2.4/bsddb/__init__.py", line 264, in first rv = self.dbc.first() _bsddb.DBNotFoundError: (-30990, 'DB_NOTFOUND: No matching key/data pair found') >>> db['foo'] = 'bar' Traceback (most recent call last): File "<stdin>", line 1, in ? File "/usr/lib/python2.4/bsddb/__init__.py", line 217, in __setitem__ self._closeCursors() File "/usr/lib/python2.4/bsddb/__init__.py", line 192, in _closeCursors self.saved_dbc_key = c.current(0,0,0)[0] bsddb._db.DBInvalidArgError: (22, 'Invalid argument -- Cursor position must be set before performing this operation') Here, I first open a new database. Since it is empty, db.first() will fail. When I after that try to add a key/value pair to the database it fails, since it tries to close an invalid cursor. >>> db = bsddb.btopen('/tmp/test.db', 'c') >>> db.first() Traceback (most recent call last): File "<stdin>", line 1, in ? File "/usr/lib/python2.4/bsddb/__init__.py", line 264, in first rv = self.dbc.first() _bsddb.DBNotFoundError: (-30990, 'DB_NOTFOUND: No matching key/data pair found') >>> db.dbc = None >>> db['foo'] = 'bar' >>> db {'foo': 'bar'} Here I do "db.dbc = None" after the exception and now it works just fine. ---------------------------------------------------------------------- >Comment By: Georg Brandl (gbrandl) Date: 2006-02-20 20:30 Message: Logged In: YES user_id=849994 Fixed in rev. 42525, 42526. ---------------------------------------------------------------------- Comment By: Ragnar Ouchterlony (ragnar) Date: 2005-05-30 07:59 Message: Logged In: YES user_id=1394 The bugreport refers to bsddb. I did not make that entirely clear. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1210377&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com