diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-11-11 14:38:56 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-11-11 14:38:56 -0500 |
commit | 1eb56ef02a7fa825be99ddfb95f217a07dab1cdf (patch) | |
tree | bf0857b7f42dec7db03910799eed7e5dda5e7c2b /mako/lexer.py | |
parent | 4ab9664a515c265238d420b0373f7225fe2e53c7 (diff) | |
download | external_python_mako-1eb56ef02a7fa825be99ddfb95f217a07dab1cdf.tar.gz external_python_mako-1eb56ef02a7fa825be99ddfb95f217a07dab1cdf.tar.bz2 external_python_mako-1eb56ef02a7fa825be99ddfb95f217a07dab1cdf.zip |
- first pass at running a py3k compatible base in py2k as well.
having some weird unicode issues I can't debug; the meaning of
str.encode() seems to be changing globally somehow
Diffstat (limited to 'mako/lexer.py')
-rw-r--r-- | mako/lexer.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/mako/lexer.py b/mako/lexer.py index 267c0d1..26d1596 100644 --- a/mako/lexer.py +++ b/mako/lexer.py @@ -6,8 +6,9 @@ """provides the Lexer class for parsing template strings into parse trees.""" -import re, codecs -from mako import parsetree, exceptions, util +import re +import codecs +from mako import parsetree, exceptions, compat from mako.pygen import adjust_whitespace _regexp_cache = {} @@ -29,7 +30,7 @@ class Lexer(object): self.disable_unicode = disable_unicode self.encoding = input_encoding - if util.py3k and disable_unicode: + if compat.py3k and disable_unicode: raise exceptions.UnsupportedError( "Mako for Python 3 does not " "support disabling Unicode") @@ -173,7 +174,7 @@ class Lexer(object): or raw if decode_raw=False """ - if isinstance(text, unicode): + if isinstance(text, compat.text_type): m = self._coding_re.match(text) encoding = m and m.group(1) or known_encoding or 'ascii' return encoding, text @@ -198,7 +199,7 @@ class Lexer(object): if decode_raw: try: text = text.decode(parsed_encoding) - except UnicodeDecodeError, e: + except UnicodeDecodeError: raise exceptions.CompileException( "Unicode decode operation of encoding '%s' failed" % parsed_encoding, |