[svn] commit: r305 - /branches/jelte-datadef/src/lib/cc/python/ISC/CC/Message.py
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri Nov 20 11:55:54 UTC 2009
Author: jelte
Date: Fri Nov 20 11:55:53 2009
New Revision: 305
Log:
convert bool elements to native bools while decoding (otherwise there will be a lot of tripping of "false" equalling true when used directly)
Modified:
branches/jelte-datadef/src/lib/cc/python/ISC/CC/Message.py
Modified: branches/jelte-datadef/src/lib/cc/python/ISC/CC/Message.py
==============================================================================
--- branches/jelte-datadef/src/lib/cc/python/ISC/CC/Message.py (original)
+++ branches/jelte-datadef/src/lib/cc/python/ISC/CC/Message.py Fri Nov 20 11:55:53 2009
@@ -188,7 +188,15 @@
if type(value) == bytearray:
# hack! just try it in case it is really a string
try:
+ # now we have a 'final' item and can decode
value = value.decode('utf-8')
+ # if the item is a bool, we need to convert it
+ if value.lower() == "true":
+ print("[XX] item is a bool (true)")
+ value = True
+ elif value.lower() == "false":
+ print("[XX] item is a bool (false)")
+ value = False
except UnicodeDecodeError as ude:
# apparently not a final item, leave it a bytearray
pass
@@ -202,7 +210,13 @@
while len(data) > 0:
value, data = _decode_item(data)
if (type(value) == bytearray):
+ # now we have a 'final' item and can decode
value = value.decode('utf-8')
+ # if the item is a bool, we need to convert it
+ if value.lower() == "true":
+ value = True
+ elif value.lower() == "false":
+ value = False
ret.append(value)
return ret
More information about the bind10-changes
mailing list