On Mon, 2026-02-09 at 23:10 +0100, Pavel Sanda wrote:
> Hi Jose,
>
> python3 generate_contributions.py a b c
> fails with
> File "/home/paf/lyx/devel/lib/generate_contributions.py", line 59
> result.append(f' {self.credit.replace("\n", "\n ")}\n')
> ^
> SyntaxError: f-string expression part cannot include a backslash
>
>
> Bisect points to your commit aeee6b373ea454a5d5.
>
> Can you have a look?
> Python 3.11.2 here.
>
> Pavel
Try the following patch.
If it works I will commit it to main.
FWIW I have never found such errors, even although I was aware of the reason.
The issue is that the f-strings (*f* standing for format) had their own python
parser. This parser was different from the main parser. In this case we have hit
a limitation of the parser until Python 3.12.
The fix is quite simple, evaluate the expression outside of the formatted string
and it works.
Best regards,
--
José Abílio
diff --git i/lib/generate_contributions.py w/lib/generate_contributions.py
index 0009f67ff7..b124603504 100755
--- i/lib/generate_contributions.py
+++ w/lib/generate_contributions.py
@@ -56,7 +56,9 @@ class contributor:
result.append(f'@i{self.contact}\n')
else:
result.append(f'@iE-mail: {self.contact}\n')
- result.append(f' {self.credit.replace("\n", "\n ")}\n')
+ # Python fstrings parser did not like backslashes until 3.12
+ tidy_credit = self.credit.replace("\n", "\n ")
+ result.append(f' {tidy_credit}\n')
return "".join(result)
--
lyx-devel mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-devel