PyUnicode_GET_LENGTH(state->last_str) != 0' failed. [2] 12810 abort (core dumped) ./python The problem is that some literal strings are zero length. The assert can be deleted.
Before the patch, eval("f'\\\n'") gives me the same assertion failure, with an IDLE freeze instead of core dump equivalent, but is seems that the string should be of length 2. >>> len('\\\n') 2 >>> len(f'\\\n') 2
Terry: The eval is important. The bug was in evaluating an f-string that consisted of two bytes: a backslash followed by a newline. And just as: eval("'\\\n'") == '' # len == 0 so should eval("f'\\\n'") == '' # len == 0 It's the second one that was throwing the assertion. The parser was seeing these bytes: f 0x66 ' 0x27 \ 0x5c nl 0xa ' 0x27 and behaving badly (to say the least) by asserting. Without the eval, I can't think of a way to have a string consisting of those two bytes, but I assume someone who's trickier than I can come up with a way.
History
Date
User
Action
Args
2022-04-11 14:58:47
admin
set
github: 74867
2017-06-16 17:13:05
serhiy.storchaka
set
type: behavior -> crash
2017-06-16 16:49:50
eric.smith
set
status: open -> closedresolution: fixedmessages: +