-
-
Notifications
You must be signed in to change notification settings - Fork 32k
bpo-41084: Adjust message when an f-string expression causes a SyntaxError #21084
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…Error Prefix the error message with `fstring: `, when parsing an f-string expression throws a `SyntaxError`.
b8ecf05
to
2367cdc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes look good to me.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be PyMem_Malloc
no? Any reason why you need the raw allocator?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used PyMem_RawMalloc
, because fstring_compile_expr
uses it for str
in string_parser.c
. You know best what's more suitable here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to move them to PyMem_Malloc
, but let's do that in a different PR
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. |
…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 <[email protected]>
…Error (GH-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 <[email protected]>
This comment has been minimized.
This comment has been minimized.
…Error (pythonGH-21084) Prefix the error message with `fstring: `, when parsing an f-string expression throws a `SyntaxError`.
…Error (pythonGH-21084) Prefix the error message with `fstring: `, when parsing an f-string expression throws a `SyntaxError`.
Prefix the error message with
f-string:
, when parsing an f-stringexpression which throws a
SyntaxError
.https://bugs.python.org/issue41084