diff options
| -rw-r--r-- | extras/appengine/sqlformat/legacy.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/extras/appengine/sqlformat/legacy.py b/extras/appengine/sqlformat/legacy.py index 9d53479..6d3aaf8 100644 --- a/extras/appengine/sqlformat/legacy.py +++ b/extras/appengine/sqlformat/legacy.py @@ -105,7 +105,18 @@ def _get_examples(): def _get_sql(data, files=None): sql = None if files is not None and 'datafile' in files: - sql = files['datafile'].read().decode('utf-8') + raw = files['datafile'].read() + try: + sql = raw.decode('utf-8') + except UnicodeDecodeError, err: + logging.error(err) + logging.debug(repr(raw)) + sql = (u'-- UnicodeDecodeError: %s\n' + u'-- Please make sure to upload UTF-8 encoded data for now.\n' + u'-- If you want to help improving this part of the application\n' + u'-- please file a bug with some demo data at:\n' + u'-- http://code.google.com/p/python-sqlparse/issues/entry\n' + u'-- Thanks!\n' % err) if not sql: sql = data.get('data') return sql or '' |
