This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2017年06月16日 09:13 by eric.smith, last changed 2022年04月11日 14:58 by admin. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 2232 | eric.smith, 2017年06月16日 09:33 | ||
| PR 2242 | merged | serhiy.storchaka, 2017年06月16日 10:22 | |
| Messages (5) | |||
|---|---|---|---|
| msg296166 - (view) | Author: Eric V. Smith (eric.smith) * (Python committer) | Date: 2017年06月16日 09:13 | |
>>> eval("f'\\\n'")
python: Python/ast.c:4906: FstringParser_ConcatFstring: Assertion `!state->last_str || 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.
|
|||
| msg296174 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2017年06月16日 10:19 | |
New changeset 11e97f2f80bf65cc828c127eafc95229df35d403 by Serhiy Storchaka (ericvsmith) in branch 'master': bpo-30682: Removed a too-strict assertion that failed for certain f-strings. (#2232) https://github.com/python/cpython/commit/11e97f2f80bf65cc828c127eafc95229df35d403 |
|||
| msg296193 - (view) | Author: Eric V. Smith (eric.smith) * (Python committer) | Date: 2017年06月16日 13:29 | |
New changeset 2eca5b465f7404cc8484457b7966f828f434ec20 by ericvsmith (Serhiy Storchaka) in branch '3.6': [3.6] bpo-30682: Removed a too-strict assertion that failed for certain f-strings. (GH-2232) (#2242) https://github.com/python/cpython/commit/2eca5b465f7404cc8484457b7966f828f434ec20 |
|||
| msg296204 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2017年06月16日 15:35 | |
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
|
|||
| msg296212 - (view) | Author: Eric V. Smith (eric.smith) * (Python committer) | Date: 2017年06月16日 16:49 | |
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 -> closed resolution: fixed messages: + msg296212 |
| 2017年06月16日 15:35:28 | terry.reedy | set | nosy:
+ terry.reedy messages: + msg296204 type: behavior stage: resolved |
| 2017年06月16日 13:29:44 | eric.smith | set | messages: + msg296193 |
| 2017年06月16日 10:22:59 | serhiy.storchaka | set | pull_requests: + pull_request2286 |
| 2017年06月16日 10:19:34 | serhiy.storchaka | set | messages: + msg296174 |
| 2017年06月16日 09:33:11 | eric.smith | set | pull_requests: + pull_request2285 |
| 2017年06月16日 09:13:47 | eric.smith | create | |