[Python-checkins] python/dist/src/Lib/bsddb __init__.py, 1.5.10.1,
1.5.10.2
rhettinger at users.sourceforge.net
rhettinger at users.sourceforge.net
Sun Sep 21 00:51:48 EDT 2003
Update of /cvsroot/python/python/dist/src/Lib/bsddb
In directory sc8-pr-cvs1:/tmp/cvs-serv19704
Modified Files:
Tag: release23-maint
__init__.py
Log Message:
Backport Greg's patch (1.7 to 1.8) for backwards code compatability.
Index: __init__.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/bsddb/__init__.py,v
retrieving revision 1.5.10.1
retrieving revision 1.5.10.2
diff -C2 -d -r1.5.10.1 -r1.5.10.2
*** __init__.py 16 Sep 2003 21:42:13 -0000 1.5.10.1
--- __init__.py 21 Sep 2003 04:51:46 -0000 1.5.10.2
***************
*** 53,59 ****
#----------------------------------------------------------------------
import UserDict
! class _DBWithCursor(UserDict.DictMixin):
"""
A simple wrapper around DB that makes it look like the bsddbobject in
--- 53,88 ----
#----------------------------------------------------------------------
+ import sys
+
+ # for backwards compatibility with python versions older than 2.3, the
+ # iterator interface is dynamically defined and added using a mixin
+ # class. old python can't tokenize it due to the yield keyword.
+ if sys.version >= '2.3':
+ exec """
import UserDict
+ class _iter_mixin(UserDict.DictMixin):
+ def __iter__(self):
+ try:
+ yield self.first()[0]
+ next = self.next
+ while 1:
+ yield next()[0]
+ except _bsddb.DBNotFoundError:
+ return
! def iteritems(self):
! try:
! yield self.first()
! next = self.next
! while 1:
! yield next()
! except _bsddb.DBNotFoundError:
! return
! """
! else:
! class _iter_mixin: pass
!
!
! class _DBWithCursor(_iter_mixin):
"""
A simple wrapper around DB that makes it look like the bsddbobject in
***************
*** 146,166 ****
return self.db.sync()
- def __iter__(self):
- try:
- yield self.first()[0]
- next = self.next
- while 1:
- yield next()[0]
- except _bsddb.DBNotFoundError:
- return
-
- def iteritems(self):
- try:
- yield self.first()
- next = self.next
- while 1:
- yield next()
- except _bsddb.DBNotFoundError:
- return
#----------------------------------------------------------------------
--- 175,178 ----
More information about the Python-checkins
mailing list