diff options
author | Walter Bender <walter.bender@gmail.com> | 2012-06-30 15:28:16 (GMT) |
---|---|---|
committer | Walter Bender <walter.bender@gmail.com> | 2012-06-30 15:28:16 (GMT) |
commit | 807ca1da501e9ab412e799ede4b88b74d6dd9ed8 (patch) | |
tree | 063db7a52dd24083946cc095485f52a80d4d3002 /TurtleArt/tautils.py | |
parent | b34197d73824609a29af1af2b2249d532d5f7ede (diff) |
fix problem with unicode encoding that prevented sharing
Diffstat (limited to 'TurtleArt/tautils.py')
-rw-r--r-- | TurtleArt/tautils.py | 11 |
1 files changed, 5 insertions, 6 deletions
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. ''' |