bpo-41084: Adjust message when an f-string expression causes a SyntaxError#21084
Merged
Conversation
…Error Prefix the error message with `fstring: `, when parsing an f-string expression throws a `SyntaxError`.
Member
Author
lysnikolaou
force-pushed
the
fstring-error-message
branch
from
June 23, 2020 16:49
b8ecf05 to
2367cdc
Compare
ericvsmith
approved these changes
Jun 23, 2020
ericvsmith
left a comment
Member
There was a problem hiding this comment.
The changes look good to me.
pablogsal
reviewed
Jun 23, 2020
| const char *fstring_msg = "f-string: "; | ||
| Py_ssize_t len = strlen(fstring_msg) + strlen(errmsg); | ||
|
|
||
| char *new_errmsg = PyMem_RawMalloc(len + 1); // Lengths of both strings plus NULL character |
Member
There was a problem hiding this comment.
This should be PyMem_Malloc no? Any reason why you need the raw allocator?
Member
Author
There was a problem hiding this comment.
I used PyMem_RawMalloc, because fstring_compile_expr uses it for str in string_parser.c. You know best what's more suitable here.
Member
There was a problem hiding this comment.
I would like to move them to PyMem_Malloc, but let's do that in a different PR
Contributor
|
Thanks @lysnikolaou for the PR, and @pablogsal for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9. |
|
GH-21188 is a backport of this pull request to the 3.9 branch. |
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this pull request
Jun 27, 2020
…Error (pythonGH-21084) Prefix the error message with `fstring: `, when parsing an f-string expression throws a `SyntaxError`. (cherry picked from commit 2e0a920) Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
This comment has been minimized.
This comment has been minimized.
fasih
pushed a commit
to fasih/cpython
that referenced
this pull request
Jun 29, 2020
…Error (pythonGH-21084) Prefix the error message with `fstring: `, when parsing an f-string expression throws a `SyntaxError`.
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.
Prefix the error message with
f-string:, when parsing an f-stringexpression which throws a
SyntaxError.https://bugs.python.org/issue41084