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
gh-102856: Initial implementation of PEP 701 #102855
base: main
Are you sure you want to change the base?
gh-102856: Initial implementation of PEP 701 #102855
Conversation
pablogsal
commented
Mar 20, 2023
•
edited by bedevere-bot
edited by bedevere-bot
- Issue: PEP 701 – Syntactic formalization of f-strings #102856
7cb2e44
to
ed0ef34
Compare
Co-authored-by: Eclips4 <80244920+Eclips4@users.noreply.github.com>
Infer format specificer enclosing automatically
…-sprint' into fstring-grammar-rebased-after-sprint
…sprint test: Fix fstring related tests in test_tokenize.py
…replacement-field capture more errors in fstring replacement field
One issue is that, with current grammar f"{lambda x:{123}}" will be recognized as a valid lambda, but f"{lambda x: {123}}"
f"{lambda x:{123} }" won't. It definitely confuses the users. I can't figure out an elegant way to fix this under current tokens. Since the info of One workaround is to emit an empty fstring_middle to prevent any further match by the Another workaround is to add 2 tokens: |
@sunmy2019 the changes may also make |
I ran cpu heavy tests yeterday, and found this failure. See here: pablogsal#67 (comment) Both the tokenize and the untokenize function needs a rewrite. |
If you want to schedule another build, you need to add the |
We are almost there! We have a failing test in some buildbots: https://buildbot.python.org/all/#/builders/802/builds/760 I cannot reproduce in my mac machine. Maybe someone has more luck with a Linux system |
No luck on my side either (with a Linux machine + debug build + refleaks) for |
I'm able to reproduce on a Debian container using Docker on my macOS. The problem has to do with code like |
More info. When running it with Python, I get the following error: root@9ee555036b0f:/usr/src/cpython# cat t.py
eval('f"a"')
root@9ee555036b0f:/usr/src/cpython# ./python t.py
Fatal Python error: tok_backup: tok_backup: wrong character
Python runtime state: initialized
Current thread 0x0000ffff9de38750 (most recent call first):
File "/usr/src/cpython/t.py", line 1 in <module>
Aborted Here's a simple step though
|
Oh, this kind of makes sense. At least on how we got there. I wonder whether we could simply look at the E.g. something like this (just as a hack to test if it works):
For me, |
If you want to schedule another build, you need to add the |
Not sure whether this is the actual problem though. The big questions to me is how do we end up with |