Skip to content

Commit

Permalink
Merge branch 'Python3_update' into python3_docs_consolidation
Browse files Browse the repository at this point in the history
  • Loading branch information
loechel committed Jan 31, 2017
2 parents 11c229f + d4bd9d0 commit fa034ab
Show file tree
Hide file tree
Showing 12 changed files with 707 additions and 883 deletions.
23 changes: 3 additions & 20 deletions src/RestrictedPython/Guards.py
Expand Up @@ -15,7 +15,7 @@
# AccessControl.ZopeGuards contains a large set of wrappers for builtins.
# DocumentTemplate.DT_UTil contains a few.

import sys
from ._compat import IS_PY2


try:
Expand Down Expand Up @@ -104,8 +104,7 @@
'ZeroDivisionError',
]

version = sys.version_info
if version >= (2, 7) and version < (2, 8):
if IS_PY2:
_safe_names.extend([
'basestring',
'cmp',
Expand All @@ -118,22 +117,6 @@
'StandardError',
])

if version >= (3, 0):
_safe_names.extend([

])
_safe_exceptions.extend([

])

if version >= (3, 5):
_safe_names.extend([

])
_safe_exceptions.extend([

])


for name in _safe_names:
safe_builtins[name] = getattr(builtins, name)
Expand Down Expand Up @@ -246,7 +229,7 @@ def __init__(self, ob):
def _full_write_guard():
# Nested scope abuse!
# safetype and Wrapper variables are used by guard()
safetype = {dict: True, list: True}.has_key if version < (3, 0) else {dict: True, list: True}.keys
safetype = {dict: True, list: True}.has_key if IS_PY2 else {dict: True, list: True}.keys
Wrapper = _write_wrapper()

def guard(ob):
Expand Down
8 changes: 8 additions & 0 deletions src/RestrictedPython/_compat.py
@@ -0,0 +1,8 @@
import sys


_version = sys.version_info
IS_PY2 = _version.major == 2
IS_PY3 = _version.major == 3
IS_PY34_OR_GREATER = _version.major == 3 and _version.minor >= 4
IS_PY35_OR_GREATER = _version.major == 3 and _version.minor >= 5
301 changes: 0 additions & 301 deletions src/RestrictedPython/tests/before_and_after.py

This file was deleted.

0 comments on commit fa034ab

Please sign in to comment.