diff options
Diffstat (limited to 'Python/bltinmodule.c')
-rw-r--r-- | Python/bltinmodule.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 047cca0..ff5a512 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -977,9 +977,13 @@ builtin_eval_impl(PyObject *module, PyObject *source, PyObject *globals, } if (PyCode_Check(source)) { + if (PySys_Audit("exec", "O", source) < 0) { + return NULL; + } + if (PyCode_GetNumFree((PyCodeObject *)source) > 0) { PyErr_SetString(PyExc_TypeError, - "code object passed to eval() may not contain free variables"); + "code object passed to eval() may not contain free variables"); return NULL; } return PyEval_EvalCode(source, globals, locals); @@ -1061,6 +1065,10 @@ builtin_exec_impl(PyObject *module, PyObject *source, PyObject *globals, } if (PyCode_Check(source)) { + if (PySys_Audit("exec", "O", source) < 0) { + return NULL; + } + if (PyCode_GetNumFree((PyCodeObject *)source) > 0) { PyErr_SetString(PyExc_TypeError, "code object passed to exec() may not " @@ -1207,7 +1215,14 @@ static PyObject * builtin_id(PyModuleDef *self, PyObject *v) /*[clinic end generated code: output=0aa640785f697f65 input=5a534136419631f4]*/ { - return PyLong_FromVoidPtr(v); + PyObject *id = PyLong_FromVoidPtr(v); + + if (id && PySys_Audit("builtins.id", "O", id) < 0) { + Py_DECREF(id); + return NULL; + } + + return id; } @@ -1986,6 +2001,10 @@ builtin_input_impl(PyObject *module, PyObject *prompt) return NULL; } + if (PySys_Audit("builtins.input", "O", prompt ? prompt : Py_None) < 0) { + return NULL; + } + /* First of all, flush stderr */ tmp = _PyObject_CallMethodId(ferr, &PyId_flush, NULL); if (tmp == NULL) @@ -2116,6 +2135,13 @@ builtin_input_impl(PyObject *module, PyObject *prompt) Py_DECREF(stdin_errors); Py_XDECREF(po); PyMem_FREE(s); + + if (result != NULL) { + if (PySys_Audit("builtins.input/result", "O", result) < 0) { + return NULL; + } + } + return result; _readline_errors: |