Bug in Tokenizer/Automatic Parenthesization for Python 3.12
zacharyrs opened this issue · comments
Hey there!
I've discovered a bug with the tokenizer and automatic forward-slash-parenthesization.
Specifically, the following will result in an error when run in IPython 8.25.0 on Python 3.12.3:
1| from pathlib import Path
2|
3| (
4| Path(".")
5| / f")"
6| / "a a a a a a a a a"
7| )
Interestingly, the issue is mitigated if the f-string on line 5 is:
- removed/replaced by a plain string
- has any character after the ending parenthesis
- starts with an opening parenthesis (note if there's anything before, including a space, it'll fail)
From a little digging, the tokenizer starts a new line (in tokens_by_line
) when it encounters the new line at the end of the f-string.
It looks like the end parenthesis in the f-string is becoming an FSTRING_MIDDLE
token, and deincrementing parenlev
.
See here
ipython/IPython/core/inputtransformer2.py
Lines 511 to 556 in 1b4607f
This issue does not occur on an older version of Python (e.g., 3.11.x), even when running the latest version of IPython.
thanks for the report, i'll see what I can do.