- [bug] The Babel plugin has been repaired to work on Python 3.
diff --git a/CHANGES b/CHANGES
index fb83453..1e5cad8 100644
--- a/CHANGES
+++ b/CHANGES
@@ -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 @@
binary_type = bytes
text_type = str
+ from io import BytesIO as byte_buffer
+
def u(s):
return s
@@ -30,6 +32,9 @@
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 @@
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,