[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[minion-cvs] Python2.3-related fixes



Update of /home/minion/cvsroot/src/minion/lib/mixminion
In directory moria.mit.edu:/tmp/cvs-serv3035/lib/mixminion

Modified Files:
	Common.py Packet.py 
Log Message:
Python2.3-related fixes

Index: Common.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Common.py,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -d -r1.58 -r1.59
--- Common.py	12 Feb 2003 01:21:46 -0000	1.58
+++ Common.py	12 Feb 2003 01:36:22 -0000	1.59
@@ -576,7 +576,16 @@
     """Given a time_t 'when', return the smallest time_t > when that falls
        on midnight, GMT."""
     yyyy,MM,dd = time.gmtime(when)[0:3]
-    return calendar.timegm((yyyy,MM,dd+1,0,0,0,0,0,0))
+    try:
+        return calendar.timegm((yyyy,MM,dd+1,0,0,0,0,0,0))
+    except ValueError:
+        # Python 2.3 seems to raise ValueError when dd is the last day of the
+        # month.
+        pass
+    if MM < 12:
+        return calendar.timegm((yyyy,MM+1,1,0,0,0,0,0,0))
+    else:
+        return calendar.timegm((yyyy+1,1,1,0,0,0,0,0,0))
 
 def formatTime(when,localtime=0):
     """Given a time in seconds since the epoch, returns a time value in the

Index: Packet.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Packet.py,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- Packet.py	11 Feb 2003 22:18:13 -0000	1.30
+++ Packet.py	12 Feb 2003 01:36:22 -0000	1.31
@@ -805,6 +805,8 @@
             raise CompressedDataTooLong()
         except zlibutil.DecompressError, e:
             raise ParseError("Error in compressed data: %s"%e)
+        except (IOError, ValueError), e:
+            raise ParseError("Error in compressed data: %s"%e)
 
     try:
         # We can't just call zlib.decompress(payload), since we may
@@ -828,6 +830,8 @@
         return d
     except zlib.error:
         raise ParseError("Error in compressed data")
+    except (IOError, ValueError), e:
+        raise ParseError("Error in compressed data: %s"%e)
 
 def _validateZlib():
     """Internal function:  Make sure that zlib is a recognized version, and