diff options
author | Victor Uriarte <victor.m.uriarte@intel.com> | 2016-05-29 13:31:59 -0700 |
---|---|---|
committer | Victor Uriarte <victor.m.uriarte@intel.com> | 2016-06-04 15:06:04 -0700 |
commit | da914acdb20293b9a059bdb346221757907855a7 (patch) | |
tree | dbd0634f8ef189a9284a64623c22562ed85e632d /sqlparse/compat.py | |
parent | be62c7a673b5f0fe973523d01e22b7ad0bb76600 (diff) | |
download | sqlparse-da914acdb20293b9a059bdb346221757907855a7.tar.gz |
Add unicode-str compatible cls decorator
Diffstat (limited to 'sqlparse/compat.py')
-rw-r--r-- | sqlparse/compat.py | 10 |
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 |