mirror of
https://github.com/python/cpython.git
synced 2025-11-03 03:22:27 +00:00
SF Bug #215126: Over restricted type checking on eval() function
The builtin eval() function now accepts any mapping for the locals argument. Time sensitive steps guarded by PyDict_CheckExact() to keep from slowing down the normal case. My timings so no measurable impact.
This commit is contained in:
parent
78bace7442
commit
214b1c3aae
9 changed files with 103 additions and 31 deletions
|
|
@ -291,8 +291,12 @@ class C:
|
|||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{eval}{expression\optional{, globals\optional{, locals}}}
|
||||
The arguments are a string and two optional dictionaries. The
|
||||
\var{expression} argument is parsed and evaluated as a Python
|
||||
The arguments are a string and optional globals and locals. If provided,
|
||||
\var{globals} must be a dictionary. If provided, \var{locals} can be
|
||||
any mapping object. \versionchanged[formerly \var{locals} was required
|
||||
to be a dictionary]{2.4}
|
||||
|
||||
The \var{expression} argument is parsed and evaluated as a Python
|
||||
expression (technically speaking, a condition list) using the
|
||||
\var{globals} and \var{locals} dictionaries as global and local name
|
||||
space. If the \var{globals} dictionary is present and lacks
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue