summaryrefslogtreecommitdiff
path: root/sqlparse/compat.py
diff options
context:
space:
mode:
authorVictor Uriarte <victor.m.uriarte@intel.com>2016-05-29 13:31:59 -0700
committerVictor Uriarte <victor.m.uriarte@intel.com>2016-06-04 15:06:04 -0700
commitda914acdb20293b9a059bdb346221757907855a7 (patch)
treedbd0634f8ef189a9284a64623c22562ed85e632d /sqlparse/compat.py
parentbe62c7a673b5f0fe973523d01e22b7ad0bb76600 (diff)
downloadsqlparse-da914acdb20293b9a059bdb346221757907855a7.tar.gz
Add unicode-str compatible cls decorator
Diffstat (limited to 'sqlparse/compat.py')
-rw-r--r--sqlparse/compat.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/sqlparse/compat.py b/sqlparse/compat.py
index 0226a00..0defd86 100644
--- a/sqlparse/compat.py
+++ b/sqlparse/compat.py
@@ -25,6 +25,10 @@ if PY3:
return str(s)
+ def unicode_compatible(cls):
+ return cls
+
+
text_type = str
string_types = (str,)
from io import StringIO
@@ -39,6 +43,12 @@ elif PY2:
return unicode(s, encoding)
+ def unicode_compatible(cls):
+ cls.__unicode__ = cls.__str__
+ cls.__str__ = lambda x: x.__unicode__().encode('utf-8')
+ return cls
+
+
text_type = unicode
string_types = (basestring,)
from StringIO import StringIO