Log message for revision 117168:
  Backported c115442, 115445 and 115501 from trunk to deal with changes in ZODB 
3.9.6
  

Changed:
  U   Zope/branches/2.12/doc/CHANGES.rst
  U   Zope/branches/2.12/src/Products/PluginIndexes/DateIndex/DateIndex.py
  U   
Zope/branches/2.12/src/Products/PluginIndexes/DateRangeIndex/DateRangeIndex.py

-=-
Modified: Zope/branches/2.12/doc/CHANGES.rst
===================================================================
--- Zope/branches/2.12/doc/CHANGES.rst  2010-10-02 10:41:21 UTC (rev 117167)
+++ Zope/branches/2.12/doc/CHANGES.rst  2010-10-02 10:51:51 UTC (rev 117168)
@@ -11,6 +11,9 @@
 Bugs Fixed
 ++++++++++
 
+- Adjusted overflow logic in DateIndex and DateRangeIndex to work with latest
+  ZODB 3.9.7.
+
 - Fixed ``testZODBCompat`` tests in ZopeTestCase to match modern ZODB
   semantics.
 

Modified: Zope/branches/2.12/src/Products/PluginIndexes/DateIndex/DateIndex.py
===================================================================
--- Zope/branches/2.12/src/Products/PluginIndexes/DateIndex/DateIndex.py        
2010-10-02 10:41:21 UTC (rev 117167)
+++ Zope/branches/2.12/src/Products/PluginIndexes/DateIndex/DateIndex.py        
2010-10-02 10:51:51 UTC (rev 117168)
@@ -53,7 +53,9 @@
     DSTOFFSET = STDOFFSET
 
 DSTDIFF = DSTOFFSET - STDOFFSET
+MAX32 = int(2**31 - 1)
 
+
 class LocalTimezone(tzinfo):
 
     def utcoffset(self, dt):
@@ -262,9 +264,9 @@
 
         t_val = ( ( ( ( yr * 12 + mo ) * 31 + dy ) * 24 + hr ) * 60 + mn )
 
-        if isinstance(t_val, long):
-            # t_val must be IntType, not LongType
-            raise OverflowError, (
+        if t_val > MAX32:
+            # t_val must be integer fitting in the 32bit range
+            raise OverflowError(
                 "%s is not within the range of indexable dates (index: %s)"
                 % (value, self.id))
 

Modified: 
Zope/branches/2.12/src/Products/PluginIndexes/DateRangeIndex/DateRangeIndex.py
===================================================================
--- 
Zope/branches/2.12/src/Products/PluginIndexes/DateRangeIndex/DateRangeIndex.py  
    2010-10-02 10:41:21 UTC (rev 117167)
+++ 
Zope/branches/2.12/src/Products/PluginIndexes/DateRangeIndex/DateRangeIndex.py  
    2010-10-02 10:51:51 UTC (rev 117168)
@@ -40,6 +40,7 @@
 from Products.PluginIndexes.interfaces import IDateRangeIndex
 
 _dtmldir = os.path.join( package_home( globals() ), 'dtml' )
+MAX32 = int(2**31 - 1)
 
 
 class DateRangeIndex(UnIndex):
@@ -421,7 +422,8 @@
         elif isinstance(value, DateTime):
             value = value.millis() / 1000 / 60 # flatten to minutes
         result = int( value )
-        if isinstance(result, long): # this won't work (Python 2.3)
+        if result > MAX32:
+            # t_val must be integer fitting in the 32bit range
             raise OverflowError( '%s is not within the range of dates allowed'
                               'by a DateRangeIndex' % value)
         return result

_______________________________________________
Zope-Checkins maillist  -  Zope-Checkins@zope.org
https://mail.zope.org/mailman/listinfo/zope-checkins

Reply via email to