Mercurial > cpython-lru_cache-weakref
diff Python/ast.c @ 37162:b4d92ef2f338 legacy-trunk
Forward port MvL's fix in 43227:
Fix crash when a Unicode string containing an encoding declaration is
compile()d. Fixes #1115379.
| author | Neal Norwitz <nnorwitz@gmail.com> |
|---|---|
| date | Thu, 23 Mar 2006 05:39:47 +0000 |
| parents | b01c80d88267 |
| children | 9d8b33aff60c |
line wrap: on
line diff
--- a/Python/ast.c Thu Mar 23 05:38:33 2006 +0000 +++ b/Python/ast.c Thu Mar 23 05:39:47 2006 +0000 @@ -191,6 +191,10 @@ if (flags && flags->cf_flags & PyCF_SOURCE_IS_UTF8) { c.c_encoding = "utf-8"; + if (TYPE(n) == encoding_decl) { + ast_error(n, "encoding declaration in Unicode string"); + goto error; + } } else if (TYPE(n) == encoding_decl) { c.c_encoding = STR(n); n = CHILD(n, 0);
