Skip to content

Commit

Permalink
Merge pull request malthe#293 from starzel/fix_syntaxwarnings
Browse files Browse the repository at this point in the history
Fix SyntaxWarnings in Python 3.8 when comparing literals with is
  • Loading branch information
malthe authored Jun 21, 2019
2 parents 983877e + d36533c commit b6d251c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Changes
3.7 (unreleased)
----------------

...
- Fix SyntaxWarnings in Python 3.8 resulting from comparing literals with 'is'.
See https://github.com/plone/Products.CMFPlone/issues/2890.

3.6.1 (2019-04-01)
------------------
Expand Down
6 changes: 3 additions & 3 deletions src/chameleon/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ def func(target):
'default'),
func_defaults=(None,),
source=r"""
target = translate(msgid, default=default, domain=__i18n_domain,
context=__i18n_context,
target = translate(msgid, default=default, domain=__i18n_domain,
context=__i18n_context,
target_language=target_language)""")


Expand Down Expand Up @@ -949,7 +949,7 @@ def __init__(self, engine_factory, node, filename, source,
module = ast.Module([])
module.body += self.visit(node)
ast.fix_missing_locations(module)
prelude = "__filename = %r" % filename
prelude = "__filename = %r\n__default = object()" % filename
generator = TemplateCodeGenerator(module, source)
tokens = [
Token(source[pos:pos + length], pos, source)
Expand Down
4 changes: 2 additions & 2 deletions src/chameleon/zpt/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def builtins(self):
@property
def engine(self):
if self.literal_false:
default_marker = ast.Str(s="__default__")
default_marker = Builtin("__default")
else:
default_marker = Builtin("False")

Expand All @@ -225,7 +225,7 @@ def expression_parser(self):

def parse(self, body):
if self.literal_false:
default_marker = ast.Str(s="__default__")
default_marker = Builtin("__default")
else:
default_marker = Builtin("False")

Expand Down

0 comments on commit b6d251c

Please sign in to comment.