-
Notifications
You must be signed in to change notification settings - Fork 705
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix f-string formatting in traceback of Python 3.12
In Python 3.12, new tokens were added to "tokenize" module in order to differentiate simple strings and f-string. Additionally, the expressions inside the f-string are properly parsed as well. The unit tests have been updated consequently.
- Loading branch information
Showing
4 changed files
with
30 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,18 @@ | ||
|
||
[33m[1mTraceback (most recent call last):[0m | ||
|
||
File "[32mtests/exceptions/source/modern/[0m[32m[1mf_string.py[0m", line [33m17[0m, in [35m<module>[0m | ||
File "[32mtests/exceptions/source/modern/[0m[32m[1mf_string.py[0m", line [33m21[0m, in [35m<module>[0m | ||
[1mhello[0m[1m([0m[1m)[0m | ||
[36m└ [0m[36m[1m<function hello at 0xDEADBEEF>[0m | ||
|
||
File "[32mtests/exceptions/source/modern/[0m[32m[1mf_string.py[0m", line [33m13[0m, in [35mhello[0m | ||
[36mf"{name}"[0m [35m[1mand[0m [36mf'{{ {f / 0} }}'[0m | ||
File "[32mtests/exceptions/source/modern/[0m[32m[1mf_string.py[0m", line [33m11[0m, in [35mhello[0m | ||
[1moutput[0m [35m[1m=[0m [36mf"[0m[36mHello[0m[36m"[0m [35m[1m+[0m [36mf'[0m[36m [0m[36m'[0m [35m[1m+[0m [36mf"""[0m[36mWorld[0m[36m"""[0m [35m[1mand[0m [1mworld[0m[1m([0m[1m)[0m | ||
[36m └ [0m[36m[1m<function world at 0xDEADBEEF>[0m | ||
|
||
File "[32mtests/exceptions/source/modern/[0m[32m[1mf_string.py[0m", line [33m17[0m, in [35mworld[0m | ||
[36mf"[0m[1m{[0m[1mname[0m[1m}[0m[36m -> [0m[1m{[0m [1mf[0m [1m}[0m[36m"[0m [35m[1mand[0m [1m{[0m[1m}[0m [35m[1mor[0m [36mf'[0m[36m{{[0m[36m [0m[1m{[0m[1mf[0m [35m[1m/[0m [34m[1m0[0m[1m}[0m[36m }}[0m[36m'[0m | ||
[36m │ │ └ [0m[36m[1m1[0m | ||
[36m │ └ [0m[36m[1m1[0m | ||
[36m └ [0m[36m[1m'world'[0m | ||
|
||
[31m[1mZeroDivisionError[0m:[1m division by zero[0m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters