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

Conversation

Projects
None yet
8 participants
@dwt
Contributor

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 referenced this pull request Oct 4, 2016

Closed

Port to Python 3 #8

hannosch added some commits Jan 20, 2017

Remove the PURE_PYTHON flag.
AccessControl can't support a pure Python version, as the pure Python
implementation of Acquisition/ExtensionClass can't be perfect enough
and isn't able to proxy class dict proxies.

@hannosch hannosch referenced this pull request Jan 22, 2017

Closed

Python 3 compatibility #39

22 of 22 tasks complete

hannosch added some commits Feb 2, 2017

Make some more progress on porting the cAccessControl.c file to Py3.
This currently runs into a problem in both Acquisition.h (which
needs zopefoundation/Acquisition#13 to be merged and released, so
the aq_init macro uses PyCapsule_Import) and with
ExtensionClass.h (zopefoundation/ExtensionClass#14).

icemac and others added some commits Feb 1, 2017

Flake8 (#30)
* flake8 checks
Merge branch 'master' into py3-pure-python
# Conflicts:
#	CHANGES.rst
#	setup.py
#	src/AccessControl/Permission.py
#	src/AccessControl/tests/testZopeGuards.py
#	src/AccessControl/users.py

@icemac icemac self-requested a review May 4, 2017

@icemac

icemac approved these changes May 4, 2017

LGTM

@coveralls

This comment has been minimized.

coveralls commented May 4, 2017

Coverage Status

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

1 similar comment
@coveralls

This comment has been minimized.

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

3 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
coverage/coveralls First build on master at 82.646%
Details
@stephan-hof

This comment has been minimized.

Member

stephan-hof commented Jun 8, 2017

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 Jun 8, 2017

@hannosch

This comment has been minimized.

Member

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