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
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
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 |
char is unsigned on those platforms (arm). Thus,
will lead to a 255. Then 255 was converted to int again in I can reproduce this problem on x86 with
|
C allows any explicitly using |
Oooh, that's right! Didn't know that ARM has unsigned chars by default. Pushed a fix. |
Wow, thats a nice find!! |
If you want to schedule another build, you need to add the |
Ok, now it seems we are green in all fronts |
One more nit, why is this |
@isidentical @lysnikolaou please check the pr again and LGTM if you are ready to land |
Ah that's a typo |
Gave an initial pass, everything seems to be looking great |
Could you approve it formally? :) |
Same thing for @lysnikolaou |
If you want to schedule another build, you need to add the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Let's merge!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* main: (24 commits) pythongh-98040: Move the Single-Phase Init Tests Out of test_imp (pythongh-102561) pythongh-83861: Fix datetime.astimezone() method (pythonGH-101545) pythongh-102856: Clean some of the PEP 701 tokenizer implementation (python#103634) pythongh-102856: Skip test_mismatched_parens in WASI builds (python#103633) pythongh-102856: Initial implementation of PEP 701 (python#102855) pythongh-103583: Add ref. dependency between multibytecodec modules (python#103589) pythongh-83004: Harden msvcrt further (python#103420) pythonGH-88342: clarify that `asyncio.as_completed` accepts generators yielding tasks (python#103626) pythongh-102778: IDLE - make sys.last_exc available in Shell after traceback (python#103314) pythongh-103582: Remove last references to `argparse.REMAINDER` from docs (python#103586) pythongh-103583: Always pass multibyte codec structs as const (python#103588) pythongh-103617: Fix compiler warning in _iomodule.c (python#103618) pythongh-103596: [Enum] do not shadow mixed-in methods/attributes (pythonGH-103600) pythonGH-100530: Change the error message for non-class class patterns (pythonGH-103576) pythongh-95299: Remove lingering setuptools reference in installer scripts (pythonGH-103613) [Doc] Fix a typo in optparse.rst (python#103504) pythongh-101100: Fix broken reference `__format__` in `string.rst` (python#103531) pythongh-95299: Stop installing setuptools as a part of ensurepip and venv (python#101039) pythonGH-103484: Docs: add linkcheck allowed redirects entries for most cases (python#103569) pythongh-67230: update whatsnew note for csv changes (python#103598) ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need help with getting the program to run