From 3be307770542e3f15bcae49055294d9b8b14eebd Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 11 Jun 2012 04:10:37 +0000 Subject: Python supports null. --- python/gats.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'python/gats.py') 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'; -- cgit v1.2.3