NovFora Dev

Issue with Python 3.11 bytecode generation — getting SyntaxError on f-string nesting that worked in 3.9/3.10

Taylor Davis

Taylor Davis

4 months ago

I'm hitting a regression when using nested f-strings like f"{foo(bar=f'{baz}')}" which ran fine in 3.10 but throws a SyntaxError in 3.11 due to the new hyper-optimized f-string parser. The error says "unsupported format specifier" or just generic syntax error depending on context. I've checked the PEPs and it seems like nested quotes within expressions have stricter parsing rules now. Workarounds: use a helper function, .format(), or template string — but these all add overhead in tight loops where this was originally fine. Has anyone successfully reproduced this with a minimal script? Any chance there is an upcoming fix or am I stuck refactoring?

Join the conversation to leave a reply.

Sign in to reply

Related topics