From 807ca1da501e9ab412e799ede4b88b74d6dd9ed8 Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Sat, 30 Jun 2012 15:28:16 +0000 Subject: fix problem with unicode encoding that prevented sharing --- (limited to 'TurtleArt/tautils.py') diff --git a/TurtleArt/tautils.py b/TurtleArt/tautils.py index d60884e..e24d061 100644 --- a/TurtleArt/tautils.py +++ b/TurtleArt/tautils.py @@ -237,13 +237,12 @@ def data_from_string(text): ''' JSON load data from a string. ''' if type(text) == str: return json_load(text.replace(']],\n', ']], ')) + elif type(text) == unicode: + text = text.encode('ascii', 'replace') + 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 '' + print 'type error (%s) in data_from_string' % (type(text)) + return None def data_to_file(data, ta_file): ''' Write data to a file. ''' -- cgit v0.9.1