From 3be307770542e3f15bcae49055294d9b8b14eebd Mon Sep 17 00:00:00 2001
From: Mike Buland <eichlan@xagasoft.com>
Date: Mon, 11 Jun 2012 04:10:37 +0000
Subject: Python supports null.

---
 python/gats.py | 9 ++++++---
 python/test.py | 2 +-
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/python/gats.py b/python/gats.py
index 22463ab..adf5122 100644
--- a/python/gats.py
+++ b/python/gats.py
@@ -85,6 +85,9 @@ def dump( obj, sOut ):
 	sOut.write(	struct.pack('>BI', 1, len(sCore)+5 ) )
 	sOut.write( sCore )
 
+class EndMarker:
+	pass
+
 def _readObj( sIn ):
 	t = sIn.read( 1 )
 	if t == 'i':	# Integer
@@ -100,14 +103,14 @@ def _readObj( sIn ):
 		ret = []
 		while True:
 			value = _readObj( sIn )
-			if value is None:
+			if isinstance( value, EndMarker ):
 				return ret
 			ret.append( value )
 	elif t == 'd':	# Dictionary
 		ret = {}
 		while True:
 			key = _readObj( sIn )
-			if key is None:
+			if isinstance( key, EndMarker ):
 				return ret
 			if not isinstance( key, str ):
 				raise Exception('Only strings can be used as keys in gats dictionaries')
@@ -149,7 +152,7 @@ def _readObj( sIn ):
 	elif t == 'n':
 		return None
 	elif t == 'e':	# End marker
-		return None
+		return EndMarker()
 	else:
 		raise Exception('Invalid gats type discovered: ' + t)
 	return 'not implemented yet';
diff --git a/python/test.py b/python/test.py
index fa9c79a..a359893 100755
--- a/python/test.py
+++ b/python/test.py
@@ -7,4 +7,4 @@ print isinstance( True, int )
 print isinstance( 1, bool )
 print isinstance( 1, int )
 
-print gats.loads( gats.dumps( 0 ) )
+print gats.loads( gats.dumps( [0, 1, 2, 3, None, {'hi': None, 'bye': 1}] ) )
-- 
cgit v1.2.3