Skip to content

Commit d2912bf

Browse files
Support Python 3.12 and 3.13. (#45)
* Skip testing the crypt module if it does not exist, like on Python 3.13. * Support Python 3.12 and 3.13. * Require ``legacy-cgi`` on Python 3.13 or higher so ``WebOb`` works. * Update GitHub Actions versions. Maybe then setup-python can find Python 3.13. * gha: allow Python prereleases, so we can test with 3.13. * gha: downgrade artifact action versions. ```
1 parent 2f11841 commit d2912bf

File tree

7 files changed

+49
-28
lines changed

7 files changed

+49
-28
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,18 @@ jobs:
1919
- "3.9"
2020
- "3.10"
2121
- "3.11"
22+
- "3.12"
23+
- "3.13"
2224
steps:
2325

2426
- name: Checkout
25-
uses: actions/checkout@v2
27+
uses: actions/checkout@v4
2628

2729
- name: Setup Python
28-
uses: actions/setup-python@v2
30+
uses: actions/setup-python@v5
2931
with:
3032
python-version: ${{ matrix.python }}
33+
allow-prereleases: true
3134

3235
- name: Install nox
3336
run: |
@@ -53,10 +56,10 @@ jobs:
5356
steps:
5457

5558
- name: Checkout
56-
uses: actions/checkout@v2
59+
uses: actions/checkout@v4
5760

5861
- name: Setup Python
59-
uses: actions/setup-python@v2
62+
uses: actions/setup-python@v5
6063
with:
6164
python-version: "3.10"
6265

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ docs/_build/
66
*.pyc
77
*.egg-info
88
.coverage
9+
.coverage.py*
910
coverage.xml
1011
nosetests.xml

CHANGES.rst

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
repoze.who Changelog
22
====================
33

4+
3.0.0b2 (unreleased)
5+
--------------------
6+
7+
- Skip testing the crypt module if it does not exist, like on Python 3.13.
8+
9+
- Require ``legacy-cgi`` on Python 3.13 or higher so ``WebOb`` works.
10+
11+
- Add support for Python 3.12 and 3.13.
12+
413
3.0.0b1 (2023-01-16)
514
--------------------
615

@@ -106,7 +115,7 @@ repoze.who Changelog
106115
2.0b1 (2011-05-24)
107116
------------------
108117

109-
- Enabled standard use of logging module's configuration mechanism.
118+
- Enabled standard use of logging module's configuration mechanism.
110119
See http://docs.python.org/dev/howto/logging.html#configuring-logging-for-a-library
111120
Thanks to jgoldsmith for the patch: http://bugs.repoze.org/issue178
112121

@@ -180,7 +189,7 @@ repoze.who Changelog
180189
- Added ``repoze.who.config:make_api_factory_with_config``, a convenience
181190
method for applications which want to set up their own API Factory from
182191
a configuration file.
183-
192+
184193
- Fixed example call to ``repoze.who.config:make_middleware_with_config``
185194
(added missing ``global_config`` argument). See
186195
http://bugs.repoze.org/issue114
@@ -248,7 +257,7 @@ Backward Incompatibilities
248257
~~~~~~~~~~~~~~~~~~~~~~~~~~
249258

250259
- The middleware used to allow identifier plugins to "pre-authenticate"
251-
an identity. This feature is no longer supported: the ``auth_tkt``
260+
an identity. This feature is no longer supported: the ``auth_tkt``
252261
plugin, which used to use the feature, is now configured to work as
253262
an authenticator plugin (as well as an identifier).
254263

@@ -263,7 +272,7 @@ Backward Incompatibilities
263272

264273
- The following (non-API) functions moved from ``repoze.who.middleware`` to
265274
``repoze.who.api``:
266-
275+
267276
- ``make_registries``
268277
- ``match_classification``
269278
- ``verify``
@@ -274,7 +283,7 @@ Backward Incompatibilities
274283
-------------------
275284

276285
- Issue #104: AuthTkt plugin was passing an invalid cookie value in
277-
headers from ``forget``, and was not setting the ``Max-Age`` and
286+
headers from ``forget``, and was not setting the ``Max-Age`` and
278287
``Expires`` attributes of those cookies.
279288

280289

repoze/who/plugins/htpasswd.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ def _same_string(x, y):
9191
return len(mismatches) == 0
9292

9393
def crypt_check(password, hashed):
94+
# Note: the crypt module is deprecated since Python 3.11
95+
# and will be removed in Python 3.13.
96+
# win32 does not have a crypt library at all.
9497
from crypt import crypt
9598
salt = hashed[:2]
9699
return _same_string(hashed, crypt(password, salt))

repoze/who/plugins/tests/test_htpasswd.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
import unittest
22

33

4+
try:
5+
from crypt import crypt
6+
except ImportError:
7+
# The crypt module is deprecated since Python 3.11
8+
# and will be removed in Python 3.13.
9+
# win32 does not have a crypt library at all.
10+
crypt = None
11+
12+
413
class TestHTPasswdPlugin(unittest.TestCase):
514

615
def _getTargetClass(self):
@@ -106,14 +115,8 @@ def warn(self, msg):
106115
self.assertEqual(len(logger.warnings), 1)
107116
self.assertTrue('could not open htpasswd' in logger.warnings[0])
108117

118+
@unittest.skipIf(crypt is None, "crypt module not available")
109119
def test_crypt_check(self):
110-
import sys
111-
# win32 does not have a crypt library, don't
112-
# fail here
113-
if "win32" == sys.platform: # pragma: no cover
114-
return
115-
116-
from crypt import crypt
117120
salt = '123'
118121
hashed = crypt('password', salt)
119122
from repoze.who.plugins.htpasswd import crypt_check

setup.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ def _read_file(filename):
2626

2727
README = _read_file('README.rst')
2828
CHANGES = _read_file('CHANGES.rst')
29-
tests_require = ['WebOb', 'zope.interface']
30-
docs_extras = tests_require + ['Sphinx', 'repoze.sphinx.autointerface']
3129

3230
setup(name='repoze.who',
3331
version='3.0.0b1',
@@ -43,6 +41,8 @@ def _read_file(filename):
4341
"Programming Language :: Python :: 3.9",
4442
"Programming Language :: Python :: 3.10",
4543
"Programming Language :: Python :: 3.11",
44+
"Programming Language :: Python :: 3.12",
45+
"Programming Language :: Python :: 3.13",
4646
"Programming Language :: Python :: Implementation :: CPython",
4747
"Programming Language :: Python :: Implementation :: PyPy",
4848
"Topic :: Internet :: WWW/HTTP",
@@ -59,8 +59,12 @@ def _read_file(filename):
5959
include_package_data=True,
6060
namespace_packages=['repoze', 'repoze.who', 'repoze.who.plugins'],
6161
zip_safe=False,
62-
tests_require = tests_require,
63-
install_requires=['WebOb', 'zope.interface', 'setuptools'],
62+
install_requires=[
63+
'WebOb',
64+
'zope.interface',
65+
'setuptools',
66+
'legacy-cgi; python_version > "3.12"', # WebOb uses the cgi module
67+
],
6468
test_suite="repoze.who",
6569
entry_points = """\
6670
[paste.filter_app_factory]
@@ -70,6 +74,6 @@ def _read_file(filename):
7074
authenticated = repoze.who.restrict:make_authenticated_restriction
7175
""",
7276
extras_require = {
73-
'docs': docs_extras,
77+
'docs': ['Sphinx', 'repoze.sphinx.autointerface'],
7478
},
7579
)

tox.ini

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
[tox]
2-
envlist =
3-
py37,py38,py39,py310,py311,pypy3,cover,docs
2+
envlist =
3+
py37,py38,py39,py310,py311,py312,py313,pypy3,cover,docs
44

55
[testenv]
6-
commands =
6+
commands =
77
python -m pytest --cov=repoze.who --cov-append --cov-report= {toxinidir}/repoze/who/tests/ {toxinidir}/repoze/who/plugins/tests/
88
usedevelop=true
99
deps =
10-
zope.interface
11-
WebOb
1210
virtualenv
1311
pytest
1412
pytest-cov
@@ -19,7 +17,7 @@ setenv =
1917
skip_install = true
2018
basepython =
2119
python3.10
22-
commands =
20+
commands =
2321
coverage combine
2422
coverage report --fail-under=100 --show-missing
2523
coverage xml
@@ -31,7 +29,7 @@ setenv =
3129
[testenv:docs]
3230
basepython =
3331
python3.10
34-
commands =
32+
commands =
3533
sphinx-build -b html -d docs/_build/doctrees docs docs/_build/html
3634
sphinx-build -b doctest -d docs/_build/doctrees docs docs/_build/doctest
3735
deps =

0 commit comments

Comments
 (0)