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

fix f-string syntax error in code generation #1852

Open
wants to merge 1 commit into
base: 3.1.x
Choose a base branch
from

Conversation

sisp
Copy link

@sisp sisp commented May 26, 2023

I've fixed a bug that caused an f-string syntax error in the template compilation when a template, that imports a macro, contains curly braces in its name. The bug was caused by the code-generation of an f-string in which the template name is inserted, and when the template name contains curly braces and the generated code gets executed, Python treats the curly braces as f-string braces. I've changed the code-generation to construct the string differently, such that the affected substring is not an f-string. Instead, the different substrings are concatenated using the + operator.

Checklist:

  • Add tests that demonstrate the correct behavior of the change. Tests should fail without the change.
  • Add or update relevant docs, in the docs folder and in code.
  • Add an entry in CHANGES.rst summarizing the change and linking to the issue.
  • Add .. versionchanged:: entries in any relevant code docs.
  • Run pre-commit hooks and fix any issues.
  • Run pytest and tox, no tests failed.

@sisp
Copy link
Author

sisp commented May 26, 2023

I don't think any of the errors were introduced by this PR.

@sisp sisp force-pushed the fix/fstring-syntax-error-in-codegen branch from f78592a to 65e00c4 Compare December 19, 2023 07:56
@sisp
Copy link
Author

sisp commented Dec 19, 2023

I've rebased this PR onto the latest state of the 3.1.x branch. All tests are passing except pre-commit.ci - pr, but the reported errors originate from 3.1.x and weren't introduced by this PR.

@davidism (or any other maintainer) – may I ask you for a review? 🙏

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

Successfully merging this pull request may close these issues.

None yet

1 participant