From da914acdb20293b9a059bdb346221757907855a7 Mon Sep 17 00:00:00 2001 From: Victor Uriarte Date: Sun, 29 May 2016 13:31:59 -0700 Subject: Add unicode-str compatible cls decorator --- sqlparse/compat.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'sqlparse/compat.py') 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 -- cgit v1.2.1