Skip to content

Commit 9765493

Browse files
committed
fix: CPython 3.11 support. #1241
The fix for CTracer is egregious and will need to be updated when there's a supported way to do it. The fullcoverage skip is noted in #1278 The raise_through_with skip is noted in #1270
1 parent dfa9774 commit 9765493

File tree

11 files changed

+35
-6
lines changed

11 files changed

+35
-6
lines changed

.github/workflows/coverage.yml

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ jobs:
3838
- "3.8"
3939
- "3.9"
4040
- "3.10"
41+
- "3.11.0-alpha.2"
4142
- "pypy3"
4243
exclude:
4344
# Windows PyPy doesn't seem to work?

.github/workflows/kit.yml

+11-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@
44
# Based on:
55
# https://github.com/joerick/cibuildwheel/blob/master/examples/github-deploy.yml
66

7+
# To test installing wheels without uploading them to PyPI:
8+
#
9+
# $ mkdir /tmp/pypi
10+
# $ cp dist/* /tmp/pypi
11+
# $ python -m pip install piprepo
12+
# $ piprepo build /tmp/pypi
13+
# $ python -m pip install -v coverage --index-url=file:///tmp/pypi/simple
14+
#
15+
716
name: "Kits"
817

918
on:
@@ -197,7 +206,7 @@ jobs:
197206

198207
prerel:
199208
name: "Build pre-rel ${{ matrix.os }} ${{ matrix.py }} wheels"
200-
if: ${{ false }} # disable for now, since there are no pre-rel Python versions.
209+
if: ${{ true }} # true when there are pre-rel, false when not.
201210
runs-on: "${{ matrix.os }}-latest"
202211
strategy:
203212
matrix:
@@ -206,7 +215,7 @@ jobs:
206215
- windows
207216
- macos
208217
py:
209-
- "3.10.0-rc.2"
218+
- "3.11.0-alpha.2"
210219
fail-fast: false
211220

212221
steps:

.github/workflows/testsuite.yml

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ jobs:
3737
- "3.8"
3838
- "3.9"
3939
- "3.10"
40+
- "3.11.0-alpha.2"
4041
- "pypy3"
4142
exclude:
4243
# Windows PyPy doesn't seem to work?

CHANGES.rst

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ This list is detailed and covers changes in each pre-release version.
2222
Unreleased
2323
----------
2424

25+
- Python 3.11 is supported (tested with 3.11.0a2). One still-open issue has to
26+
do with `exits through with-statements <issue 1270_>`_.
27+
2528
- Fix: When remapping file paths through the ``[paths]`` setting while
2629
combining, the ``[run] relative_files`` setting was ignored, resulting in
2730
absolute paths for remapped file names (`issue 1147`_). This is now fixed.
@@ -44,6 +47,7 @@ Unreleased
4447

4548
.. _django_coverage_plugin issue 78: https://github.com/nedbat/django_coverage_plugin/issues/78
4649
.. _issue 1147: https://github.com/nedbat/coveragepy/issues/1147
50+
.. _issue 1270: https://github.com/nedbat/coveragepy/issues/1270
4751
.. _issue 1271: https://github.com/nedbat/coveragepy/issues/1271
4852
.. _issue 1273: https://github.com/nedbat/coveragepy/issues/1273
4953

README.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ library to determine which lines are executable, and which have been executed.
1919

2020
Coverage.py runs on these versions of Python:
2121

22-
* CPython 3.6 through 3.10.
22+
* CPython 3.6 through 3.11.
2323
* PyPy3 7.3.7.
2424

2525
Documentation is on `Read the Docs`_. Code repository and issue tracker are on

coverage/ctracer/util.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,15 @@
1212
#undef COLLECT_STATS /* Collect counters: stats are printed when tracer is stopped. */
1313
#undef DO_NOTHING /* Define this to make the tracer do nothing. */
1414

15+
#if PY_VERSION_HEX >= 0x030B00A0
16+
// 3.11 moved f_lasti into an internal structure. This is totally the wrong way
17+
// to make this work, but it's all I've got until https://bugs.python.org/issue40421
18+
// is resolved.
19+
#include <internal/pycore_frame.h>
20+
#define MyFrame_lasti(f) ((f)->f_frame->f_lasti * 2)
21+
#elif PY_VERSION_HEX >= 0x030A00A7
1522
// The f_lasti field changed meaning in 3.10.0a7. It had been bytes, but
1623
// now is instructions, so we need to adjust it to use it as a byte index.
17-
#if PY_VERSION_HEX >= 0x030A00A7
1824
#define MyFrame_lasti(f) ((f)->f_lasti * 2)
1925
#else
2026
#define MyFrame_lasti(f) ((f)->f_lasti)

doc/index.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ not.
1616
The latest version is coverage.py |release|, released |release_date|. It is
1717
supported on:
1818

19-
* Python versions 3.6 through 3.10.
19+
* Python versions 3.6 through 3.11.
2020

2121
* PyPy3 7.3.7.
2222

setup.py

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def better_set_verbosity(v):
4444
Programming Language :: Python :: 3.8
4545
Programming Language :: Python :: 3.9
4646
Programming Language :: Python :: 3.10
47+
Programming Language :: Python :: 3.11
4748
Programming Language :: Python :: Implementation :: CPython
4849
Programming Language :: Python :: Implementation :: PyPy
4950
Topic :: Software Development :: Quality Assurance

tests/test_arcs.py

+2
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,8 @@ def test_continue_through_with(self):
279279
arcz=arcz,
280280
)
281281

282+
@pytest.mark.skipif(env.PYVERSION[:2] >= (3, 11), reason="avoid a 3.11 bug: 45709")
283+
# https://github.com/nedbat/coveragepy/issues/1270
282284
def test_raise_through_with(self):
283285
if env.PYBEHAVIOR.exit_through_with:
284286
arcz = ".1 12 27 78 8. 9A A. -23 34 45 53 6-2"

tests/test_process.py

+2
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,8 @@ def f():
748748
@pytest.mark.expensive
749749
@pytest.mark.skipif(env.METACOV, reason="Can't test fullcoverage when measuring ourselves")
750750
@pytest.mark.skipif(not env.C_TRACER, reason="fullcoverage only works with the C tracer.")
751+
@pytest.mark.skipif(env.PYVERSION[:2] >= (3, 11), reason="this test needs work on 3.11")
752+
# https://github.com/nedbat/coveragepy/issues/1278
751753
def test_fullcoverage(self):
752754
# fullcoverage is a trick to get stdlib modules measured from
753755
# the very beginning of the process. Here we import os and

tox.ini

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
[tox]
55
# When changing this list, be sure to check the [gh-actions] list below.
6-
envlist = py{36,37,38,39,310}, pypy3, doc, lint
6+
envlist = py{36,37,38,39,310,311}, pypy3, doc, lint
77
skip_missing_interpreters = {env:COVERAGE_SKIP_MISSING_INTERPRETERS:True}
88
toxworkdir = {env:TOXWORKDIR:.tox}
99

@@ -32,6 +32,8 @@ setenv =
3232
# For some tests, we need .pyc files written in the current directory,
3333
# so override any local setting.
3434
PYTHONPYCACHEPREFIX=
35+
# PyContracts can't do 3.11.
36+
py311: COVERAGE_NO_CONTRACTS=1
3537

3638
commands =
3739
# Create tests/zipmods.zip
@@ -95,4 +97,5 @@ python =
9597
3.8: py38
9698
3.9: py39
9799
3.10: py310
100+
3.11: py311
98101
pypy3: pypy3

0 commit comments

Comments
 (0)