Commit 415a59c4 authored by Jérome Perrin's avatar Jérome Perrin Committed by Arnaud Fontaine

restricted py3

parent ecf079ce
......@@ -29,11 +29,25 @@ Restricted collections module.
From restricted python, use "import collections" (see patches/Restricted.py).
"""
import six
from collections import (
Counter, defaultdict, deque, OrderedDict, namedtuple as _namedtuple)
if six.PY2:
def namedtuple(typename, field_names, verbose=False, rename=False):
ret = _namedtuple(typename, field_names, verbose, rename)
ret.__allow_access_to_unprotected_subobjects__ = 1
return ret
else:
def namedtuple(typename, field_names, rename=False, defaults=None, module=None):
ret = _namedtuple(
typename,
field_names,
rename=rename,
defaults=defaults,
module=module
)
ret.__allow_access_to_unprotected_subobjects__ = 1
return ret
def namedtuple(typename, field_names, verbose=False, rename=False):
ret = _namedtuple(typename, field_names, verbose, rename)
ret.__allow_access_to_unprotected_subobjects__ = 1
return ret
......@@ -48,5 +48,6 @@ from AccessControl.ZopeGuards import SafeIter
iterkeys = lambda d: SafeIter(_six.iterkeys(d), d)
itervalues = lambda d: SafeIter(_six.itervalues(d), d)
from AccessControl.ZopeGuards import safe_builtins as _safe_builtins
_safe_builtins['xrange'] = _six.moves.xrange
if PY2:
from AccessControl.ZopeGuards import safe_builtins as _safe_builtins
_safe_builtins['xrange'] = _six.moves.xrange
......@@ -385,6 +385,8 @@ import six.moves.urllib.parse
allow_module('six.moves.urllib.parse')
allow_type(six.moves.urllib.parse.ParseResult)
allow_type(six.moves.urllib.parse.SplitResult)
# BBB this is different type on python3
allow_type(type(six.moves.urllib.parse.urldefrag('')))
ModuleSecurityInfo('six.moves.urllib.parse').declarePublic(
'urlencode',
'quote', 'unquote',
......
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