mirror of
https://github.com/python/cpython.git
synced 2025-07-19 01:05:26 +00:00
Fix warn_invalid_escape_sequence()
Issue #28691: Fix warn_invalid_escape_sequence(): handle correctly DeprecationWarning raised as an exception. First clear the current exception to replace the DeprecationWarning exception with a SyntaxError exception. Unit test written by Serhiy Storchaka.
This commit is contained in:
parent
de40e1218c
commit
f9cca365c7
2 changed files with 27 additions and 1 deletions
|
@ -4129,7 +4129,13 @@ warn_invalid_escape_sequence(struct compiling *c, const node *n,
|
|||
NULL, NULL) < 0 &&
|
||||
PyErr_ExceptionMatches(PyExc_DeprecationWarning))
|
||||
{
|
||||
const char *s = PyUnicode_AsUTF8(msg);
|
||||
const char *s;
|
||||
|
||||
/* Replace the DeprecationWarning exception with a SyntaxError
|
||||
to get a more accurate error report */
|
||||
PyErr_Clear();
|
||||
|
||||
s = PyUnicode_AsUTF8(msg);
|
||||
if (s != NULL) {
|
||||
ast_error(c, n, s);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue