bpo-37050: Remove expr_text from FormattedValue ast node, use Constant node instead#13597
Merged
ericvsmith merged 7 commits intopython:masterfrom May 27, 2019
ericvsmith:remove-expr_text-from-FormattedValue-ast-node
Merged
bpo-37050: Remove expr_text from FormattedValue ast node, use Constant node instead#13597ericvsmith merged 7 commits intopython:masterfrom ericvsmith:remove-expr_text-from-FormattedValue-ast-node
ericvsmith merged 7 commits intopython:masterfrom
ericvsmith:remove-expr_text-from-FormattedValue-ast-node
Conversation
| eq("(x:=10)") | ||
| eq("f'{(x:=10):=10}'") | ||
|
|
||
| # f-strings with '=' don't round trip very well, so set the expected |
Member
There was a problem hiding this comment.
I think it is worth to move this into separate method. It can even be decorated as cpython_only. I think that if an alternate implementation is smart enough to roundtrip these case, it is still a valid Python implementation.
|
|
||
| *expression is set to the expression. For an '=' "debug" expression, | ||
| *expr_text is set to the debug text (the original text of the expression, | ||
| *including the '=' and any whitespace around it, as a string object). If |
Member
There was a problem hiding this comment.
Suggested change
| *including the '=' and any whitespace around it, as a string object). If | |
| including the '=' and any whitespace around it, as a string object). If |
| *expression is set to the expression. For an '=' "debug" expression, | ||
| *expr_text is set to the debug text (the original text of the expression, | ||
| *including the '=' and any whitespace around it, as a string object). If | ||
| *not a debug expression, *expr_text set to NULL. */ |
Member
There was a problem hiding this comment.
Suggested change
| *not a debug expression, *expr_text set to NULL. */ | |
| not a debug expression, *expr_text set to NULL. */ |
| expr_text_end = *str; | ||
|
|
||
| /* Set *expr_text to the text of the expression. */ | ||
| *expr_text = PyUnicode_FromStringAndSize(expr_start, *str-expr_start); |
Member
There was a problem hiding this comment.
Note that *expr_text can be leaked at the error label.
| /* We have a literal, concatenate it. */ | ||
| assert(PyUnicode_GET_LENGTH(literal[i]) != 0); | ||
| if (FstringParser_ConcatAndDel(state, literal[i]) < 0) | ||
| return -1; |
Member
There was a problem hiding this comment.
literal[1] can be leaked here.
Member
Author
|
Thanks, Serhiy. I was in a rush to get this change in for B1. I'll address these in a subsequent commit. |
DinoV
pushed a commit
to DinoV/cpython
that referenced
this pull request
Jan 14, 2020
…t node instead (pythonGH-13597) When using the "=" debug functionality of f-strings, use another Constant node (or a merged constant node) instead of adding expr_text to the FormattedValue node.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://bugs.python.org/issue37050