Adapts to the deprecation of multi-argument generator.throw().
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.
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]
"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",
],
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)
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()
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,
[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
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
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
# 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.