Skip to content

Commit

Permalink
Make RestrictedPython compatible to Python3.7. (#138)
Browse files Browse the repository at this point in the history
* Make RestrictedPython compatible to Python3.7.
* with Python3.7 compatibility, we must check it and do not allow failure builds
* add workaround to test Python3.7
  • Loading branch information
loechel committed Oct 3, 2018
1 parent 673a45f commit d0809bf
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 6 deletions.
10 changes: 6 additions & 4 deletions .travis.yml
Expand Up @@ -15,15 +15,17 @@ matrix:
env: TOXENV=py36,py36-datetime
- python: "3.7"
env: TOXENV=py37,py37-datetime
dist: xenial
sudo: true
- python: "3.7-dev"
env: TOXENV=py37,py37-datetime
dist: xenial
sudo: true
- python: "3.8-dev"
env: TOXENV=py38,py38-datetime
dist: xenial
sudo: true
allow_failures:
- python: "3.7"
env: TOXENV=py37,py37-datetime
- python: "3.7-dev"
env: TOXENV=py37,py37-datetime
- python: "3.8-dev"
env: TOXENV=py38,py38-datetime

Expand Down
1 change: 0 additions & 1 deletion appveyor.yml
Expand Up @@ -2,7 +2,6 @@

matrix:
allow_failures:
- PROFILE: py37
- PROFILE: py38

environment:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -52,7 +52,7 @@ def read(*rnames):
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
# 'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: Implementation :: CPython',
'Topic :: Security',
],
Expand Down
2 changes: 2 additions & 0 deletions src/RestrictedPython/_compat.py
Expand Up @@ -7,6 +7,8 @@
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
IS_PY36_OR_GREATER = _version.major == 3 and _version.minor >= 6
IS_PY37_OR_GREATER = _version.major == 3 and _version.minor >= 7

if IS_PY2:
basestring = basestring # NOQA: F821 # Python 2 only built-in function
Expand Down
1 change: 1 addition & 0 deletions src/RestrictedPython/transformer.py
Expand Up @@ -71,6 +71,7 @@
'print',
'printed',
'builtins',
'breakpoint',
])


Expand Down
13 changes: 13 additions & 0 deletions tests/transformer/test_breakpoint.py
@@ -0,0 +1,13 @@
from tests import c_exec

import pytest


@pytest.mark.parametrize(*c_exec)
def test_call_breakpoint(c_exec):
"""The Python3.7+ builtin function breakpoint should not
be used and is forbidden in RestrictedPython.
"""
result = c_exec('breakpoint()')
assert result.errors == ('Line 1: "breakpoint" is a reserved name.',)
assert result.code is None

0 comments on commit d0809bf

Please sign in to comment.