Skip to content

Commit c1bc989

Browse files
author
Michael Howitz
authored
Drop support for Python 2.7 and 3.5. (#226)
This is needed to support Python 3.11 in a clear way. No longer use `coverage-python-version` so `coverage >= 6` is used.
1 parent aeffbaa commit c1bc989

31 files changed

+105
-1042
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ jobs:
2222
config:
2323
# [Python version, tox env]
2424
- ["3.9", "lint"]
25-
- ["2.7", "py27"]
26-
- ["3.5", "py35"]
2725
- ["3.6", "py36"]
2826
- ["3.7", "py37"]
2927
- ["3.8", "py38"]
@@ -63,7 +61,7 @@ jobs:
6361
- name: Coverage
6462
if: matrix.config[1] == 'coverage'
6563
run: |
66-
pip install coveralls coverage-python-version
64+
pip install coveralls
6765
coveralls --service=github
6866
env:
6967
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.meta.toml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
# https://github.com/zopefoundation/meta/tree/master/config/pure-python
33
[meta]
44
template = "pure-python"
5-
commit-id = "3a251aab94eff9cf2aa2fd87d7266593251e4b76"
5+
commit-id = "387516cfda91ee38cde868ef0d6205314a6a9bef"
66

77
[python]
88
with-pypy = false
9-
with-legacy-python = true
9+
with-legacy-python = false
1010
with-docs = true
1111
with-sphinx-doctests = true
1212
with-windows = true
@@ -22,7 +22,6 @@ testenv-deps = [
2222
"datetime: DateTime",
2323
"-cconstraints.txt",
2424
"pytest-cov",
25-
"coverage-python-version",
2625
]
2726
testenv-setenv = [
2827
"COVERAGE_FILE=.coverage.{envname}",
@@ -40,7 +39,6 @@ testenv-additional = [
4039
" mkdir",
4140
"deps =",
4241
" coverage",
43-
" coverage-python-version",
4442
" -cconstraints.txt",
4543
"setenv =",
4644
" COVERAGE_FILE=.coverage",
@@ -49,7 +47,7 @@ testenv-additional = [
4947
" coverage combine",
5048
" coverage html",
5149
" coverage report -m --fail-under=100",
52-
"depends = py27,py35,py36,py37,py38,py39,py39-datetime,py310,coverage",
50+
"depends = py36,py37,py38,py39,py39-datetime,py310,py311,coverage",
5351
]
5452
coverage-basepython = "python3.8"
5553
coverage-command = "pytest --cov=src --cov=tests --cov-report= {posargs}"

CHANGES.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
Changes
22
=======
33

4-
5.3 (unreleased)
4+
6.0 (unreleased)
55
----------------
66

7+
Backwards incompatible changes
8+
++++++++++++++++++++++++++++++
9+
10+
- Drop support for Python 2.7 and 3.5.
11+
12+
Features
13+
++++++++
14+
715
- Allow to use the package with Python 3.11 -- Caution: No security audit has
816
been done so far.
917

constraints.txt

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
1-
# Constraints for Python Packages
2-
# -----------------------------------------------
3-
# Pin Versions / Version Ranges if necessary.
1+
# Constraints for Python packages
2+
# -------------------------------
3+
# Pin versions / version ranges if necessary.
44
isort >= 4.3.2
5-
# Needed for Appveyor as long as PY2 is supported:
6-
pytest < 5 ; python_version < '3.11'
7-
# Python 3.11 needs pytest > 5
8-
pytest >= 5 ; python_version >= '3.11'
9-
# coverage 6+ no longer supports Python 2 and coverage results of older
10-
# versions cannot not combined with newer ones:
11-
coverage < 6; python_version < '3.11'
12-
# Python 3.11 requires coverage >= 6,
13-
coverage >= 6; python_version >= '3.11'
5+
pytest >= 5
6+
coverage >= 6

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Generated from:
22
# https://github.com/zopefoundation/meta/tree/master/config/pure-python
33
[bdist_wheel]
4-
universal = 1
4+
universal = 0
55

66
[flake8]
77
doctests = 1

setup.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def read(*rnames):
3232

3333
setup(
3434
name='RestrictedPython',
35-
version='5.3.dev0',
35+
version='6.0.dev0',
3636
url='https://github.com/zopefoundation/RestrictedPython',
3737
license='ZPL 2.1',
3838
description=(
@@ -46,10 +46,8 @@ def read(*rnames):
4646
'License :: OSI Approved :: Zope Public License',
4747
'Programming Language :: Python',
4848
'Operating System :: OS Independent',
49-
'Programming Language :: Python :: 2',
50-
'Programming Language :: Python :: 2.7',
5149
'Programming Language :: Python :: 3',
52-
'Programming Language :: Python :: 3.5',
50+
'Programming Language :: Python :: 3 :: Only',
5351
'Programming Language :: Python :: 3.6',
5452
'Programming Language :: Python :: 3.7',
5553
'Programming Language :: Python :: 3.8',
@@ -70,7 +68,7 @@ def read(*rnames):
7068
package_dir={'': 'src'},
7169
install_requires=[
7270
],
73-
python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <3.12", # NOQA: E501
71+
python_requires=">=3.6, <3.12",
7472
tests_require=tests_require,
7573
extras_require={
7674
'test': tests_require,

src/RestrictedPython/Eval.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,10 @@
1414

1515
import ast
1616

17-
from ._compat import IS_PY2
1817
from .compile import compile_restricted_eval
1918

2019

21-
if IS_PY2: # pragma: PY2
22-
from string import maketrans
23-
else: # pragma: PY3
24-
maketrans = str.maketrans
25-
26-
27-
nltosp = maketrans('\r\n', ' ')
20+
nltosp = str.maketrans('\r\n', ' ')
2821

2922
# No restrictions.
3023
default_guarded_getattr = getattr
@@ -40,7 +33,7 @@ def default_guarded_getiter(ob):
4033
return ob
4134

4235

43-
class RestrictionCapableEval(object):
36+
class RestrictionCapableEval:
4437
"""A base class for restricted code."""
4538

4639
globals = {'__builtins__': None}

src/RestrictedPython/Guards.py

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,13 @@
1515
# AccessControl.ZopeGuards contains a large set of wrappers for builtins.
1616
# DocumentTemplate.DT_UTil contains a few.
1717

18-
from RestrictedPython import _compat
18+
import builtins
1919

2020

21-
if _compat.IS_PY2: # pragma: PY2
22-
import __builtin__ as builtins
23-
else: # pragma: PY3
24-
# Do not attempt to use this package on Python2.7 as there
25-
# might be backports for this package such as future.
26-
import builtins
27-
2821
safe_builtins = {}
2922

3023
_safe_names = [
24+
'__build_class__',
3125
'None',
3226
'False',
3327
'True',
@@ -109,23 +103,6 @@
109103
'ZeroDivisionError',
110104
]
111105

112-
if _compat.IS_PY2: # pragma: PY2
113-
_safe_names.extend([
114-
'basestring',
115-
'cmp',
116-
'long',
117-
'unichr',
118-
'unicode',
119-
'xrange',
120-
])
121-
_safe_exceptions.extend([
122-
'StandardError',
123-
])
124-
else: # pragma: PY3
125-
_safe_names.extend([
126-
'__build_class__', # needed to define new classes
127-
])
128-
129106
for name in _safe_names:
130107
safe_builtins[name] = getattr(builtins, name)
131108

@@ -202,7 +179,7 @@ def handler(self, *args):
202179
f(*args)
203180
return handler
204181

205-
class Wrapper(object):
182+
class Wrapper:
206183
def __init__(self, ob):
207184
self.__dict__['ob'] = ob
208185

@@ -264,7 +241,7 @@ def safer_getattr(object, name, default=None, getattr=getattr):
264241
http://lucumr.pocoo.org/2016/12/29/careful-with-str-format/
265242
266243
"""
267-
if isinstance(object, _compat.basestring) and name == 'format':
244+
if isinstance(object, str) and name == 'format':
268245
raise NotImplementedError(
269246
'Using format() on a %s is not safe.' % object.__class__.__name__)
270247
if name.startswith('_'):

src/RestrictedPython/PrintCollector.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@
1010
# FOR A PARTICULAR PURPOSE
1111
#
1212
##############################################################################
13-
from __future__ import print_function
1413

1514

16-
class PrintCollector(object):
15+
class PrintCollector:
1716
"""Collect written text, and return it when called."""
1817

1918
def __init__(self, _getattr_=None):

src/RestrictedPython/Utilities.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
try:
2929
import DateTime
30-
utility_builtins['DateTime'] = DateTime.DateTime # pragma: no cover
30+
utility_builtins['DateTime'] = DateTime.DateTime
3131
except ImportError:
3232
pass
3333

0 commit comments

Comments
 (0)