summaryrefslogtreecommitdiffstats
path: root/Python/ceval.c
diff options
context:
space:
mode:
authorJust van Rossum <just@letterror.com>2003-02-10 08:21:10 (GMT)
committerJust van Rossum <just@letterror.com>2003-02-10 08:21:10 (GMT)
commit3aaf42c6139ed211a59b200130d1d205982b9818 (patch)
treef8bd6b0fd7101701a3eb8f5bc783cea962e59725 /Python/ceval.c
parent4adc9abc32a26f5ce5e2dada33d019f31170b5be (diff)
downloadcpython-3aaf42c6139ed211a59b200130d1d205982b9818.zip
cpython-3aaf42c6139ed211a59b200130d1d205982b9818.tar.gz
cpython-3aaf42c6139ed211a59b200130d1d205982b9818.tar.bz2
patch #683515: "Add unicode support to compile(), eval() and exec"
Incorporated nnorwitz's comment re. Py__USING_UNICODE.
Diffstat (limited to 'Python/ceval.c')
-rw-r--r--Python/ceval.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index 0f52a0b..801f08d 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -3122,7 +3122,7 @@ int
PyEval_MergeCompilerFlags(PyCompilerFlags *cf)
{
PyFrameObject *current_frame = (PyFrameObject *)PyEval_GetFrame();
- int result = 0;
+ int result = cf->cf_flags != 0;
if (current_frame != NULL) {
const int codeflags = current_frame->f_code->co_flags;
@@ -3898,16 +3898,27 @@ exec_statement(PyFrameObject *f, PyObject *prog, PyObject *globals,
locals);
}
else {
+ PyObject *tmp = NULL;
char *str;
PyCompilerFlags cf;
+ cf.cf_flags = 0;
+#ifdef Py_USING_UNICODE
+ if (PyUnicode_Check(prog)) {
+ tmp = PyUnicode_AsUTF8String(prog);
+ if (tmp == NULL)
+ return -1;
+ prog = tmp;
+ cf.cf_flags |= PyCF_SOURCE_IS_UTF8;
+ }
+#endif
if (PyString_AsStringAndSize(prog, &str, NULL))
return -1;
- cf.cf_flags = 0;
if (PyEval_MergeCompilerFlags(&cf))
v = PyRun_StringFlags(str, Py_file_input, globals,
locals, &cf);
else
v = PyRun_String(str, Py_file_input, globals, locals);
+ Py_XDECREF(tmp);
}
if (plain)
PyFrame_LocalsToFast(f, 0);