]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
setup: Add Python 3.11 final and 3.12 alpha to CI 3196/head
authorBen Darnell <ben@bendarnell.com>
Sat, 19 Nov 2022 20:59:31 +0000 (15:59 -0500)
committerBen Darnell <ben@bendarnell.com>
Sat, 19 Nov 2022 22:03:38 +0000 (17:03 -0500)
Adapts to the deprecation of multi-argument generator.throw().

.github/workflows/test.yml
pyproject.toml
setup.py
tornado/gen.py
tornado/test/gen_test.py
tornado/testing.py
tox.ini

index 58ca611fdcfa2a8df4ed5e28940f072203f5a265..935c325ec19212ddb8e018ea4ba96aa2f2a4c1f0 100644 (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.
index b2095ed6ce93dcc80ed9de756dcff92851dc2272..4c5d9b028931135bc96dfb11c082347da62f494f 100644 (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]
index 3a157b541015f368145dfa58ee73a27c11b54cbf..6ebc0f6bb76dc05e85f01ff33ac2ae93a0889e84 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -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",
     ],
index f3e6e72f1dac795697cc45b9d2da999bb70fc484..4819b8571537f0074833dafc0118c804044dcf47 100644 (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)
 
index 2b0253869241208231fffc8ebc058536250cb80b..c17bf65fd00f0be8d8a4ba6fc2bb427c1e7157be 100644 (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()
index 688464f01b9aec340989ce8daad00432ce87cb4b..fcad60c173a6a587da7cb480509c553d324f6b50 100644 (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,
diff --git a/tox.ini b/tox.ini
index 6a7d4ce85387ab53f06acc07fc1b45a1fe1417a8..6ea03e462f0ab5488144b5551b85d92e33cff0d4 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -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.