diff options
| author | Martin v. Löwis <martin@v.loewis.de> | 2006-03-22 13:55:50 +0000 |
|---|---|---|
| committer | Martin v. Löwis <martin@v.loewis.de> | 2006-03-22 13:55:50 +0000 |
| commit | 73c8c2c3dd0ff10a31ee4c07273d7f1f3343561a (patch) | |
| tree | f478549d94e803fa2a824f68971b25bebca5a205 /Python | |
| parent | 88fd50038b2ddbcbb162a87387a78e6f208bc849 (diff) | |
| download | cpython-git-73c8c2c3dd0ff10a31ee4c07273d7f1f3343561a.tar.gz | |
Change SystemError into SyntaxError, when a Unicode string
containing an encoding declaration is compile()d. Fixes
#1115379.
Diffstat (limited to 'Python')
| -rw-r--r-- | Python/compile.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Python/compile.c b/Python/compile.c index a5bd09eb4d..4a7ec8c23e 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -4952,6 +4952,12 @@ jcompile(node *n, const char *filename, struct compiling *base, return NULL; if (flags && flags->cf_flags & PyCF_SOURCE_IS_UTF8) { sc.c_encoding = "utf-8"; + if (TYPE(n) == encoding_decl) { + com_error(&sc, PyExc_SyntaxError, + "encoding declaration in Unicode string"); + co = NULL; + goto exit; + } } else if (TYPE(n) == encoding_decl) { sc.c_encoding = STR(n); n = CHILD(n, 0); @@ -5044,7 +5050,7 @@ jcompile(node *n, const char *filename, struct compiling *base, PyErr_SetString(PyExc_SystemError, "lost syntax error"); } exit: - if (base == NULL) { + if (base == NULL && sc.c_symtable != NULL) { PySymtable_Free(sc.c_symtable); sc.c_symtable = NULL; } |
