Whole file
berkerpeksag/astor
The author described this change as “Fix code generation with escaped braces in f-strings (#125)”. It counts as a record because the check below fails on the code as it stood at 8aa5437f1 and passes on a3c9e284b, with nothing else changed between the two runs.
Projectberkerpeksag/astor
Fix saved2019-03-14
Sharing licenceBSD-3-Clause · LICENSE
Change size+2 −1
What the code was meant to do, written into the code itself as a save note
Fix code generation with escaped braces in f-strings (#125)
The change
| 566 | 566 | def recurse(node): | |
| 567 | 567 | for value in node.values: | |
| 568 | 568 | if isinstance(value, ast.Str): | |
| 569 | - | self.write(value.s) | |
| 569 | + | # Double up braces to escape them. | |
| 570 | + | self.write(value.s.replace('{', '{{').replace('}', '}}')) | |
| 570 | 571 | elif isinstance(value, ast.FormattedValue): | |
| 571 | 572 | with self.delimit('{}'): | |
| 572 | 573 | self.visit(value.value) |
The check that tells the two apart
fail→pass·tests/test_code_gen.py::CodegenTestCase::test_fstring_escaped_braces
Check file tests/test_code_gen.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before it8aa5437f160290b09001fd831bce71919909f746
Broken version dated2019-03-14
Moduleastor.code_gen
Units changedSourceGenerator
Fingerprint9d64ec8f4e9556ab
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.
Other bugs found in berkerpeksag/astor
- 2026-02-17add_parens
- 2019-05-12MetaFlatten
- 2018-05-07Fix trailing newlines in f-strings (#103)