python / cpython

The Python programming language
https://www.python.org
Other
63.69k stars 30.51k forks source link

The python PEG parser generator doesn't allow f-strings anymore in actions #125588

Open pablogsal opened 1 month ago

pablogsal commented 1 month ago

After the changes in 3.12 to the f-string formalisation, the PEG parser doesn't recognise the new tokens.

Linked PRs

db3l commented 5 days ago

Just ran into this today when trying to test a clean build of main on my buildbot. My buildbot has a system python of 3.11, but with this change, it needs to be 3.12+ otherwise there's an exception on non-existent FSTRING_* attributes in the token module. The issue hasn't yet presented itself on any of the regular builder builds, I guess due to re-generation not usually being necessary, but presumably it will the next time the grammar is touched.

It appears 3.10+ is the current minimum enforced by find_python.bat under Windows (and I believe configure under Linux). I can fix things by adding a default "None" parameter to the new getattr() calls (together with the existing "if not" checks) but am unsure if this would still produce the right final output, or if the minimum system python version just needs to be bumped.