setup: Add Python 3.11 final and 3.12 alpha to CI

Adapts to the deprecation of multi-argument generator.throw().
This commit is contained in:
Ben Darnell 2022-11-19 15:59:31 -05:00
parent 031c435a6d
commit 2ef1fd31a6
7 changed files with 25 additions and 17 deletions

View File

@ -44,8 +44,10 @@ jobs:
tox_env: py39-full
- python: '3.10'
tox_env: py310-full
- python: '3.11.0-alpha - 3.11'
- python: '3.11'
tox_env: py311-full
- python: '3.12.0-alpha - 3.12'
tox_env: py312-full
- python: 'pypy-3.8'
# Pypy is a lot slower due to jit warmup costs, so don't run the
# "full" test config there.

View File

@ -3,7 +3,7 @@ requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"
[tool.cibuildwheel]
build = "cp3[789]* cp310*"
build = "cp3[789]* cp310* cp311*"
test-command = "python -m tornado.test"
[tool.cibuildwheel.macos]

View File

@ -116,6 +116,7 @@ setuptools.setup(
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
],

View File

@ -763,21 +763,25 @@ class Runner(object):
return
self.future = None
try:
exc_info = None
try:
value = future.result()
except Exception:
exc_info = sys.exc_info()
future = None
except Exception as e:
# Save the exception for later. It's important that
# gen.throw() not be called inside this try/except block
# because that makes sys.exc_info behave unexpectedly.
exc: Optional[Exception] = e
else:
exc = None
finally:
future = None
if exc_info is not None:
if exc is not None:
try:
yielded = self.gen.throw(*exc_info) # type: ignore
yielded = self.gen.throw(exc)
finally:
# Break up a reference to itself
# for faster GC on CPython.
exc_info = None
# Break up a circular reference for faster GC on
# CPython.
del exc
else:
yielded = self.gen.send(value)

View File

@ -1119,7 +1119,7 @@ class ContextVarsTest(AsyncTestCase):
x = 10
async def native_async_function():
self.assertEquals(ctx_var.get(), x)
self.assertEqual(ctx_var.get(), x)
ctx_var.set(x)
yield native_async_function()

View File

@ -672,7 +672,7 @@ def gen_test( # noqa: F811
if self._test_generator is not None and getattr(
self._test_generator, "cr_running", True
):
self._test_generator.throw(type(e), e)
self._test_generator.throw(e)
# In case the test contains an overly broad except
# clause, we may get back here.
# Coroutine was stopped or didn't raise a useful stack trace,

View File

@ -13,7 +13,7 @@
[tox]
envlist =
# Basic configurations: Run the tests for each python version.
py37-full,py38-full,py39-full,py310-full,pypy3-full
py37-full,py38-full,py39-full,py310-full,py311-full,pypy3-full
# Build and test the docs with sphinx.
docs
@ -32,6 +32,7 @@ basepython =
py39: python3.9
py310: python3.10
py311: python3.11
py312: python3.12
pypy3: pypy3
# In theory, it doesn't matter which python version is used here.
# In practice, things like changes to the ast module can alter
@ -50,7 +51,7 @@ deps =
setenv =
# Treat the extension as mandatory in testing (but not on pypy)
{py3,py37,py38,py39,py310}: TORNADO_EXTENSION=1
{py3,py37,py38,py39,py310,py311}: TORNADO_EXTENSION=1
# CI workers are often overloaded and can cause our tests to exceed
# the default timeout of 5s.
ASYNC_TEST_TIMEOUT=25
@ -62,7 +63,7 @@ setenv =
# during sdist installation (and it doesn't seem to be
# possible to set environment variables during that phase of
# tox).
{py3,py37,py38,py39,py310,pypy3}: PYTHONWARNINGS=error:::tornado
{py3,py37,py38,py39,py310,py311,pypy3}: PYTHONWARNINGS=error:::tornado
# All non-comment lines but the last must end in a backslash.