Commit fdb23c44 authored by Arnaud Fontaine's avatar Arnaud Fontaine

py3: Make py3 API available on py2.

Standard library was reorganized (urlparse => urllib, httplib => http...) in PEP
3108. install_aliases() from `future` egg provides module aliases so that
imports work on both python2 and python3.
parent 1c57528b
# Modules aliases to support both python2 and python3
from future import standard_library
standard_library.install_aliases()
import argparse
from io import BytesIO
import logging
......
......@@ -11,6 +11,7 @@
#
##############################################################################
import six
import copy
import sys
import types
......@@ -307,10 +308,32 @@ import hashlib
allow_type(type(hashlib.md5()))
allow_module('time')
allow_module('unicodedata')
allow_module('urlparse')
import urlparse
allow_type(urlparse.ParseResult)
allow_type(urlparse.SplitResult)
if six.PY2:
import urlparse
allow_module('urlparse')
allow_type(urlparse.ParseResult)
allow_type(urlparse.SplitResult)
ModuleSecurityInfo('urllib').declarePublic(
'urlencode',
'quote', 'unquote',
'quote_plus', 'unquote_plus',
)
# six.PY2 with future.standard_library.install_aliases()
# six.PY3
import urllib.parse
allow_module('urllib.parse')
allow_type(urllib.parse.ParseResult)
allow_type(urllib.parse.SplitResult)
ModuleSecurityInfo('urllib.parse').declarePublic(
'urlencode',
'quote', 'unquote',
'quote_plus', 'unquote_plus',
)
allow_module('struct')
ModuleSecurityInfo('os.path').declarePublic(
......@@ -371,12 +394,6 @@ safe_builtins['__import__'] = guarded_import
ModuleSecurityInfo('transaction').declarePublic('doom')
ModuleSecurityInfo('urllib').declarePublic(
'urlencode',
'quote', 'unquote',
'quote_plus', 'unquote_plus',
)
import hmac
allow_module('hmac')
# HMAC does not sub-class object so ContainerAssertions
......
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