diff options
author | Miro HronĨok <miro@hroncok.cz> | 2019-04-11 12:02:04 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-04-12 10:08:42 -0400 |
commit | 8ace3ad64144b44d383e07ddcfb5e61848cd03b2 (patch) | |
tree | 3d7dcd6886cd83add5370360a31ec2c6b408a040 | |
parent | d99330c67ce6b0ab14a3ef5b13904260e2e4fe80 (diff) | |
download | external_python_mako-8ace3ad64144b44d383e07ddcfb5e61848cd03b2.tar.gz external_python_mako-8ace3ad64144b44d383e07ddcfb5e61848cd03b2.tar.bz2 external_python_mako-8ace3ad64144b44d383e07ddcfb5e61848cd03b2.zip |
Use Constant.value, not Constant.n
Since Python 3.8, class ast.Constant is used for all constants.
Old classes ast.Num, ast.Str, ast.Bytes, ast.NameConstant and
ast.Ellipsis are still available, but they will be removed in
future Python releases.
Further corrected the previous fix for :ticket:`287` as it relied upon
an attribute that is monkeypatched by Python's ``ast`` module for some
reason, which fails if ``ast`` hasn't been imported; the correct
attribute ``Constant.value`` is now used. Also note the issue
was mis-numbered in the previous changelog note.
References: https://github.com/Pylons/pyramid_mako/issues/47
Fixes: #287
Closes: #292
Pull-request: https://github.com/sqlalchemy/mako/pull/292
Pull-request-sha: b48081aa08fdc1cb6e0196b59a2d0eff35adcd94
Change-Id: Ic3fd1975e608b6890410f3fd4ad4d949478dc45e
-rw-r--r-- | doc/build/changelog.rst | 12 | ||||
-rw-r--r-- | mako/_ast_util.py | 2 |
2 files changed, 12 insertions, 2 deletions
diff --git a/doc/build/changelog.rst b/doc/build/changelog.rst index fdef573..d667475 100644 --- a/doc/build/changelog.rst +++ b/doc/build/changelog.rst @@ -9,6 +9,16 @@ Changelog :version: 1.0.9 :include_notes_from: unreleased + .. change:: + :tags: bug + :tickets: 287 + + Further corrected the previous fix for :ticket:`287` as it relied upon + an attribute that is monkeypatched by Python's ``ast`` module for some + reason, which fails if ``ast`` hasn't been imported; the correct + attribute ``Constant.value`` is now used. Also note the issue + was mis-numbered in the previous changelog note. + .. changelog:: :version: 1.0.8 :released: Wed Mar 20 2019 @@ -16,7 +26,7 @@ Changelog .. change:: :tags: bug - :tickets: 281 + :tickets: 287 Fixed an element in the AST Python generator which changed for Python 3.8, causing expression generation to fail. diff --git a/mako/_ast_util.py b/mako/_ast_util.py index caf157d..e2c7d24 100644 --- a/mako/_ast_util.py +++ b/mako/_ast_util.py @@ -682,7 +682,7 @@ class SourceGenerator(NodeVisitor): # newly needed in Python 3.8 def visit_Constant(self, node): - self.write(repr(node.n)) + self.write(repr(node.value)) def visit_Tuple(self, node): self.write('(') |