diff options
-rw-r--r-- | doc/build/unreleased/310.rst | 10 | ||||
-rw-r--r-- | mako/util.py | 6 | ||||
-rw-r--r-- | test/templates/unicode_runtime_error.html | 2 | ||||
-rw-r--r-- | test/templates/unicode_syntax_error.html | 2 |
4 files changed, 15 insertions, 5 deletions
diff --git a/doc/build/unreleased/310.rst b/doc/build/unreleased/310.rst new file mode 100644 index 0000000..e824924 --- /dev/null +++ b/doc/build/unreleased/310.rst @@ -0,0 +1,10 @@ +.. change:: + :tags: bug, py3k + :tickets: 310 + + Replaced usage of the long-superseded "parser.suite" module in the + mako.util package for parsing the python magic encoding comment with the + "ast.parse" function introduced many years ago in Python 2.5, as + "parser.suite" is emitting deprecation warnings in Python 3.9. + + diff --git a/mako/util.py b/mako/util.py index 498edbc..16e3c72 100644 --- a/mako/util.py +++ b/mako/util.py @@ -3,7 +3,9 @@ # # This module is part of Mako and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php +from __future__ import absolute_import +from ast import parse import codecs import collections import operator @@ -257,9 +259,7 @@ def parse_encoding(fp): m = _PYTHON_MAGIC_COMMENT_re.match(line1.decode("ascii", "ignore")) if not m: try: - import parser - - parser.suite(line1.decode("ascii", "ignore")) + parse(line1.decode("ascii", "ignore")) except (ImportError, SyntaxError): # Either it's a real syntax error, in which case the source # is not valid python source, or line2 is a continuation of diff --git a/test/templates/unicode_runtime_error.html b/test/templates/unicode_runtime_error.html index 862dce5..dda7f62 100644 --- a/test/templates/unicode_runtime_error.html +++ b/test/templates/unicode_runtime_error.html @@ -1,2 +1,2 @@ ## -*- coding: utf-8 -*- -<% print 'Alors vous imaginez ma surprise, au lever du jour, quand une drôle de petite voix m’a réveillé. Elle disait: « S’il vous plaît… dessine-moi un mouton! »' + int(5/0) %>
\ No newline at end of file +<% x = 'Alors vous imaginez ma surprise, au lever du jour, quand une drôle de petite voix m’a réveillé. Elle disait: « S’il vous plaît… dessine-moi un mouton! »' + int(5/0) %>
\ No newline at end of file diff --git a/test/templates/unicode_syntax_error.html b/test/templates/unicode_syntax_error.html index 982af33..aa53025 100644 --- a/test/templates/unicode_syntax_error.html +++ b/test/templates/unicode_syntax_error.html @@ -1,2 +1,2 @@ ## -*- coding: utf-8 -*- -<% print 'Alors vous imaginez ma surprise, au lever du jour, quand une drôle de petite voix m’a réveillé. Elle disait: « S’il vous plaît… dessine-moi un mouton! » %>
\ No newline at end of file +<% x = 'Alors vous imaginez ma surprise, au lever du jour, quand une drôle de petite voix m’a réveillé. Elle disait: « S’il vous plaît… dessine-moi un mouton! » %>
\ No newline at end of file |