From c491950c7febde93d98bb5998e1866f093869f1b Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Fri, 29 Jun 2012 23:18:41 +0000 Subject: check type returned from json_load --- diff --git a/TurtleArt/tautils.py b/TurtleArt/tautils.py index 40c39e9..d60884e 100644 --- a/TurtleArt/tautils.py +++ b/TurtleArt/tautils.py @@ -235,8 +235,15 @@ def data_from_file(ta_file): def data_from_string(text): ''' JSON load data from a string. ''' - return json_load(text.replace(']],\n', ']], ')) - + if type(text) == str: + return json_load(text.replace(']],\n', ']], ')) + else: + print type(text), text + if hasattr('replace', text): + return json_load(text.replace(']],\n', ']], ')) + else: + print 'type error in data_from_string' + return '' def data_to_file(data, ta_file): ''' Write data to a file. ''' -- cgit v0.9.1