summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2020-06-08 07:19:27 (GMT)
committerGitHub <noreply@github.com>2020-06-08 07:19:27 (GMT)
commit3deded947c79daf01b5f987ff43b7f067776f905 (patch)
tree8dbc0d559db0ccdc4957021bac4a769d72731720
parentbe5ed59e29106634a0d02d96ed35fb71ed61cb6d (diff)
downloadcpython-3deded947c79daf01b5f987ff43b7f067776f905.zip
cpython-3deded947c79daf01b5f987ff43b7f067776f905.tar.gz
cpython-3deded947c79daf01b5f987ff43b7f067776f905.tar.bz2
Deny eval() direct access to builtins (GH-20713) (GH-20714)
-rw-r--r--Lib/collections/__init__.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/Lib/collections/__init__.py b/Lib/collections/__init__.py
index 011a0c1..d11d120 100644
--- a/Lib/collections/__init__.py
+++ b/Lib/collections/__init__.py
@@ -407,7 +407,8 @@ def namedtuple(typename, field_names, *, rename=False, defaults=None, module=Non
# Create all the named tuple methods to be added to the class namespace
s = f'lambda _cls, {arg_list}: _tuple_new(_cls, ({arg_list}))'
- namespace = {'_tuple_new': tuple_new, '__name__': f'namedtuple_{typename}'}
+ namespace = {'_tuple_new': tuple_new, '__builtins__': None,
+ '__name__': f'namedtuple_{typename}'}
__new__ = eval(s, namespace)
__new__.__doc__ = f'Create new instance of {typename}({arg_list})'
if defaults is not None: