Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python3 compatibility #21

Merged
merged 62 commits into from May 4, 2017
Merged

python3 compatibility #21

merged 62 commits into from May 4, 2017

Conversation

dwt
Copy link
Contributor

@dwt dwt commented Sep 30, 2016

Not done yet - but easier to talk about in pull request format.

To work on this branch, you will need this patch applied, as none of the RestrictedPython stuff is ready yet.

diff --git a/setup.py b/setup.py
index 2c2d1a9..f06ae65 100644
--- a/setup.py
+++ b/setup.py
@@ -67,7 +67,8 @@ setup(name='AccessControl',
           'ExtensionClass>=4.1a1',
           'Persistence',
           'Record',
-          'RestrictedPython',
+          # 'RestrictedPython',
+          'six',
           'transaction',
           'zExceptions',
           'zope.component',
diff --git a/src/AccessControl/ZopeGuards.py b/src/AccessControl/ZopeGuards.py
index b9ef0fb..15ec89a 100644
--- a/src/AccessControl/ZopeGuards.py
+++ b/src/AccessControl/ZopeGuards.py
@@ -18,10 +18,15 @@ import sys
 import string
 import warnings

-import RestrictedPython
-from RestrictedPython.Guards import safe_builtins, full_write_guard
-from RestrictedPython.Utilities import utility_builtins
-from RestrictedPython.Eval import RestrictionCapableEval
+try:
+    import RestrictedPython
+    from RestrictedPython.Guards import safe_builtins, full_write_guard
+    from RestrictedPython.Utilities import utility_builtins
+    from RestrictedPython.Eval import RestrictionCapableEval
+except ImportError:
+    safe_builtins = {}
+    utility_builtins = {}
+    full_write_guard = None
 from .SecurityManagement import getSecurityManager
 from .SecurityInfo import secureModule
 from .SimpleObjectPolicies import Containers, ContainerAssertions
@@ -534,22 +539,22 @@ def protected_inplacevar(op, var, expr):
 # guarded_getattr from this module (ZopeGuards) and plug it into the
 # dict themselves, with key '_getattr_'.

-_safe_globals = {'__builtins__': safe_builtins,
-                 '__metaclass__': _metaclass,
-                 '_apply_':      guarded_apply,
-                 '_getitem_':    guarded_getitem,
-                 '_getiter_':    guarded_iter,
-                 '_print_':      RestrictedPython.PrintCollector,
-                 '_write_':      full_write_guard,
-                 '_inplacevar_': protected_inplacevar,
-                 # The correct implementation of _getattr_, aka
-                 # guarded_getattr, isn't known until
-                 # AccessControl.Implementation figures that out, then
-                 # stuffs it into *this* module's globals bound to
-                 # 'guarded_getattr'.  We can't know what that is at
-                 ## '_getattr_':   guarded_getattr,
-                }
-
-get_safe_globals = _safe_globals.copy
-
-RestrictionCapableEval.globals.update(_safe_globals)
+# _safe_globals = {'__builtins__': safe_builtins,
+#                  '__metaclass__': _metaclass,
+#                  '_apply_':      guarded_apply,
+#                  '_getitem_':    guarded_getitem,
+#                  '_getiter_':    guarded_iter,
+#                  '_print_':      RestrictedPython.PrintCollector,
+#                  '_write_':      full_write_guard,
+#                  '_inplacevar_': protected_inplacevar,
+#                  # The correct implementation of _getattr_, aka
+#                  # guarded_getattr, isn't known until
+#                  # AccessControl.Implementation figures that out, then
+#                  # stuffs it into *this* module's globals bound to
+#                  # 'guarded_getattr'.  We can't know what that is at
+#                  ## '_getattr_':   guarded_getattr,
+#                 }
+#
+# get_safe_globals = _safe_globals.copy
+#
+# RestrictionCapableEval.globals.update(_safe_globals)
diff --git a/src/AccessControl/tests/testZopeGuards.py b/src/AccessControl/tests/testZopeGuards.py
index f8fc6d5..385464e 100644
--- a/src/AccessControl/tests/testZopeGuards.py
+++ b/src/AccessControl/tests/testZopeGuards.py
@@ -861,6 +861,9 @@ protected_inplacevar allows inplce ops on sets:


 def test_suite():
+    # Disable tests temporarily
+    return unittest.TestSuite()
+    
     suite = unittest.TestSuite([
         doctest.DocTestSuite(),
         ])

@dwt dwt mentioned this pull request Oct 4, 2016
@icemac icemac self-requested a review May 4, 2017 14:37
Copy link
Member

@icemac icemac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 1b5488a on py3-pure-python into ** on master**.

1 similar comment
@coveralls
Copy link

coveralls commented May 4, 2017

Coverage Status

Changes Unknown when pulling 1b5488a on py3-pure-python into ** on master**.

@hannosch hannosch merged commit 1b5488a into master May 4, 2017
@stephan-hof
Copy link
Member

Now that py3-pure-python is merged into master are there any reasons to keep the branch ? I would say lets remove branches if they are not needed any more, otherwise they cause confusion.

@hannosch hannosch deleted the py3-pure-python branch June 8, 2017 18:32
@hannosch
Copy link
Contributor

hannosch commented Jun 8, 2017

The branch couldn't be deleted, as the other isort PR still wanted to merge commits into it. Since that wasn't going to get accepted as-is, I've closed that other PR and deleted the py3-pure-python branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants