Commit f416dfbe authored by Jérome Perrin's avatar Jérome Perrin

patches/Restricted: allow collections.namedtuple

parent d9d1caa3
...@@ -205,6 +205,8 @@ ContainerAssertions[Counter] = _check_access_wrapper(Counter, _counter_white_lis ...@@ -205,6 +205,8 @@ ContainerAssertions[Counter] = _check_access_wrapper(Counter, _counter_white_lis
Counter.__guarded_setitem__ = dict.__setitem__ Counter.__guarded_setitem__ = dict.__setitem__
Counter.__guarded_delitem__ = dict.__delitem__ Counter.__guarded_delitem__ = dict.__delitem__
ModuleSecurityInfo('collections').declarePublic('namedtuple')
# given as example in Products.PythonScripts.module_access_examples # given as example in Products.PythonScripts.module_access_examples
allow_module('base64') allow_module('base64')
allow_module('binascii') allow_module('binascii')
......
...@@ -145,3 +145,11 @@ class TestRestrictedPythonSecurity(ERP5TypeTestCase): ...@@ -145,3 +145,11 @@ class TestRestrictedPythonSecurity(ERP5TypeTestCase):
'return c.most_common(1)', 'return c.most_common(1)',
expected=[('a', 3)] expected=[('a', 3)]
) )
def test_collections_namedtuple(self):
self.createAndRunScript(
'from collections import namedtuple',
'Object = namedtuple("Object", ["a", "b", "c"])',
'return Object(a=1, b=2, c=3).a',
expected=1
)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment