Commit 3fe5cad0 authored by Jelte Jansen's avatar Jelte Jansen

addressed first 3 comments in #22


git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac22@3377 e5f2f494-b856-4b98-b285-d166d9295462
parent dd47ffa1
......@@ -31,10 +31,8 @@ def remove_identical(a, b):
to_remove = []
if type(a) != dict or type(b) != dict:
raise DataTypeError("Not a dict in remove_identical()")
for ka in a.keys():
if ka in b and a[ka] == b[ka]:
to_remove.append(ka)
for id in to_remove:
duplicate_keys = [key for key in a.keys() if key in b and a[key] == b[key]]
for id in duplicate_keys:
del(a[id])
def merge(orig, new):
......
......@@ -78,6 +78,8 @@ class Session:
raise SessionError("Session has been closed.")
if type(env) == dict:
env = isc.cc.message.to_wire(env)
if len(env) > 65535:
raise ProtocolError("Envelope too large")
if type(msg) == dict:
msg = isc.cc.message.to_wire(msg)
self._socket.setblocking(1)
......@@ -113,9 +115,6 @@ class Session:
if (seq == None and "reply" not in env) or (seq != None and "reply" in env and seq == env["reply"]):
return env, msg
else:
tmp = None
if "reply" in env:
tmp = env["reply"]
self._queue.append((env,msg))
return self.recvmsg(nonblock, seq)
else:
......
......@@ -137,6 +137,11 @@ class testSession(unittest.TestCase):
sess.close()
self.assertRaises(SessionError, sess.sendmsg, {}, {"hello": "a"})
def test_env_too_large(self):
sess = MySession()
largeenv = { "a": "b"*65535 }
self.assertRaises(ProtocolError, sess.sendmsg, largeenv, {"hello": "a"})
def test_session_sendmsg(self):
sess = MySession()
sess.sendmsg({}, {"hello": "a"})
......
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