[Python-checkins] python/dist/src/Lib/bsddb __init__.py,1.3,1.4 dbshelve.py,1.4,1.5 dbtables.py,1.6,1.7 dbutils.py,1.5,1.6

bwarsaw@users.sourceforge.net bwarsaw@users.sourceforge.net
Tue, 28 Jan 2003 09:20:45 -0800


Update of /cvsroot/python/python/dist/src/Lib/bsddb
In directory sc8-pr-cvs1:/tmp/cvs-serv17192

Modified Files:
	__init__.py dbshelve.py dbtables.py dbutils.py 
Log Message:
Everything worked in both the distutils distro and in Python 2.3cvs,
so merge from the bsddb-bsddb3-schizo-branch back to the trunk.


Index: __init__.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/bsddb/__init__.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** __init__.py	30 Dec 2002 20:52:07 -0000	1.3
--- __init__.py	28 Jan 2003 17:20:41 -0000	1.4
***************
*** 45,53 ****
      raise
      
! # bsddb3 calls it _db
! _db = _bsddb
! __version__ = _db.__version__
  
! error = _db.DBError  # So bsddb.error will mean something...
  
  #----------------------------------------------------------------------
--- 45,53 ----
      raise
      
! # bsddb3 calls it db, but provide _db for backwards compatibility
! db = _db = _bsddb
! __version__ = db.__version__
  
! error = db.DBError  # So bsddb.error will mean something...
  
  #----------------------------------------------------------------------
***************
*** 153,157 ****
  
      flags = _checkflag(flag)
!     d = _db.DB()
      d.set_flags(hflags)
      if cachesize is not None: d.set_cachesize(0, cachesize)
--- 153,157 ----
  
      flags = _checkflag(flag)
!     d = db.DB()
      d.set_flags(hflags)
      if cachesize is not None: d.set_cachesize(0, cachesize)
***************
*** 160,164 ****
      if ffactor is not None:   d.set_h_ffactor(ffactor)
      if nelem is not None:     d.set_h_nelem(nelem)
!     d.open(file, _db.DB_HASH, flags, mode)
      return _DBWithCursor(d)
  
--- 160,164 ----
      if ffactor is not None:   d.set_h_ffactor(ffactor)
      if nelem is not None:     d.set_h_nelem(nelem)
!     d.open(file, db.DB_HASH, flags, mode)
      return _DBWithCursor(d)
  
***************
*** 170,174 ****
  
      flags = _checkflag(flag)
!     d = _db.DB()
      if cachesize is not None: d.set_cachesize(0, cachesize)
      if pgsize is not None: d.set_pagesize(pgsize)
--- 170,174 ----
  
      flags = _checkflag(flag)
!     d = db.DB()
      if cachesize is not None: d.set_cachesize(0, cachesize)
      if pgsize is not None: d.set_pagesize(pgsize)
***************
*** 177,181 ****
      if minkeypage is not None: d.set_bt_minkey(minkeypage)
      if maxkeypage is not None: d.set_bt_maxkey(maxkeypage)
!     d.open(file, _db.DB_BTREE, flags, mode)
      return _DBWithCursor(d)
  
--- 177,181 ----
      if minkeypage is not None: d.set_bt_minkey(minkeypage)
      if maxkeypage is not None: d.set_bt_maxkey(maxkeypage)
!     d.open(file, db.DB_BTREE, flags, mode)
      return _DBWithCursor(d)
  
***************
*** 188,192 ****
  
      flags = _checkflag(flag)
!     d = _db.DB()
      if cachesize is not None: d.set_cachesize(0, cachesize)
      if pgsize is not None: d.set_pagesize(pgsize)
--- 188,192 ----
  
      flags = _checkflag(flag)
!     d = db.DB()
      if cachesize is not None: d.set_cachesize(0, cachesize)
      if pgsize is not None: d.set_pagesize(pgsize)
***************
*** 197,201 ****
      if source is not None: d.set_re_source(source)
      if pad is not None: d.set_re_pad(pad)
!     d.open(file, _db.DB_RECNO, flags, mode)
      return _DBWithCursor(d)
  
--- 197,201 ----
      if source is not None: d.set_re_source(source)
      if pad is not None: d.set_re_pad(pad)
!     d.open(file, db.DB_RECNO, flags, mode)
      return _DBWithCursor(d)
  
***************
*** 205,220 ****
  def _checkflag(flag):
      if flag == 'r':
!         flags = _db.DB_RDONLY
      elif flag == 'rw':
          flags = 0
      elif flag == 'w':
!         flags =  _db.DB_CREATE
      elif flag == 'c':
!         flags =  _db.DB_CREATE
      elif flag == 'n':
!         flags = _db.DB_CREATE | _db.DB_TRUNCATE
      else:
          raise error, "flags should be one of 'r', 'w', 'c' or 'n'"
!     return flags | _db.DB_THREAD
  
  #----------------------------------------------------------------------
--- 205,220 ----
  def _checkflag(flag):
      if flag == 'r':
!         flags = db.DB_RDONLY
      elif flag == 'rw':
          flags = 0
      elif flag == 'w':
!         flags =  db.DB_CREATE
      elif flag == 'c':
!         flags =  db.DB_CREATE
      elif flag == 'n':
!         flags = db.DB_CREATE | db.DB_TRUNCATE
      else:
          raise error, "flags should be one of 'r', 'w', 'c' or 'n'"
!     return flags | db.DB_THREAD
  
  #----------------------------------------------------------------------
***************
*** 232,236 ****
      del thread
  except ImportError:
!     _db.DB_THREAD = 0
  
  
--- 232,236 ----
      del thread
  except ImportError:
!     db.DB_THREAD = 0
  
  

Index: dbshelve.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/bsddb/dbshelve.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** dbshelve.py	30 Dec 2002 20:52:07 -0000	1.4
--- dbshelve.py	28 Jan 2003 17:20:42 -0000	1.5
***************
*** 31,35 ****
  
  import cPickle
! from bsddb import db
  
  #------------------------------------------------------------------------
--- 31,40 ----
  
  import cPickle
! try:
!     # For Python 2.3
!     from bsddb import db
! except ImportError:
!     # For earlier Pythons w/distutils pybsddb
!     from bsddb3 import db
  
  #------------------------------------------------------------------------

Index: dbtables.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/bsddb/dbtables.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** dbtables.py	30 Dec 2002 20:52:07 -0000	1.6
--- dbtables.py	28 Jan 2003 17:20:42 -0000	1.7
***************
*** 18,38 ****
  _cvsid = '$Id$'
  
- import string
- import sys
- try:
-     import cPickle
-     pickle = cPickle
- except ImportError:
-     import pickle
- import whrandom
- import xdrlib
  import re
  import copy
  
! from bsddb.db import *
  
  
! class TableDBError(StandardError): pass
! class TableAlreadyExists(TableDBError): pass
  
  
--- 18,41 ----
  _cvsid = '$Id$'
  
  import re
+ import sys
  import copy
+ import xdrlib
+ import whrandom
+ from types import ListType, StringType
+ import cPickle as pickle
  
! try:
!     # For Python 2.3
!     from bsddb.db import *
! except ImportError:
!     # For earlier Pythons w/distutils pybsddb
!     from bsddb3.db import *
  
  
! class TableDBError(StandardError):
!     pass
! class TableAlreadyExists(TableDBError):
!     pass
  
  
***************
*** 73,79 ****
          chars_to_escape = '.*+()[]?'
          for char in chars_to_escape :
!             likestr = string.replace(likestr, char, '\\'+char)
          # convert %s to wildcards
!         self.likestr = string.replace(likestr, '%', '.*')
          self.re = re.compile('^'+self.likestr+'$', re_flags)
      def __call__(self, s):
--- 76,82 ----
          chars_to_escape = '.*+()[]?'
          for char in chars_to_escape :
!             likestr = likestr.replace(char, '\\'+char)
          # convert %s to wildcards
!         self.likestr = likestr.replace('%', '.*')
          self.re = re.compile('^'+self.likestr+'$', re_flags)
      def __call__(self, s):
***************
*** 85,89 ****
  _table_names_key = '__TABLE_NAMES__'  # list of the tables in this db
  _columns = '._COLUMNS__'  # table_name+this key contains a list of columns
! def _columns_key(table) : return table + _columns
  
  #
--- 88,94 ----
  _table_names_key = '__TABLE_NAMES__'  # list of the tables in this db
  _columns = '._COLUMNS__'  # table_name+this key contains a list of columns
! 
! def _columns_key(table):
!     return table + _columns
  
  #
***************
*** 94,102 ****
                       # row in the table.  (no data is stored)
  _rowid_str_len = 8   # length in bytes of the unique rowid strings
! def _data_key(table, col, rowid) : return table + _data + col + _data + rowid
! def _search_col_data_key(table, col) : return table + _data + col + _data
! def _search_all_data_key(table) : return table + _data
! def _rowid_key(table, rowid) : return table + _rowid + rowid + _rowid
! def _search_rowid_key(table) : return table + _rowid
  
  def contains_metastrings(s) :
--- 99,117 ----
                       # row in the table.  (no data is stored)
  _rowid_str_len = 8   # length in bytes of the unique rowid strings
! 
! def _data_key(table, col, rowid):
!     return table + _data + col + _data + rowid
! 
! def _search_col_data_key(table, col):
!     return table + _data + col + _data
! 
! def _search_all_data_key(table):
!     return table + _data
! 
! def _rowid_key(table, rowid):
!     return table + _rowid + rowid + _rowid
! 
! def _search_rowid_key(table):
!     return table + _rowid
  
  def contains_metastrings(s) :
***************
*** 104,113 ****
      metadata strings that might interfere with dbtables database operation.
      """
!     if string.find(s, _table_names_key) >= 0 or \
!        string.find(s, _columns) >= 0 or \
!        string.find(s, _data) >= 0 or \
!        string.find(s, _rowid) >= 0 :
          return 1
!     else :
          return 0
  
--- 119,129 ----
      metadata strings that might interfere with dbtables database operation.
      """
!     if (s.find(_table_names_key) >= 0 or
!         s.find(_columns) >= 0 or
!         s.find(_data) >= 0 or
!         s.find(_rowid) >= 0):
!         # Then
          return 1
!     else:
          return 0
  
***************
*** 115,119 ****
  class bsdTableDB :
      def __init__(self, filename, dbhome, create=0, truncate=0, mode=0600,
!                  recover=0, dbflags=0) :
          """bsdTableDB.open(filename, dbhome, create=0, truncate=0, mode=0600)
          Open database name in the dbhome BerkeleyDB directory.
--- 131,135 ----
  class bsdTableDB :
      def __init__(self, filename, dbhome, create=0, truncate=0, mode=0600,
!                  recover=0, dbflags=0):
          """bsdTableDB.open(filename, dbhome, create=0, truncate=0, mode=0600)
          Open database name in the dbhome BerkeleyDB directory.
***************
*** 187,191 ****
          try:
              key, data = cur.first()
!             while 1 :
                  print `{key: data}`
                  next = cur.next()
--- 203,207 ----
          try:
              key, data = cur.first()
!             while 1:
                  print `{key: data}`
                  next = cur.next()
***************
*** 203,207 ****
          raises TableDBError if it already exists or for other DB errors.
          """
!         assert type(columns) == type([])
          txn = None
          try:
--- 219,223 ----
          raises TableDBError if it already exists or for other DB errors.
          """
!         assert isinstance(columns, ListType)
          txn = None
          try:
***************
*** 234,240 ****
              txn.commit()
              txn = None
- 
          except DBError, dberror:
!             if txn :
                  txn.abort()
              raise TableDBError, dberror[1]
--- 250,255 ----
              txn.commit()
              txn = None
          except DBError, dberror:
!             if txn:
                  txn.abort()
              raise TableDBError, dberror[1]
***************
*** 245,250 ****
          [] if the table doesn't exist.
          """
!         assert type(table) == type('')
!         if contains_metastrings(table) :
              raise ValueError, "bad table name: contains reserved metastrings"
  
--- 260,265 ----
          [] if the table doesn't exist.
          """
!         assert isinstance(table, StringType)
!         if contains_metastrings(table):
              raise ValueError, "bad table name: contains reserved metastrings"
  
***************
*** 274,278 ****
          all of its current columns.
          """
!         assert type(columns) == type([])
          try:
              self.CreateTable(table, columns)
--- 289,293 ----
          all of its current columns.
          """
!         assert isinstance(columns, ListType)
          try:
              self.CreateTable(table, columns)
***************
*** 332,336 ****
          """Create a new unique row identifier"""
          unique = 0
!         while not unique :
              # Generate a random 64-bit row ID string
              # (note: this code has <64 bits of randomness
--- 347,351 ----
          """Create a new unique row identifier"""
          unique = 0
!         while not unique:
              # Generate a random 64-bit row ID string
              # (note: this code has <64 bits of randomness
***************
*** 359,370 ****
          txn = None
          try:
!             if not self.db.has_key(_columns_key(table)) :
                  raise TableDBError, "unknown table"
  
              # check the validity of each column name
!             if not self.__tablecolumns.has_key(table) :
                  self.__load_column_info(table)
              for column in rowdict.keys() :
!                 if not self.__tablecolumns[table].count(column) :
                      raise TableDBError, "unknown column: "+`column`
  
--- 374,385 ----
          txn = None
          try:
!             if not self.db.has_key(_columns_key(table)):
                  raise TableDBError, "unknown table"
  
              # check the validity of each column name
!             if not self.__tablecolumns.has_key(table):
                  self.__load_column_info(table)
              for column in rowdict.keys() :
!                 if not self.__tablecolumns[table].count(column):
                      raise TableDBError, "unknown column: "+`column`
  
***************
*** 374,378 ****
  
              # insert the row values into the table database
!             for column, dataitem in rowdict.items() :
                  # store the value
                  self.db.put(_data_key(table, column, rowid), dataitem, txn=txn)
--- 389,393 ----
  
              # insert the row values into the table database
!             for column, dataitem in rowdict.items():
                  # store the value
                  self.db.put(_data_key(table, column, rowid), dataitem, txn=txn)
***************
*** 393,397 ****
  
  
!     def Modify(self, table, conditions={}, mappings={}) :
          """Modify(table, conditions) - Modify in rows matching 'conditions'
          using mapping functions in 'mappings'
--- 408,412 ----
  
  
!     def Modify(self, table, conditions={}, mappings={}):
          """Modify(table, conditions) - Modify in rows matching 'conditions'
          using mapping functions in 'mappings'
***************
*** 408,415 ****
              # modify only requested columns
              columns = mappings.keys()
!             for rowid in matching_rowids.keys() :
                  txn = None
                  try:
!                     for column in columns :
                          txn = self.env.txn_begin()
                          # modify the requested column
--- 423,430 ----
              # modify only requested columns
              columns = mappings.keys()
!             for rowid in matching_rowids.keys():
                  txn = None
                  try:
!                     for column in columns:
                          txn = self.env.txn_begin()
                          # modify the requested column
***************
*** 434,438 ****
  
                  except DBError, dberror:
!                     if txn :
                          txn.abort()
                      raise
--- 449,453 ----
  
                  except DBError, dberror:
!                     if txn:
                          txn.abort()
                      raise
***************
*** 441,445 ****
              raise TableDBError, dberror[1]
  
!     def Delete(self, table, conditions={}) :
          """Delete(table, conditions) - Delete items matching the given
          conditions from the table.
--- 456,460 ----
              raise TableDBError, dberror[1]
  
!     def Delete(self, table, conditions={}):
          """Delete(table, conditions) - Delete items matching the given
          conditions from the table.
***************
*** 453,461 ****
              # delete row data from all columns
              columns = self.__tablecolumns[table]
!             for rowid in matching_rowids.keys() :
                  txn = None
                  try:
                      txn = self.env.txn_begin()
!                     for column in columns :
                          # delete the data key
                          try:
--- 468,476 ----
              # delete row data from all columns
              columns = self.__tablecolumns[table]
!             for rowid in matching_rowids.keys():
                  txn = None
                  try:
                      txn = self.env.txn_begin()
!                     for column in columns:
                          # delete the data key
                          try:
***************
*** 474,486 ****
                      txn = None
                  except DBError, dberror:
!                     if txn :
                          txn.abort()
                      raise
- 
          except DBError, dberror:
              raise TableDBError, dberror[1]
  
  
!     def Select(self, table, columns, conditions={}) :
          """Select(table, conditions) - retrieve specific row data
          Returns a list of row column->value mapping dictionaries.
--- 489,500 ----
                      txn = None
                  except DBError, dberror:
!                     if txn:
                          txn.abort()
                      raise
          except DBError, dberror:
              raise TableDBError, dberror[1]
  
  
!     def Select(self, table, columns, conditions={}):
          """Select(table, conditions) - retrieve specific row data
          Returns a list of row column->value mapping dictionaries.
***************
*** 492,508 ****
          """
          try:
!             if not self.__tablecolumns.has_key(table) :
                  self.__load_column_info(table)
!             if columns is None :
                  columns = self.__tablecolumns[table]
              matching_rowids = self.__Select(table, columns, conditions)
          except DBError, dberror:
              raise TableDBError, dberror[1]
- 
          # return the matches as a list of dictionaries
          return matching_rowids.values()
  
  
!     def __Select(self, table, columns, conditions) :
          """__Select() - Used to implement Select and Delete (above)
          Returns a dictionary keyed on rowids containing dicts
--- 506,521 ----
          """
          try:
!             if not self.__tablecolumns.has_key(table):
                  self.__load_column_info(table)
!             if columns is None:
                  columns = self.__tablecolumns[table]
              matching_rowids = self.__Select(table, columns, conditions)
          except DBError, dberror:
              raise TableDBError, dberror[1]
          # return the matches as a list of dictionaries
          return matching_rowids.values()
  
  
!     def __Select(self, table, columns, conditions):
          """__Select() - Used to implement Select and Delete (above)
          Returns a dictionary keyed on rowids containing dicts
***************
*** 514,523 ****
          """
          # check the validity of each column name
!         if not self.__tablecolumns.has_key(table) :
              self.__load_column_info(table)
!         if columns is None :
              columns = self.tablecolumns[table]
!         for column in (columns + conditions.keys()) :
!             if not self.__tablecolumns[table].count(column) :
                  raise TableDBError, "unknown column: "+`column`
  
--- 527,536 ----
          """
          # check the validity of each column name
!         if not self.__tablecolumns.has_key(table):
              self.__load_column_info(table)
!         if columns is None:
              columns = self.tablecolumns[table]
!         for column in (columns + conditions.keys()):
!             if not self.__tablecolumns[table].count(column):
                  raise TableDBError, "unknown column: "+`column`
  
***************
*** 525,530 ****
          # column names containing the data for that row and column.
          matching_rowids = {}
! 
!         rejected_rowids = {} # keys are rowids that do not match
  
          # attempt to sort the conditions in such a way as to minimize full
--- 538,543 ----
          # column names containing the data for that row and column.
          matching_rowids = {}
!         # keys are rowids that do not match
!         rejected_rowids = {}
  
          # attempt to sort the conditions in such a way as to minimize full
***************
*** 533,537 ****
              a = atuple[1]
              b = btuple[1]
!             if type(a) == type(b) :
                  if isinstance(a, PrefixCond) and isinstance(b, PrefixCond):
                      # longest prefix first
--- 546,550 ----
              a = atuple[1]
              b = btuple[1]
!             if type(a) is type(b):
                  if isinstance(a, PrefixCond) and isinstance(b, PrefixCond):
                      # longest prefix first
***************
*** 558,586 ****
          cur = self.db.cursor()
          column_num = -1
!         for column, condition in conditionlist :
              column_num = column_num + 1
              searchkey = _search_col_data_key(table, column)
              # speedup: don't linear search columns within loop
!             if column in columns :
                  savethiscolumndata = 1  # save the data for return
!             else :
                  savethiscolumndata = 0  # data only used for selection
  
              try:
                  key, data = cur.set_range(searchkey)
!                 while key[:len(searchkey)] == searchkey :
                      # extract the rowid from the key
                      rowid = key[-_rowid_str_len:]
  
!                     if not rejected_rowids.has_key(rowid) :
                          # if no condition was specified or the condition
                          # succeeds, add row to our match list.
!                         if not condition or condition(data) :
!                             if not matching_rowids.has_key(rowid) :
                                  matching_rowids[rowid] = {}
!                             if savethiscolumndata :
                                  matching_rowids[rowid][column] = data
!                         else :
!                             if matching_rowids.has_key(rowid) :
                                  del matching_rowids[rowid]
                              rejected_rowids[rowid] = rowid
--- 571,599 ----
          cur = self.db.cursor()
          column_num = -1
!         for column, condition in conditionlist:
              column_num = column_num + 1
              searchkey = _search_col_data_key(table, column)
              # speedup: don't linear search columns within loop
!             if column in columns:
                  savethiscolumndata = 1  # save the data for return
!             else:
                  savethiscolumndata = 0  # data only used for selection
  
              try:
                  key, data = cur.set_range(searchkey)
!                 while key[:len(searchkey)] == searchkey:
                      # extract the rowid from the key
                      rowid = key[-_rowid_str_len:]
  
!                     if not rejected_rowids.has_key(rowid):
                          # if no condition was specified or the condition
                          # succeeds, add row to our match list.
!                         if not condition or condition(data):
!                             if not matching_rowids.has_key(rowid):
                                  matching_rowids[rowid] = {}
!                             if savethiscolumndata:
                                  matching_rowids[rowid][column] = data
!                         else:
!                             if matching_rowids.has_key(rowid):
                                  del matching_rowids[rowid]
                              rejected_rowids[rowid] = rowid
***************
*** 589,593 ****
  
              except DBError, dberror:
!                 if dberror[0] != DB_NOTFOUND :
                      raise
                  continue
--- 602,606 ----
  
              except DBError, dberror:
!                 if dberror[0] != DB_NOTFOUND:
                      raise
                  continue
***************
*** 600,607 ****
          # extract any remaining desired column data from the
          # database for the matching rows.
!         if len(columns) > 0 :
!             for rowid, rowdata in matching_rowids.items() :
!                 for column in columns :
!                     if rowdata.has_key(column) :
                          continue
                      try:
--- 613,620 ----
          # extract any remaining desired column data from the
          # database for the matching rows.
!         if len(columns) > 0:
!             for rowid, rowdata in matching_rowids.items():
!                 for column in columns:
!                     if rowdata.has_key(column):
                          continue
                      try:
***************
*** 609,613 ****
                              _data_key(table, column, rowid))
                      except DBError, dberror:
!                         if dberror[0] != DB_NOTFOUND :
                              raise
                          rowdata[column] = None
--- 622,626 ----
                              _data_key(table, column, rowid))
                      except DBError, dberror:
!                         if dberror[0] != DB_NOTFOUND:
                              raise
                          rowdata[column] = None
***************
*** 617,623 ****
  
  
!     def Drop(self, table) :
!         """Remove an entire table from the database
!         """
          txn = None
          try:
--- 630,635 ----
  
  
!     def Drop(self, table):
!         """Remove an entire table from the database"""
          txn = None
          try:
***************
*** 631,635 ****
              # delete all keys containing this tables column and row info
              table_key = _search_all_data_key(table)
!             while 1 :
                  try:
                      key, data = cur.set_range(table_key)
--- 643,647 ----
              # delete all keys containing this tables column and row info
              table_key = _search_all_data_key(table)
!             while 1:
                  try:
                      key, data = cur.set_range(table_key)
***************
*** 637,641 ****
                      break
                  # only delete items in this table
!                 if key[:len(table_key)] != table_key :
                      break
                  cur.delete()
--- 649,653 ----
                      break
                  # only delete items in this table
!                 if key[:len(table_key)] != table_key:
                      break
                  cur.delete()
***************
*** 643,647 ****
              # delete all rowids used by this table
              table_key = _search_rowid_key(table)
!             while 1 :
                  try:
                      key, data = cur.set_range(table_key)
--- 655,659 ----
              # delete all rowids used by this table
              table_key = _search_rowid_key(table)
!             while 1:
                  try:
                      key, data = cur.set_range(table_key)
***************
*** 649,653 ****
                      break
                  # only delete items in this table
!                 if key[:len(table_key)] != table_key :
                      break
                  cur.delete()
--- 661,665 ----
                      break
                  # only delete items in this table
!                 if key[:len(table_key)] != table_key:
                      break
                  cur.delete()
***************
*** 670,678 ****
              txn = None
  
!             if self.__tablecolumns.has_key(table) :
                  del self.__tablecolumns[table]
  
          except DBError, dberror:
!             if txn :
                  txn.abort()
              raise TableDBError, dberror[1]
--- 682,690 ----
              txn = None
  
!             if self.__tablecolumns.has_key(table):
                  del self.__tablecolumns[table]
  
          except DBError, dberror:
!             if txn:
                  txn.abort()
              raise TableDBError, dberror[1]

Index: dbutils.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/bsddb/dbutils.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** dbutils.py	30 Dec 2002 20:52:08 -0000	1.5
--- dbutils.py	28 Jan 2003 17:20:42 -0000	1.6
***************
*** 27,31 ****
  from time import sleep as _sleep
  
! from bsddb import _db
  
  # always sleep at least N seconds between retrys
--- 27,36 ----
  from time import sleep as _sleep
  
! try:
!     # For Python 2.3
!     from bsddb import db
! except ImportError:
!     # For earlier Pythons w/distutils pybsddb
!     from bsddb3 import db
  
  # always sleep at least N seconds between retrys
***************
*** 61,65 ****
          try:
              return function(*_args, **_kwargs)
!         except _db.DBLockDeadlockError:
              if _deadlock_VerboseFile:
                  _deadlock_VerboseFile.write(
--- 66,70 ----
          try:
              return function(*_args, **_kwargs)
!         except db.DBLockDeadlockError:
              if _deadlock_VerboseFile:
                  _deadlock_VerboseFile.write(