diff options
| author | Vik <vmuriart@gmail.com> | 2016-09-12 00:14:01 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-09-12 00:14:01 -0700 |
| commit | 47fef6b7cb1fa8edd83dd31eb73aaf3c9afff086 (patch) | |
| tree | cda75d04543a02e20bf04ab01c8dfc5e670a269d /sqlparse/sql.py | |
| parent | 791a3312a247670cdeed61e52e8ca449dbb27afa (diff) | |
| parent | 843499915e91e0ee324a0407c78ac6f570806370 (diff) | |
| download | sqlparse-47fef6b7cb1fa8edd83dd31eb73aaf3c9afff086.tar.gz | |
Merge pull request #287 from phdru/master
Convert string literals to unicode using u() for Py27
Diffstat (limited to 'sqlparse/sql.py')
| -rw-r--r-- | sqlparse/sql.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/sqlparse/sql.py b/sqlparse/sql.py index f780090..06347a0 100644 --- a/sqlparse/sql.py +++ b/sqlparse/sql.py @@ -48,8 +48,8 @@ class Token(object): cls = self._get_repr_name() value = self._get_repr_value() - q = '"' if value.startswith("'") and value.endswith("'") else "'" - return "<{cls} {q}{value}{q} at 0x{id:2X}>".format( + q = u'"' if value.startswith("'") and value.endswith("'") else u"'" + return u"<{cls} {q}{value}{q} at 0x{id:2X}>".format( id=id(self), **locals()) def _get_repr_name(self): @@ -143,7 +143,7 @@ class TokenList(Token): self.is_group = True def __str__(self): - return ''.join(token.value for token in self.flatten()) + return u''.join(token.value for token in self.flatten()) # weird bug # def __len__(self): @@ -160,13 +160,13 @@ class TokenList(Token): def _pprint_tree(self, max_depth=None, depth=0, f=None): """Pretty-print the object tree.""" - indent = ' | ' * depth + indent = u' | ' * depth for idx, token in enumerate(self.tokens): cls = token._get_repr_name() value = token._get_repr_value() - q = '"' if value.startswith("'") and value.endswith("'") else "'" - print("{indent}{idx:2d} {cls} {q}{value}{q}" + q = u'"' if value.startswith("'") and value.endswith("'") else u"'" + print(u"{indent}{idx:2d} {cls} {q}{value}{q}" .format(**locals()), file=f) if token.is_group and (max_depth is None or depth < max_depth): |
