Skip to content

Commit

Permalink
Merge pull request #11 from ehfeng/master
Browse files Browse the repository at this point in the history
Add built-in function 'set'
  • Loading branch information
tseaver committed Mar 1, 2017
2 parents 2d15393 + 9842dc8 commit 02882e1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/RestrictedPython/Guards.py
Expand Up @@ -23,7 +23,7 @@
for name in ['False', 'None', 'True', 'abs', 'basestring', 'bool', 'callable',
'chr', 'cmp', 'complex', 'divmod', 'float', 'hash',
'hex', 'id', 'int', 'isinstance', 'issubclass', 'len',
'long', 'oct', 'ord', 'pow', 'range', 'repr', 'round',
'long', 'oct', 'ord', 'pow', 'range', 'repr', 'round', 'set',
'str', 'tuple', 'unichr', 'unicode', 'xrange', 'zip']:

safe_builtins[name] = __builtins__[name]
Expand Down
5 changes: 5 additions & 0 deletions src/RestrictedPython/tests/restricted_module.py
Expand Up @@ -33,6 +33,11 @@ def try_map():
print map(inc, x),
return printed

def try_set():
x = [1, 1, 2, 3]
print set(x)
return printed

def try_apply():
def f(x, y, z):
return x + y + z
Expand Down
4 changes: 4 additions & 0 deletions src/RestrictedPython/tests/testRestrictions.py
Expand Up @@ -251,6 +251,10 @@ def checkTryMap(self):
res = self.execFunc('try_map')
self.assertEqual(res, "[2, 3, 4]")

def checkTrySet(self):
res = self.execFunc('try_set')
self.assertEqual(res, "set([1, 2, 3])")

def checkApply(self):
del apply_wrapper_called[:]
res = self.execFunc('try_apply')
Expand Down

0 comments on commit 02882e1

Please sign in to comment.