[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[minion-cvs] Reduce pychecker warnings, fixing a few typos in the pr...



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

Modified Files:
	BuildMessage.py ClientMain.py Common.py Config.py Packet.py 
	benchmark.py 
Log Message:
Reduce pychecker warnings, fixing a few typos in the process

Index: BuildMessage.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/BuildMessage.py,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- BuildMessage.py	17 May 2003 00:08:41 -0000	1.45
+++ BuildMessage.py	28 May 2003 06:37:30 -0000	1.46
@@ -270,7 +270,7 @@
 # MESSAGE DECODING
 
 def decodePayload(payload, tag, key=None,
-                  userKeys={}):
+                  userKeys=None):
     """Given a 28K payload and a 20-byte decoding tag, attempt to decode and
        decompress the original message.
 
@@ -282,7 +282,9 @@
        might be able to decrypt the payload given more/different keys,
        we return None.  If the payload is corrupt, we raise MixError.
     """
-    if type(userKeys) is types.StringType:
+    if userKeys is None:
+        userKeys = {}
+    elif type(userKeys) is types.StringType:
         userKeys = { "" : userKeys }
 
     if len(payload) != PAYLOAD_LEN or len(tag) != TAG_LEN:

Index: ClientMain.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/ClientMain.py,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -d -r1.77 -r1.78
--- ClientMain.py	28 May 2003 05:27:11 -0000	1.77
+++ ClientMain.py	28 May 2003 06:37:32 -0000	1.78
@@ -20,7 +20,6 @@
 import signal
 import socket
 import stat
-import string
 import sys
 import time
 import urllib2
@@ -739,7 +738,7 @@
     path = []
     for ent in p:
         if re.match(r'\*(\d+)', ent):
-            path.extend(("?")*string.atoi(ent[1:]))
+            path.extend(("?")* int(ent[1:]))
         else:
             path.append(ent)
 
@@ -1577,7 +1576,6 @@
         """
         #XXXX004 write unit tests
         results = []
-        idx = 0
         for msg in parseTextEncodedMessages(s, force=force):
             if msg.isOvercompressed() and not force:
                 LOG.warn("Message is a possible zlib bomb; not uncompressing")

Index: Common.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Common.py,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -d -r1.79 -r1.80
--- Common.py	28 May 2003 04:53:34 -0000	1.79
+++ Common.py	28 May 2003 06:37:32 -0000	1.80
@@ -262,6 +262,8 @@
         
         s = s[mEnd.end()+1:]
 
+    raise MixFatalError("Unreachable code somehow reached.")
+
 #----------------------------------------------------------------------
 def checkPrivateFile(fn, fix=1):
     """Checks whether f is a file owned by this uid, set to mode 0600 or

Index: Config.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Config.py,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- Config.py	28 May 2003 05:26:47 -0000	1.43
+++ Config.py	28 May 2003 06:37:32 -0000	1.44
@@ -128,7 +128,7 @@
         num = float(num)
     else:
         num = int(num)
-    nsec = num * _seconds_per_unit[unit]
+    nsec = int(num * _seconds_per_unit[unit])
     return mixminion.Common.Duration(nsec,
                     _canonical_unit_names.get(unit,unit), num)
 

Index: Packet.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Packet.py,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- Packet.py	25 May 2003 17:07:31 -0000	1.43
+++ Packet.py	28 May 2003 06:37:35 -0000	1.44
@@ -405,20 +405,23 @@
             s = s[1:]
         if not s:
             break
-        block, length = parseReplyBlock(s, allowMore=1, returnLen=1)
+        block, length = _parseReplyBlock(s)
         blocks.append(block)
         s = s[length:]
     return blocks
 
-def parseReplyBlock(s, allowMore=0, returnLen=0):
+def parseReplyBlock(s):
     """Return a new ReplyBlock object for an encoded reply block.
-       If allowMore is true, accept a string that only begins with a
-       reply block.  If returnLen is true, return a 2-tuple of the
-       reply block, and its length when encoded.
 
        Raise ParseError on failure.
     """
+    block, length = _parseReplyBlock(s)
+    if length > len(s):
+        raise ParseError("Misformatted reply block: extra data.")
+    return block
 
+def _parseReplyBlock(s):
+    """DOCDOC"""
     if len(s) < MIN_RB_LEN:
         raise ParseError("Reply block too short")
     try:
@@ -436,16 +439,10 @@
 
     ri = s[MIN_RB_LEN:]
     length = rlen + MIN_RB_LEN
-    if allowMore:
-        ri = ri[:rlen]
-    elif len(ri) != rlen:
-        raise ParseError("Misformatted reply block")
+    ri = ri[:rlen]
 
     surb =  ReplyBlock(header, timestamp, rt, ri, key)
-    if returnLen:
-        return surb, length
-    else:
-        return surb
+    return surb, length
 
 class ReplyBlock:
     """A mixminion reply block, including the address of the first hop

Index: benchmark.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/benchmark.py,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- benchmark.py	26 May 2003 20:04:19 -0000	1.35
+++ benchmark.py	28 May 2003 06:37:35 -0000	1.36
@@ -820,8 +820,8 @@
     while 1:
         if 1:
             context = _ml.TLSContext_new(fn, p, dh)
-            s1 = context.sock(0, 0)
-            s2 = context.sock(0, 1)
+            _ = context.sock(0, 0)
+            _ = context.sock(0, 1)
 
 def testLeaks5():
     from mixminion.test import _getMMTPServer
@@ -842,7 +842,7 @@
     import mixminion.MMTPClient
     routing = IPV4Info("127.0.0.1", TEST_PORT, None)
 
-    msg = "X" * 32 * 1024
+    #msg = "X" * 32 * 1024
     n = 0
     while 1:
         mixminion.MMTPClient.sendMessages(routing, [])