Skip to content

Commit a38b6eb

Browse files
jgrahammoz-wptsync-bot
authored andcommitted
Bug 1940455 [wpt PR 49970] - Add support for Python 3.13, a=testonly
Automatic update from web-platform-tests Import fork of Python cgi library into wptserve This code has been dropped from Python 3.13, but we depend on FieldStorage as part of the request API. The easiest option here is to directly import the code that we are already using (the last version on the 3.12 branch, but with the deprecation warning removed), along with a copy of the PSF License which covers the cgi module code. -- Use vendored cgi lib in wptserve -- Update third party deps for Python 3.13 support -- Fix lock in QueueHandler class to be a dummy implementation of the Lock API This is required since the logging module started using the lock as a context manager, and calling the acquire and release methods. -- Update getting context manager when running serve directly Remove code only needed for Python < 3.4 and ensure that we always use the spawn form of multiprocessing to avoid problems with fork and locks. -- Update tox configurations to include Python 3.13 -- Update Azure configuration for Python 3.13 -- Update taskcluster configuration for Python 3.13 -- Exclude cgi code from flake8 -- Ignore errors in imported cgi module Just adding this to the excludes doesn't work, because we still check the imported code. -- Add cgi tests Lightly modified from the version in Python 3.12 as follows: * Inlined check__all__ function * Converted the use of ignore_warnings helper to use warning module directly -- Update Pillow for Python>=3.9 -- Remove dep on typed-ast This is no longer support in Python 3.13, and no longer required for Python>=3.8 -- Fix cgi tests to be compatible with behaviour of older Python versions -- Add types to NullLock and rename to NullRLock -- Update assert_png to check for magic bytes directly This avoids the use of imghdr which was removed in Ptyhon 3.13 -- wpt-commits: c80b8b9f035ac4c9d8c238e8389caee6f76a97fc, c1fd85e0337d69ba3fdacd27b69ce25cf486d2ef, 36548a344ca86a9a8d3fe5968469dc49d2ce9931, d22ded6ced64889f09de80b309601521ce1a43d5, 5ddbf24f7390d28c992797353236660143d92599, 2ae5ea7bd1d3498e623ce4436cb26be3ab1a6d15, ac6d6f7bfbe74f647ebce82dc6b5c9c2cfdd7bc5, d1f396d8983543511f0208509a076a2072163815, 408f275bd0c40fe7d4895ce4eec75bf6c7f40ee7, 3f5d5c6a6c1b5e720804b7dd8db94d14dfbaf74d, 43595084855f54ce85d89aaebb4a5302bcb7270c, a0e0465d0d0238b56328d7237e63f71806b1ea59, 43dc34dd9389475155a50209035520b67d3a5a38, 16730d4b2572f230665aa653d6d98e7ec6e78d2c, 06f93bb52645f20f8c28547741e2161f97109393, 9f1d2f767cf880a5b1d6092b0cef4e356c0e7619 wpt-pr: 49970
1 parent f6a120f commit a38b6eb

File tree

20 files changed

+2086
-67
lines changed

20 files changed

+2086
-67
lines changed

testing/web-platform/tests/.azure-pipelines.yml

+31-31
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
steps:
5555
- task: UsePythonVersion@0
5656
inputs:
57-
versionSpec: '3.12'
57+
versionSpec: '3.13'
5858
- template: tools/ci/azure/affected_tests.yml
5959
parameters:
6060
checkoutCommit: 'HEAD^1'
@@ -75,7 +75,7 @@ jobs:
7575
steps:
7676
- task: UsePythonVersion@0
7777
inputs:
78-
versionSpec: '3.12'
78+
versionSpec: '3.13'
7979
- template: tools/ci/azure/checkout.yml
8080
- script: |
8181
set -eux -o pipefail
@@ -96,7 +96,7 @@ jobs:
9696
steps:
9797
- task: UsePythonVersion@0
9898
inputs:
99-
versionSpec: '3.12'
99+
versionSpec: '3.13'
100100
- template: tools/ci/azure/checkout.yml
101101
- template: tools/ci/azure/install_fonts.yml
102102
- template: tools/ci/azure/install_certs.yml
@@ -134,21 +134,21 @@ jobs:
134134
directory: tools/
135135
toxenv: py38
136136

137-
- job: tools_unittest_mac_py311
138-
displayName: 'tools/ unittests: macOS + Python 3.12'
137+
- job: tools_unittest_mac_py313
138+
displayName: 'tools/ unittests: macOS + Python 3.13'
139139
dependsOn: decision
140140
condition: dependencies.decision.outputs['test_jobs.tools_unittest']
141141
pool:
142142
vmImage: 'macOS-14'
143143
steps:
144144
- task: UsePythonVersion@0
145145
inputs:
146-
versionSpec: '3.12'
146+
versionSpec: '3.13'
147147
- template: tools/ci/azure/checkout.yml
148148
- template: tools/ci/azure/tox_pytest.yml
149149
parameters:
150150
directory: tools/
151-
toxenv: py311
151+
toxenv: py313
152152

153153
- job: wptrunner_unittest_mac_py38
154154
displayName: 'tools/wptrunner/ unittests: macOS + Python 3.8'
@@ -166,21 +166,21 @@ jobs:
166166
directory: tools/wptrunner/
167167
toxenv: py38
168168

169-
- job: wptrunner_unittest_mac_py311
170-
displayName: 'tools/wptrunner/ unittests: macOS + Python 3.12'
169+
- job: wptrunner_unittest_mac_py313
170+
displayName: 'tools/wptrunner/ unittests: macOS + Python 3.13'
171171
dependsOn: decision
172172
condition: dependencies.decision.outputs['test_jobs.wptrunner_unittest']
173173
pool:
174174
vmImage: 'macOS-14'
175175
steps:
176176
- task: UsePythonVersion@0
177177
inputs:
178-
versionSpec: '3.12'
178+
versionSpec: '3.13'
179179
- template: tools/ci/azure/checkout.yml
180180
- template: tools/ci/azure/tox_pytest.yml
181181
parameters:
182182
directory: tools/wptrunner/
183-
toxenv: py311
183+
toxenv: py313
184184

185185
- job: wpt_integration_mac_py38
186186
displayName: 'tools/wpt/ tests: macOS + Python 3.8'
@@ -202,8 +202,8 @@ jobs:
202202
directory: tools/wpt/
203203
toxenv: py38
204204

205-
- job: wpt_integration_mac_py311
206-
displayName: 'tools/wpt/ tests: macOS + Python 3.12'
205+
- job: wpt_integration_mac_py313
206+
displayName: 'tools/wpt/ tests: macOS + Python 3.13'
207207
dependsOn: decision
208208
condition: dependencies.decision.outputs['test_jobs.wpt_integration']
209209
pool:
@@ -212,15 +212,15 @@ jobs:
212212
# full checkout required
213213
- task: UsePythonVersion@0
214214
inputs:
215-
versionSpec: '3.12'
215+
versionSpec: '3.13'
216216
- template: tools/ci/azure/install_chrome.yml
217217
- template: tools/ci/azure/install_firefox.yml
218218
- template: tools/ci/azure/update_hosts.yml
219219
- template: tools/ci/azure/update_manifest.yml
220220
- template: tools/ci/azure/tox_pytest.yml
221221
parameters:
222222
directory: tools/wpt/
223-
toxenv: py311
223+
toxenv: py313
224224

225225
- job: tools_unittest_win_py38
226226
displayName: 'tools/ unittests: Windows + Python 3.8'
@@ -241,22 +241,22 @@ jobs:
241241
directory: tools/
242242
toxenv: py38
243243

244-
- job: tools_unittest_win_py311
245-
displayName: 'tools/ unittests: Windows + Python 3.12'
244+
- job: tools_unittest_win_py313
245+
displayName: 'tools/ unittests: Windows + Python 3.13'
246246
dependsOn: decision
247247
condition: dependencies.decision.outputs['test_jobs.tools_unittest']
248248
pool:
249249
vmImage: 'windows-2019'
250250
steps:
251251
- task: UsePythonVersion@0
252252
inputs:
253-
versionSpec: '3.12'
253+
versionSpec: '3.13'
254254
addToPath: false
255255
- template: tools/ci/azure/checkout.yml
256256
- template: tools/ci/azure/tox_pytest.yml
257257
parameters:
258258
directory: tools/
259-
toxenv: py311
259+
toxenv: py313
260260

261261
- job: wptrunner_unittest_win_py38
262262
displayName: 'tools/wptrunner/ unittests: Windows + Python 3.8'
@@ -275,22 +275,22 @@ jobs:
275275
directory: tools/wptrunner/
276276
toxenv: py38
277277

278-
- job: wptrunner_unittest_win_py311
279-
displayName: 'tools/wptrunner/ unittests: Windows + Python 3.12'
278+
- job: wptrunner_unittest_win_py313
279+
displayName: 'tools/wptrunner/ unittests: Windows + Python 3.13'
280280
dependsOn: decision
281281
condition: dependencies.decision.outputs['test_jobs.wptrunner_unittest']
282282
pool:
283283
vmImage: 'windows-2019'
284284
steps:
285285
- task: UsePythonVersion@0
286286
inputs:
287-
versionSpec: '3.12'
287+
versionSpec: '3.13'
288288
addToPath: false
289289
- template: tools/ci/azure/checkout.yml
290290
- template: tools/ci/azure/tox_pytest.yml
291291
parameters:
292292
directory: tools/wptrunner/
293-
toxenv: py311
293+
toxenv: py313
294294

295295
- job: wpt_integration_win_py38
296296
displayName: 'tools/wpt/ tests: Windows + Python 3.8'
@@ -314,8 +314,8 @@ jobs:
314314
directory: tools/wpt/
315315
toxenv: py38
316316

317-
- job: wpt_integration_win_py311
318-
displayName: 'tools/wpt/ tests: Windows + Python 3.12'
317+
- job: wpt_integration_win_py313
318+
displayName: 'tools/wpt/ tests: Windows + Python 3.13'
319319
dependsOn: decision
320320
condition: dependencies.decision.outputs['test_jobs.wpt_integration']
321321
pool:
@@ -324,7 +324,7 @@ jobs:
324324
# full checkout required
325325
- task: UsePythonVersion@0
326326
inputs:
327-
versionSpec: '3.12'
327+
versionSpec: '3.13'
328328
# currently just using the outdated Chrome/Firefox on the VM rather than
329329
# figuring out how to install Chrome Dev channel on Windows
330330
# - template: tools/ci/azure/install_chrome.yml
@@ -334,7 +334,7 @@ jobs:
334334
- template: tools/ci/azure/tox_pytest.yml
335335
parameters:
336336
directory: tools/wpt/
337-
toxenv: py311
337+
toxenv: py313
338338

339339
- job: results_edge_stable
340340
displayName: 'all tests: Edge Stable'
@@ -350,7 +350,7 @@ jobs:
350350
steps:
351351
- task: UsePythonVersion@0
352352
inputs:
353-
versionSpec: '3.12'
353+
versionSpec: '3.13'
354354
- template: tools/ci/azure/system_info.yml
355355
- template: tools/ci/azure/checkout.yml
356356
- template: tools/ci/azure/install_certs.yml
@@ -386,7 +386,7 @@ jobs:
386386
steps:
387387
- task: UsePythonVersion@0
388388
inputs:
389-
versionSpec: '3.12'
389+
versionSpec: '3.13'
390390
- template: tools/ci/azure/system_info.yml
391391
- template: tools/ci/azure/checkout.yml
392392
- template: tools/ci/azure/install_certs.yml
@@ -422,7 +422,7 @@ jobs:
422422
steps:
423423
- task: UsePythonVersion@0
424424
inputs:
425-
versionSpec: '3.12'
425+
versionSpec: '3.13'
426426
- template: tools/ci/azure/checkout.yml
427427
- template: tools/ci/azure/install_certs.yml
428428
- template: tools/ci/azure/install_edge.yml
@@ -456,7 +456,7 @@ jobs:
456456
steps:
457457
- task: UsePythonVersion@0
458458
inputs:
459-
versionSpec: '3.12'
459+
versionSpec: '3.13'
460460
- template: tools/ci/azure/checkout.yml
461461
- template: tools/ci/azure/install_certs.yml
462462
- template: tools/ci/azure/color_profile.yml

testing/web-platform/tests/tools/ci/tc/tasks/test.yml

+14-14
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,14 @@ components:
127127
- python3.8-dev
128128
- python3.8-venv
129129

130-
tox-python3_12:
130+
tox-python3_13:
131131
env:
132-
TOXENV: py312
132+
TOXENV: py313
133133
PY_COLORS: "0"
134134
install:
135-
- python3.12
136-
- python3.12-dev
137-
- python3.12-venv
135+
- python3.13
136+
- python3.13-dev
137+
- python3.13-venv
138138
tests-affected:
139139
options:
140140
browser:
@@ -471,13 +471,13 @@ tasks:
471471
run-job:
472472
- tools_unittest
473473

474-
- tools/ unittests (Python 3.12):
474+
- tools/ unittests (Python 3.13):
475475
description: >-
476-
Unit tests for tools running under Python 3.12, excluding wptrunner
476+
Unit tests for tools running under Python 3.13, excluding wptrunner
477477
use:
478478
- wpt-base
479479
- trigger-pr
480-
- tox-python3_12
480+
- tox-python3_13
481481
command: ./tools/ci/ci_tools_unittest.sh
482482
env:
483483
HYPOTHESIS_PROFILE: ci
@@ -507,13 +507,13 @@ tasks:
507507
run-job:
508508
- wpt_integration
509509

510-
- tools/ integration tests (Python 3.12):
510+
- tools/ integration tests (Python 3.13):
511511
description: >-
512-
Integration tests for tools running under Python 3.12
512+
Integration tests for tools running under Python 3.13
513513
use:
514514
- wpt-base
515515
- trigger-pr
516-
- tox-python3_12
516+
- tox-python3_13
517517
command: ./tools/ci/ci_tools_integration_test.sh
518518
install:
519519
- libnss3-tools
@@ -548,13 +548,13 @@ tasks:
548548
run-job:
549549
- resources_unittest
550550

551-
- resources/ tests (Python 3.12):
551+
- resources/ tests (Python 3.13):
552552
description: >-
553-
Tests for testharness.js and other files in resources/ under Python 3.12
553+
Tests for testharness.js and other files in resources/ under Python 3.13
554554
use:
555555
- wpt-base
556556
- trigger-pr
557-
- tox-python3_12
557+
- tox-python3_13
558558
command: ./tools/ci/ci_resources_unittest.sh
559559
install:
560560
- libnss3-tools

testing/web-platform/tests/tools/ci/tc/tests/test_valid.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,11 @@ def test_verify_payload():
177177
("pr_event.json", True, {".taskcluster.yml", ".travis.yml", "tools/ci/start.sh"},
178178
['lint',
179179
'tools/ unittests (Python 3.8)',
180-
'tools/ unittests (Python 3.12)',
180+
'tools/ unittests (Python 3.13)',
181181
'tools/ integration tests (Python 3.8)',
182-
'tools/ integration tests (Python 3.12)',
182+
'tools/ integration tests (Python 3.13)',
183183
'resources/ tests (Python 3.8)',
184-
'resources/ tests (Python 3.12)',
184+
'resources/ tests (Python 3.13)',
185185
'download-firefox-nightly',
186186
'infrastructure/ tests',
187187
'sink-task']),
@@ -199,7 +199,7 @@ def test_verify_payload():
199199
("pr_event_tests_affected.json", True, {"resources/testharness.js"},
200200
['lint',
201201
'resources/ tests (Python 3.8)',
202-
'resources/ tests (Python 3.12)',
202+
'resources/ tests (Python 3.13)',
203203
'download-firefox-nightly',
204204
'infrastructure/ tests',
205205
'sink-task']),

testing/web-platform/tests/tools/flake8.ini

+1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ exclude =
2323
third_party,
2424
wptserve/docs/conf.py,
2525
wptserve/tests/functional/docroot/invalid.py
26+
wptserve/wptserve/cgi/
2627
max-line-length = 141
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
zstandard==0.22.0
1+
zstandard==0.23.0

testing/web-platform/tests/tools/mypy.ini

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# - All setup.py files (avoiding duplicate module named "setup")
77
# - tools/wptserve/docs/conf.py (generated code)
88
# - tools/wptserve/tests/ (deliberately invalid syntax)
9-
exclude = (^tools/third_party/|/setup\.py$|^tools/wptserve/docs/conf.py|^tools/wptserve/tests/|^tools/third_party_modified/mozlog/)
9+
exclude = (^tools/third_party/|/setup\.py$|^tools/wptserve/docs/conf.py|^tools/wptserve/tests/|^tools/third_party_modified/mozlog/|^tools/wptserve/wptserve/cgi/test_cgi\.py$)
1010
mypy_path = tools/wptrunner:tools/wptserve:tools/webdriver:tools/webtransport
1111
#check_untyped_defs = True
1212
disallow_any_generics = True
@@ -36,6 +36,9 @@ ignore_missing_imports = True
3636
[mypy-Quartz.*]
3737
ignore_missing_imports = True
3838

39+
[mypy-cgi.*]
40+
ignore_missing_imports = True
41+
3942
[mypy-github.*]
4043
ignore_missing_imports = True
4144

testing/web-platform/tests/tools/requirements_mypy.txt

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ mypy==1.14.0
22
mypy-extensions==1.0.0
33
toml==0.10.2
44
tomli==2.0.1
5-
typed-ast==1.5.5
65
types-atomicwrites==1.4.5.1
76
types-python-dateutil==2.9.0.20240906
87
types-PyYAML==6.0.12.12

testing/web-platform/tests/tools/serve/serve.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -1418,10 +1418,7 @@ def run(config_cls=ConfigBuilder, route_builder=None, mp_context=None, log_handl
14181418
logger = get_logger("INFO", log_handlers)
14191419

14201420
if mp_context is None:
1421-
if hasattr(multiprocessing, "get_context"):
1422-
mp_context = multiprocessing.get_context()
1423-
else:
1424-
mp_context = MpContext()
1421+
mp_context = multiprocessing.get_context("spawn")
14251422

14261423
with build_config(logger,
14271424
os.path.join(repo_root, "config.json"),

testing/web-platform/tests/tools/tox.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py38,py39,py310,py311,py312,{py38,py39,py310,py311,py312}-{flake8,mypy}
2+
envlist = py38,py39,py310,py311,py312,py313,{py38,py39,py310,py311,py312,py313}-{flake8,mypy}
33
skipsdist=True
44
skip_missing_interpreters=False
55

testing/web-platform/tests/tools/wave/tox.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py38,py39,py310,py311,py312
2+
envlist = py38,py39,py310,py311,py312,py312
33
skipsdist=True
44
skip_missing_interpreters = False
55

testing/web-platform/tests/tools/wpt/tox.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py38,py39,py310,py311,py312
2+
envlist = py38,py39,py310,py311,py312,py312
33
skipsdist=True
44
skip_missing_interpreters = False
55

0 commit comments

Comments
 (0)