summaryrefslogtreecommitdiff
path: root/extras
diff options
context:
space:
mode:
authorAndi Albrecht <albrecht.andi@gmail.com>2011-08-04 10:05:11 +0200
committerAndi Albrecht <albrecht.andi@gmail.com>2011-08-04 10:05:11 +0200
commit530da46905753a1e950bcc7e736d72a7309033c6 (patch)
tree02e232e6482f794326150a15b97af461412ad002 /extras
parent4563cc1468f9ce313cfaa535f709711c3763a46d (diff)
downloadsqlparse-530da46905753a1e950bcc7e736d72a7309033c6.tar.gz
Silence UnicodeDecodeErrors, but try to collect some demo data.
Diffstat (limited to 'extras')
-rw-r--r--extras/appengine/sqlformat/legacy.py13
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 ''