diff options
| author | Piet Delport <pjdelport@gmail.com> | 2013-02-22 17:42:54 +0200 |
|---|---|---|
| committer | Piet Delport <pjdelport@gmail.com> | 2013-02-22 17:42:54 +0200 |
| commit | 629fd8c7b016aa43719b7112b75f427f67f2123a (patch) | |
| tree | 22e2f0bb5392ae41da528c3ac77fb101c08916f3 /bin | |
| parent | e6f93efe83abfd439db0f2bd67804a39e96eab5c (diff) | |
| download | sqlparse-629fd8c7b016aa43719b7112b75f427f67f2123a.tar.gz | |
Limit explicit UTF-8 encoding to Python < 3.
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/sqlformat | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/bin/sqlformat b/bin/sqlformat index 6a2496a..fcee452 100755 --- a/bin/sqlformat +++ b/bin/sqlformat @@ -98,8 +98,10 @@ def main(): err = sys.exc_info()[1] # Python 2.5 compatibility _error('Invalid options: %s' % err, exit_=1) - stream.write(sqlparse.format(data, **formatter_opts).encode('utf-8', - 'replace')) + s = sqlparse.format(data, **formatter_opts) + if sys.version_info < (3,): + s = s.encode('utf-8', 'replace') + stream.write(s) stream.flush() |
