summaryrefslogtreecommitdiff
path: root/Python
diff options
context:
space:
mode:
Diffstat (limited to 'Python')
-rw-r--r--Python/ast.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/Python/ast.c b/Python/ast.c
index bfae6ed7d4..14bcdb1b0a 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -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);
}