Commit 738f6381 authored by Chris McDonough's avatar Chris McDonough

Deal with the fact that in Python 2.3, int can return a long instead of

throwing OverflowError.
parent c972c757
......@@ -11,7 +11,7 @@
#
##############################################################################
"""$Id: DateIndex.py,v 1.12 2003/06/17 19:01:06 sidnei Exp $
"""$Id: DateIndex.py,v 1.13 2003/11/04 22:09:03 chrism Exp $
"""
from types import StringType, FloatType, IntType
......@@ -190,14 +190,14 @@ class DateIndex(UnIndex):
t_val = ( ( ( ( yr * 12 + mo ) * 31 + dy ) * 24 + hr ) * 60 + mn )
try:
if isinstance(t_val, long):
# t_val must be IntType, not LongType
return int(t_val)
except OverflowError:
raise OverflowError, (
"%s is not within the range of indexable dates (index: %s)"
% (value, self.id))
return t_val
manage_addDateIndexForm = DTMLFile( 'dtml/addDateIndex', globals() )
......
......@@ -38,14 +38,14 @@ class Dummy:
class DI_Tests(unittest.TestCase):
def setUp(self):
self._values = (
(0, Dummy('a', None)),
(1, Dummy('b', DateTime(0))),
(2, Dummy('c', DateTime('2002-05-08 15:16:17'))),
(3, Dummy('d', DateTime('2032-05-08 15:16:17'))),
(4, Dummy('e', DateTime('2062-05-08 15:16:17'))),
(5, Dummy('e', DateTime('2062-05-08 15:16:17'))),
(6, Dummy('f', 1072742620.0)),
(7, Dummy('f', 1072742900)),
(0, Dummy('a', None)), # None
(1, Dummy('b', DateTime(0))), # 1055335680
(2, Dummy('c', DateTime('2002-05-08 15:16:17'))), # 1072667236
(3, Dummy('d', DateTime('2032-05-08 15:16:17'))), # 1088737636
(4, Dummy('e', DateTime('2062-05-08 15:16:17'))), # 1018883325
(5, Dummy('e', DateTime('2062-05-08 15:16:17'))), # 1018883325
(6, Dummy('f', 1072742620.0)), # 1073545923
(7, Dummy('f', 1072742900)), # 1073545928
)
self._index = DateIndex('date')
self._noop_req = {'bar': 123}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment