Skip to content

Commit

Permalink
Merge pull request #48 from zopefoundation/py3_imports
Browse files Browse the repository at this point in the history
Small improvements to Python 3 support using six.
  • Loading branch information
rudaporto committed Oct 24, 2017
2 parents fe688c9 + fe7c6be commit 6408b5d
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 13 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -7,6 +7,7 @@ python:
- 3.6

install:
- pip install six==1.10.0 # force here to avoid conflit with zc.recipe.testrunner
- pip install -U setuptools==33.1.1
- pip install coveralls coverage
- pip install zc.buildout
Expand Down
2 changes: 1 addition & 1 deletion CHANGES.rst
Expand Up @@ -6,7 +6,7 @@ For changes before version 3.0, see ``HISTORY.rst``.
4.0b2 (unreleased)
------------------

- Nothing changed yet.
- Python 2 / 3 import improvements.


4.0b1 (2017-09-15)
Expand Down
6 changes: 1 addition & 5 deletions src/AccessControl/SecurityManagement.py
Expand Up @@ -41,11 +41,7 @@ def setSecurityManager(manager):

# AccessControl.Implementation inserts SecurityManager.

try:
from thread import get_ident
except ImportError:
def get_ident():
return 0
from six.moves._thread import get_ident

_managers = {}

Expand Down
2 changes: 1 addition & 1 deletion src/AccessControl/ZopeGuards.py
Expand Up @@ -13,7 +13,6 @@

from __future__ import absolute_import

from functools import reduce
import math
import random
import six
Expand All @@ -27,6 +26,7 @@
from RestrictedPython.Guards import guarded_unpack_sequence
from RestrictedPython.Guards import safe_builtins
from RestrictedPython.Utilities import utility_builtins
from six.moves import reduce
from zExceptions import Unauthorized

from AccessControl.SecurityInfo import secureModule
Expand Down
4 changes: 2 additions & 2 deletions src/AccessControl/__init__.py
Expand Up @@ -49,8 +49,8 @@

if six.PY2:
# Same for unicode instead on Python 2:
rules = dict([(m, True) for m in dir(unicode) if not m.startswith('_')])
rules = dict([(m, True) for m in dir(six.text_type) if not m.startswith('_')])
rules['format'] = safe_format
allow_type(unicode, rules)
allow_type(six.text_type, rules)

del six
7 changes: 3 additions & 4 deletions src/AccessControl/tests/testZopeSecurityPolicy.py
Expand Up @@ -23,10 +23,9 @@
from AccessControl.SecurityManagement import SecurityContext
from AccessControl.userfolder import UserFolder

try:
import _thread as thread # Py3
except ImportError:
import thread

from six.moves import _thread as thread


user_roles = ('RoleOfUser',)
eo_roles = ('RoleOfExecutableOwner',)
Expand Down

0 comments on commit 6408b5d

Please sign in to comment.