Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 0.14.0 fails to render sections with names that happen to be builtin methods of str #104

Open
theister opened this issue Sep 27, 2021 · 0 comments

Comments

@theister
Copy link

All section names that also happen to be names of builtin methods of str to result in broken output if their value is a plain string and not a dictionary.

The example below uses upper as a section name, but the same thing applies to the any function name that can be called as a method of a str object like zfill, encode, endswith, replace, etc.


Minimal example to reproduce (python 3.7, chevron==0.14.0), derived from here by just changing names.

import chevron
chevron.render("{{#upper}}{{{.}}} == {{{upper}}} {{/upper}}", {"upper": "foo"})

Expected output:
foo == foo
Actual output:
foo == <built-in method upper of str object at 0x104383e30>

Version 0.13.1 does not show that behaviour.


It seems that the change in #87 introduced the bug as a side effect of using getattr() on a variable that isn't guaranteed to not be a string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant