diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-08-03 13:24:10 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-08-03 13:24:10 -0400 |
| commit | adad0a0a7797686030083feafd4d46b153dbfcd8 (patch) | |
| tree | 05631760aa914b8ba3cf7559753ae039cf7cdd4f | |
| parent | e14a686012cb55645982b8220b948dcadbbb2915 (diff) | |
| download | external_python_mako-adad0a0a7797686030083feafd4d46b153dbfcd8.tar.gz external_python_mako-adad0a0a7797686030083feafd4d46b153dbfcd8.tar.bz2 external_python_mako-adad0a0a7797686030083feafd4d46b153dbfcd8.zip | |
- [bug] The Babel plugin has been repaired to work on Python 3.
| -rw-r--r-- | CHANGES | 2 | ||||
| -rw-r--r-- | mako/compat.py | 5 | ||||
| -rw-r--r-- | mako/ext/babelplugin.py | 4 |
3 files changed, 9 insertions, 2 deletions
@@ -6,6 +6,8 @@ is backwards incompatible vs. code that is relying upon a _('') translation to be working within a call tag. +- [bug] The Babel plugin has been repaired to work on Python 3. + 0.8.1 - [bug] Changed setup.py to skip installing markupsafe if Python version is < 2.6 or is between 3.0 and diff --git a/mako/compat.py b/mako/compat.py index 3a4742d..5e9c201 100644 --- a/mako/compat.py +++ b/mako/compat.py @@ -18,6 +18,8 @@ if py3k: binary_type = bytes text_type = str + from io import BytesIO as byte_buffer + def u(s): return s @@ -30,6 +32,9 @@ else: from cStringIO import StringIO except: from StringIO import StringIO + + byte_buffer = StringIO + from urllib import quote_plus, unquote_plus from htmlentitydefs import codepoint2name, name2codepoint string_types = basestring, diff --git a/mako/ext/babelplugin.py b/mako/ext/babelplugin.py index e4feceb..2f6b7fb 100644 --- a/mako/ext/babelplugin.py +++ b/mako/ext/babelplugin.py @@ -113,10 +113,10 @@ def extract_nodes(nodes, keywords, comment_tags, options): translator_comments = \ [comment[1] for comment in translator_comments] - if not compat.py3k and isinstance(code, compat.text_type): + if isinstance(code, compat.text_type): code = code.encode('ascii', 'backslashreplace') - code = StringIO(code) + code = compat.byte_buffer(code) for lineno, funcname, messages, python_translator_comments \ in extract_python(code, keywords, comment_tags, options): yield (node.lineno + (lineno - 1), funcname, messages, |
