Mercurial > cpython-lru_cache-weakref
diff Python/bltinmodule.c @ 19357:be9b50704e4c legacy-trunk
Fix for bug [#452230] future division isn't propagated.
builtin_eval wasn't merging in the compiler flags from the current frame;
I suppose we never noticed this before because future division is the
first future-feature that can affect expressions (nested_scopes and
generators had only statement-level effects).
| author | Tim Peters <tim.peters@gmail.com> |
|---|---|
| date | Fri, 17 Aug 2001 23:04:59 +0000 |
| parents | d5acff178ad5 |
| children | 3b5f34c5bc6c |
line wrap: on
line diff
--- a/Python/bltinmodule.c Fri Aug 17 22:37:02 2001 +0000 +++ b/Python/bltinmodule.c Fri Aug 17 23:04:59 2001 +0000 @@ -523,6 +523,7 @@ PyObject *cmd; PyObject *globals = Py_None, *locals = Py_None; char *str; + PyCompilerFlags cf; if (!PyArg_ParseTuple(args, "O|O!O!:eval", &cmd, @@ -536,11 +537,13 @@ } else if (locals == Py_None) locals = globals; + if (PyDict_GetItemString(globals, "__builtins__") == NULL) { if (PyDict_SetItemString(globals, "__builtins__", PyEval_GetBuiltins()) != 0) return NULL; } + if (PyCode_Check(cmd)) { if (PyTuple_GET_SIZE(((PyCodeObject *)cmd)->co_freevars) > 0) { PyErr_SetString(PyExc_TypeError, @@ -549,6 +552,7 @@ } return PyEval_EvalCode((PyCodeObject *) cmd, globals, locals); } + if (!PyString_Check(cmd) && !PyUnicode_Check(cmd)) { PyErr_SetString(PyExc_TypeError, @@ -559,7 +563,10 @@ return NULL; while (*str == ' ' || *str == '\t') str++; - return PyRun_String(str, Py_eval_input, globals, locals); + + cf.cf_flags = 0; + (void)PyEval_MergeCompilerFlags(&cf); + return PyRun_StringFlags(str, Py_eval_input, globals, locals, &cf); } static char eval_doc[] =
