From: Jeremy Hylton Date: Sun, 25 Feb 2007 15:57:45 +0000 (+0000) Subject: Fix crash in exec when unicode filename can't be decoded. X-Git-Tag: v2.6a1~2149 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c5ceb251b395c207ed0411d1e94f0fd3703157ea;p=python Fix crash in exec when unicode filename can't be decoded. I can't think of an easy way to test this behavior. It only occurs when the file system default encoding and the interpreter default encoding are different, such that you can open the file but not decode its name. --- diff --git a/Misc/NEWS b/Misc/NEWS index d7eab9cbc0..4428670b40 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -121,6 +121,7 @@ Core and builtins - with and as are now keywords. +- Bug #1664966: Fix crash in exec if Unicode filename can't be decoded. Library ------- diff --git a/Python/ceval.c b/Python/ceval.c index ffdc75bfa6..9e063029a3 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -4202,6 +4202,8 @@ exec_statement(PyFrameObject *f, PyObject *prog, PyObject *globals, else if (PyFile_Check(prog)) { FILE *fp = PyFile_AsFile(prog); char *name = PyString_AsString(PyFile_Name(prog)); + if (name == NULL) + return -1; PyCompilerFlags cf; cf.cf_flags = 0; if (PyEval_MergeCompilerFlags(&cf))