From ed869accdd1428c9cca452fdbe64b643d5662874 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Gr=C3=B6nholm?= Date: Thu, 25 Feb 2021 17:49:45 +0200 Subject: [PATCH 01/20] Added the "compact" keyword argument to TracebackException.__init__() This is a requirement to achieve Python 3.10 compatibility. --- trio/_core/_multierror.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/trio/_core/_multierror.py b/trio/_core/_multierror.py index 13fc3f3d0f..54295e71d5 100644 --- a/trio/_core/_multierror.py +++ b/trio/_core/_multierror.py @@ -381,11 +381,17 @@ def traceback_exception_init( limit=None, lookup_lines=True, capture_locals=False, + compact=False, _seen=None, ): if _seen is None: _seen = set() + if sys.version_info >= (3, 10): + kwargs = {"compact": compact} + else: + kwargs = {} + # Capture the original exception and its cause and context as TracebackExceptions traceback_exception_original_init( self, @@ -396,6 +402,7 @@ def traceback_exception_init( lookup_lines=lookup_lines, capture_locals=capture_locals, _seen=_seen, + **kwargs, ) # Capture each of the exceptions in the MultiError along with each of their causes and contexts From 8c62409483b6be9c585e12929525b95a32c1f708 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Sat, 6 Mar 2021 12:40:39 -0500 Subject: [PATCH 02/20] Test against 3.10 alpha --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2e5290e623..a4483fa2ff 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: false matrix: - python: ['3.6', '3.7', '3.8', '3.9'] + python: ['3.6', '3.7', '3.8', '3.9', '3.10'] arch: ['x86', 'x64'] lsp: [''] lsp_extract_file: [''] @@ -41,7 +41,7 @@ jobs: - name: Setup python uses: actions/setup-python@v2 with: - python-version: '${{ matrix.python }}' + python-version: '${{ matrix.python.action }}.0-alpha - ${{ matrix.python.action }}.X' architecture: '${{ matrix.arch }}' - name: Run tests run: ./ci.sh @@ -77,7 +77,7 @@ jobs: uses: actions/setup-python@v2 if: "!endsWith(matrix.python, '-dev')" with: - python-version: '${{ matrix.python }}' + python-version: '${{ matrix.python.action }}.0-alpha - ${{ matrix.python.action }}.X' - name: Setup python (dev) uses: deadsnakes/action@v2.0.2 if: endsWith(matrix.python, '-dev') @@ -105,7 +105,7 @@ jobs: - name: Setup python uses: actions/setup-python@v2 with: - python-version: '${{ matrix.python }}' + python-version: '${{ matrix.python.action }}.0-alpha - ${{ matrix.python.action }}.X' - name: Run tests run: ./ci.sh env: From 2a946a4c0152a01a9502bed248c8a09b4c997b5c Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Sat, 6 Mar 2021 12:41:50 -0500 Subject: [PATCH 03/20] Correct matrix variable references --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a4483fa2ff..4bae0fba2c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,7 @@ jobs: - name: Setup python uses: actions/setup-python@v2 with: - python-version: '${{ matrix.python.action }}.0-alpha - ${{ matrix.python.action }}.X' + python-version: '${{ matrix.python }}.0-alpha - ${{ matrix.python }}.X' architecture: '${{ matrix.arch }}' - name: Run tests run: ./ci.sh @@ -77,7 +77,7 @@ jobs: uses: actions/setup-python@v2 if: "!endsWith(matrix.python, '-dev')" with: - python-version: '${{ matrix.python.action }}.0-alpha - ${{ matrix.python.action }}.X' + python-version: '${{ matrix.python }}.0-alpha - ${{ matrix.python }}.X' - name: Setup python (dev) uses: deadsnakes/action@v2.0.2 if: endsWith(matrix.python, '-dev') @@ -105,7 +105,7 @@ jobs: - name: Setup python uses: actions/setup-python@v2 with: - python-version: '${{ matrix.python.action }}.0-alpha - ${{ matrix.python.action }}.X' + python-version: '${{ matrix.python }}.0-alpha - ${{ matrix.python }}.X' - name: Run tests run: ./ci.sh env: From 9e8692f1ddf38851f7ae8288fba6403ef5824df0 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Sat, 6 Mar 2021 13:42:26 -0500 Subject: [PATCH 04/20] Add 3.10 to Linux and macOS as well --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4bae0fba2c..81a7c676f5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,7 +59,7 @@ jobs: strategy: fail-fast: false matrix: - python: ['pypy-3.6', 'pypy-3.7', '3.6', '3.7', '3.8', '3.9', '3.8-dev', '3.9-dev'] + python: ['pypy-3.6', 'pypy-3.7', '3.6', '3.7', '3.8', '3.9', '3.8-dev', '3.9-dev', '3.10'] check_formatting: ['0'] pypy_nightly_branch: [''] extra_name: [''] @@ -98,7 +98,7 @@ jobs: strategy: fail-fast: false matrix: - python: ['3.6', '3.7', '3.8', '3.9'] + python: ['3.6', '3.7', '3.8', '3.9', '3.10'] steps: - name: Checkout uses: actions/checkout@v2 From e42c8875d9e5887b25a8b9cc572b1aa7d5630d8f Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Sun, 7 Mar 2021 18:32:48 -0500 Subject: [PATCH 05/20] reorder ubunty python versions --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 81a7c676f5..09dd689da3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,7 +59,7 @@ jobs: strategy: fail-fast: false matrix: - python: ['pypy-3.6', 'pypy-3.7', '3.6', '3.7', '3.8', '3.9', '3.8-dev', '3.9-dev', '3.10'] + python: ['pypy-3.6', 'pypy-3.7', '3.6', '3.7', '3.8', '3.9', '3.10', '3.8-dev', '3.9-dev'] check_formatting: ['0'] pypy_nightly_branch: [''] extra_name: [''] From 0af8e6c1cfbcb2d9837505057a974890c99f39d9 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Sun, 7 Mar 2021 21:49:53 -0500 Subject: [PATCH 06/20] Pass _seen=None through to TracebackException.__init__() monkey patch In CPython 3.10.0a5 TracebackException.__init__() started to care about the difference between _seen=set() and _seen=None. As such we need to avoid turning None into set() prior to passing it to the real .__init__(). https://github.com/python/cpython/commit/6dfd1734f5b230bb8fbd2a9df806c1333b6652a8 --- trio/_core/_multierror.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/trio/_core/_multierror.py b/trio/_core/_multierror.py index 54295e71d5..9d0eb22f2d 100644 --- a/trio/_core/_multierror.py +++ b/trio/_core/_multierror.py @@ -384,9 +384,6 @@ def traceback_exception_init( compact=False, _seen=None, ): - if _seen is None: - _seen = set() - if sys.version_info >= (3, 10): kwargs = {"compact": compact} else: @@ -405,6 +402,9 @@ def traceback_exception_init( **kwargs, ) + if _seen is None: + _seen = set() + # Capture each of the exceptions in the MultiError along with each of their causes and contexts if isinstance(exc_value, MultiError): embedded = [] From 896395738249d34496b02b62546bafdedbed41e1 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Sun, 7 Mar 2021 22:14:07 -0500 Subject: [PATCH 07/20] Handle _seen=None properly for TracebackException.from_exception() --- trio/_core/_multierror.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/trio/_core/_multierror.py b/trio/_core/_multierror.py index 9d0eb22f2d..ed926c029f 100644 --- a/trio/_core/_multierror.py +++ b/trio/_core/_multierror.py @@ -402,6 +402,8 @@ def traceback_exception_init( **kwargs, ) + seen_was_none = _seen is None + if _seen is None: _seen = set() @@ -418,7 +420,7 @@ def traceback_exception_init( capture_locals=capture_locals, # copy the set of _seen exceptions so that duplicates # shared between sub-exceptions are not omitted - _seen=set(_seen), + _seen=None if seen_was_none else set(_seen), ) ) self.embedded = embedded From 702fbb98f4efb54b42392ec34a52f501c5dddeb4 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Sun, 7 Mar 2021 22:25:39 -0500 Subject: [PATCH 08/20] Try indexing to pick fancy alpha-latest for cpython and straight for pypy --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 09dd689da3..b90d0d8b85 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,7 @@ jobs: - name: Setup python uses: actions/setup-python@v2 with: - python-version: '${{ matrix.python }}.0-alpha - ${{ matrix.python }}.X' + python-version: ${{ ['${{ matrix.python }}.0-alpha - ${{ matrix.python }}.X', ${{ matrix.python }}][startsWith(${{ matrix.python }}, 'pypy')] }} architecture: '${{ matrix.arch }}' - name: Run tests run: ./ci.sh @@ -77,7 +77,7 @@ jobs: uses: actions/setup-python@v2 if: "!endsWith(matrix.python, '-dev')" with: - python-version: '${{ matrix.python }}.0-alpha - ${{ matrix.python }}.X' + python-version: ${{ ['${{ matrix.python }}.0-alpha - ${{ matrix.python }}.X', ${{ matrix.python }}][startsWith(${{ matrix.python }}, 'pypy')] }} - name: Setup python (dev) uses: deadsnakes/action@v2.0.2 if: endsWith(matrix.python, '-dev') @@ -105,7 +105,7 @@ jobs: - name: Setup python uses: actions/setup-python@v2 with: - python-version: '${{ matrix.python }}.0-alpha - ${{ matrix.python }}.X' + python-version: ${{ ['${{ matrix.python }}.0-alpha - ${{ matrix.python }}.X', ${{ matrix.python }}][startsWith(${{ matrix.python }}, 'pypy')] }} - name: Run tests run: ./ci.sh env: From 5558db5f88db734a7b0192b5999a1fb3283ea015 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Sun, 7 Mar 2021 22:30:30 -0500 Subject: [PATCH 09/20] Try fromJSON to make an array in GitHub Actions --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b90d0d8b85..8ed586a1c6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,7 @@ jobs: - name: Setup python uses: actions/setup-python@v2 with: - python-version: ${{ ['${{ matrix.python }}.0-alpha - ${{ matrix.python }}.X', ${{ matrix.python }}][startsWith(${{ matrix.python }}, 'pypy')] }} + python-version: ${{ fromJSON('["${{ matrix.python }}.0-alpha - ${{ matrix.python }}.X", "${{ matrix.python }}"]')[startsWith(matrix.python, 'pypy')] }} architecture: '${{ matrix.arch }}' - name: Run tests run: ./ci.sh @@ -77,7 +77,7 @@ jobs: uses: actions/setup-python@v2 if: "!endsWith(matrix.python, '-dev')" with: - python-version: ${{ ['${{ matrix.python }}.0-alpha - ${{ matrix.python }}.X', ${{ matrix.python }}][startsWith(${{ matrix.python }}, 'pypy')] }} + python-version: ${{ fromJSON('["${{ matrix.python }}.0-alpha - ${{ matrix.python }}.X", "${{ matrix.python }}"]')[startsWith(matrix.python, 'pypy')] }} - name: Setup python (dev) uses: deadsnakes/action@v2.0.2 if: endsWith(matrix.python, '-dev') @@ -105,7 +105,7 @@ jobs: - name: Setup python uses: actions/setup-python@v2 with: - python-version: ${{ ['${{ matrix.python }}.0-alpha - ${{ matrix.python }}.X', ${{ matrix.python }}][startsWith(${{ matrix.python }}, 'pypy')] }} + python-version: ${{ fromJSON('["${{ matrix.python }}.0-alpha - ${{ matrix.python }}.X", "${{ matrix.python }}"]')[startsWith(matrix.python, 'pypy')] }} - name: Run tests run: ./ci.sh env: From 183b8c8e9c98276f2a401cdea051769cccf4431b Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Sun, 7 Mar 2021 22:35:16 -0500 Subject: [PATCH 10/20] Try fromJSON with format to make an array in GitHub Actions --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8ed586a1c6..0f02585a12 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,7 @@ jobs: - name: Setup python uses: actions/setup-python@v2 with: - python-version: ${{ fromJSON('["${{ matrix.python }}.0-alpha - ${{ matrix.python }}.X", "${{ matrix.python }}"]')[startsWith(matrix.python, 'pypy')] }} + python-version: ${{ fromJSON(format('["{0}", "{1}"]', '${{ matrix.python }}.0-alpha - ${{ matrix.python }}.X', '${{ matrix.python }}'))[startsWith(matrix.python, 'pypy')] }} architecture: '${{ matrix.arch }}' - name: Run tests run: ./ci.sh @@ -77,7 +77,7 @@ jobs: uses: actions/setup-python@v2 if: "!endsWith(matrix.python, '-dev')" with: - python-version: ${{ fromJSON('["${{ matrix.python }}.0-alpha - ${{ matrix.python }}.X", "${{ matrix.python }}"]')[startsWith(matrix.python, 'pypy')] }} + python-version: ${{ fromJSON(format('["{0}", "{1}"]', '${{ matrix.python }}.0-alpha - ${{ matrix.python }}.X', '${{ matrix.python }}'))[startsWith(matrix.python, 'pypy')] }} - name: Setup python (dev) uses: deadsnakes/action@v2.0.2 if: endsWith(matrix.python, '-dev') @@ -105,7 +105,7 @@ jobs: - name: Setup python uses: actions/setup-python@v2 with: - python-version: ${{ fromJSON('["${{ matrix.python }}.0-alpha - ${{ matrix.python }}.X", "${{ matrix.python }}"]')[startsWith(matrix.python, 'pypy')] }} + python-version: ${{ fromJSON(format('["{0}", "{1}"]', '${{ matrix.python }}.0-alpha - ${{ matrix.python }}.X', '${{ matrix.python }}'))[startsWith(matrix.python, 'pypy')] }} - name: Run tests run: ./ci.sh env: From 423d4976555d8e43802d563d8cf130eb336dcf6a Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Sun, 7 Mar 2021 22:38:36 -0500 Subject: [PATCH 11/20] More formatting for GHA --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0f02585a12..51a5e07704 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,7 @@ jobs: - name: Setup python uses: actions/setup-python@v2 with: - python-version: ${{ fromJSON(format('["{0}", "{1}"]', '${{ matrix.python }}.0-alpha - ${{ matrix.python }}.X', '${{ matrix.python }}'))[startsWith(matrix.python, 'pypy')] }} + python-version: ${{ fromJSON(format('["{0}", "{1}"]', format('{0}.0-alpha - {0}.X', matrix.python), ${{ matrix.python }}))[startsWith(matrix.python, 'pypy')] }} architecture: '${{ matrix.arch }}' - name: Run tests run: ./ci.sh @@ -77,7 +77,7 @@ jobs: uses: actions/setup-python@v2 if: "!endsWith(matrix.python, '-dev')" with: - python-version: ${{ fromJSON(format('["{0}", "{1}"]', '${{ matrix.python }}.0-alpha - ${{ matrix.python }}.X', '${{ matrix.python }}'))[startsWith(matrix.python, 'pypy')] }} + python-version: ${{ fromJSON(format('["{0}", "{1}"]', format('{0}.0-alpha - {0}.X', matrix.python), ${{ matrix.python }}))[startsWith(matrix.python, 'pypy')] }} - name: Setup python (dev) uses: deadsnakes/action@v2.0.2 if: endsWith(matrix.python, '-dev') @@ -105,7 +105,7 @@ jobs: - name: Setup python uses: actions/setup-python@v2 with: - python-version: ${{ fromJSON(format('["{0}", "{1}"]', '${{ matrix.python }}.0-alpha - ${{ matrix.python }}.X', '${{ matrix.python }}'))[startsWith(matrix.python, 'pypy')] }} + python-version: ${{ fromJSON(format('["{0}", "{1}"]', format('{0}.0-alpha - {0}.X', matrix.python), ${{ matrix.python }}))[startsWith(matrix.python, 'pypy')] }} - name: Run tests run: ./ci.sh env: From 78a497166b4521ab8eabe2338271a4655f6bf915 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Sun, 7 Mar 2021 22:42:59 -0500 Subject: [PATCH 12/20] Less ${{ }} for GHA --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 51a5e07704..503f33d7dc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,7 @@ jobs: - name: Setup python uses: actions/setup-python@v2 with: - python-version: ${{ fromJSON(format('["{0}", "{1}"]', format('{0}.0-alpha - {0}.X', matrix.python), ${{ matrix.python }}))[startsWith(matrix.python, 'pypy')] }} + python-version: ${{ fromJSON(format('["{0}", "{1}"]', format('{0}.0-alpha - {0}.X', matrix.python), matrix.python))[startsWith(matrix.python, 'pypy')] }} architecture: '${{ matrix.arch }}' - name: Run tests run: ./ci.sh @@ -77,7 +77,7 @@ jobs: uses: actions/setup-python@v2 if: "!endsWith(matrix.python, '-dev')" with: - python-version: ${{ fromJSON(format('["{0}", "{1}"]', format('{0}.0-alpha - {0}.X', matrix.python), ${{ matrix.python }}))[startsWith(matrix.python, 'pypy')] }} + python-version: ${{ fromJSON(format('["{0}", "{1}"]', format('{0}.0-alpha - {0}.X', matrix.python), matrix.python))[startsWith(matrix.python, 'pypy')] }} - name: Setup python (dev) uses: deadsnakes/action@v2.0.2 if: endsWith(matrix.python, '-dev') @@ -105,7 +105,7 @@ jobs: - name: Setup python uses: actions/setup-python@v2 with: - python-version: ${{ fromJSON(format('["{0}", "{1}"]', format('{0}.0-alpha - {0}.X', matrix.python), ${{ matrix.python }}))[startsWith(matrix.python, 'pypy')] }} + python-version: ${{ fromJSON(format('["{0}", "{1}"]', format('{0}.0-alpha - {0}.X', matrix.python), matrix.python))[startsWith(matrix.python, 'pypy')] }} - name: Run tests run: ./ci.sh env: From dfcdf5002cc9be39c4485c5673fcb3b761cee54f Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Sun, 7 Mar 2021 22:48:07 -0500 Subject: [PATCH 13/20] Add 3.10-dev as well --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 503f33d7dc..4e71fabc6d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,7 +59,7 @@ jobs: strategy: fail-fast: false matrix: - python: ['pypy-3.6', 'pypy-3.7', '3.6', '3.7', '3.8', '3.9', '3.10', '3.8-dev', '3.9-dev'] + python: ['pypy-3.6', 'pypy-3.7', '3.6', '3.7', '3.8', '3.9', '3.10', '3.8-dev', '3.9-dev', '3.10-dev'] check_formatting: ['0'] pypy_nightly_branch: [''] extra_name: [''] From 46fd668ddd4d330eb810a9c224fa24fd32bc94fe Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Mon, 8 Mar 2021 15:15:49 -0500 Subject: [PATCH 14/20] Use typed-ast from git for 3.10 for now https://github.com/python/typed_ast/issues/156 --- ci.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ci.sh b/ci.sh index b4f56f7114..0d5e77e6b4 100755 --- a/ci.sh +++ b/ci.sh @@ -69,6 +69,8 @@ python -c "import sys, struct, ssl; print('#' * 70); print('python:', sys.versio python -m pip install -U pip setuptools wheel python -m pip --version +python -m pip install 'typed-ast @ git+https://github.com/python/typed_ast; python_version >= "3.10"' + python setup.py sdist --formats=zip python -m pip install dist/*.zip From 37daed79b5d347d5c6e176a326086b969398a0e4 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Mon, 8 Mar 2021 15:27:03 -0500 Subject: [PATCH 15/20] Use threading.__excepthook__ in disable_threading_excepthook() when available --- trio/_core/tests/tutil.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/trio/_core/tests/tutil.py b/trio/_core/tests/tutil.py index 7f51750869..84a5a9a9fb 100644 --- a/trio/_core/tests/tutil.py +++ b/trio/_core/tests/tutil.py @@ -97,7 +97,11 @@ def restore_unraisablehook(): @contextmanager def disable_threading_excepthook(): - threading.excepthook, prev = _noop, threading.excepthook + if sys.version_info >= (3, 10): + threading.excepthook, prev = threading.__excepthook__, threading.excepthook + else: + threading.excepthook, prev = _noop, threading.excepthook + try: yield finally: From 3fb82d1d7c93ceda782f3ef778656d3ba9989c30 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Mon, 8 Mar 2021 15:42:43 -0500 Subject: [PATCH 16/20] Document python-version: craziness for handling alpha->release easily --- .github/workflows/ci.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4e71fabc6d..9726053192 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,6 +41,14 @@ jobs: - name: Setup python uses: actions/setup-python@v2 with: + # This allows the matrix to specify just the major.minor version while still + # expanding it to get the latest patch version including alpha releases. + # This avoids the need to update for each new alpha, beta, release candidate, + # and then finally an actual release version. actions/setup-python doesn't + # support this for PyPy presently so we get no help there. + # + # CPython -> 3.9.0-alpha - 3.9.X + # PyPy -> pypy-3.7 python-version: ${{ fromJSON(format('["{0}", "{1}"]', format('{0}.0-alpha - {0}.X', matrix.python), matrix.python))[startsWith(matrix.python, 'pypy')] }} architecture: '${{ matrix.arch }}' - name: Run tests From c069b12d32444eded906d073b6f53ecf24091771 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Tue, 8 Jun 2021 21:24:37 +0100 Subject: [PATCH 17/20] avoid deprecated asyncio.Future() --- docs/source/reference-lowlevel.rst | 2 +- notes-to-self/aio-guest-test.py | 2 +- trio/_core/tests/test_guest_mode.py | 2 +- trio/_core/tests/test_run.py | 7 +++---- trio/_core/tests/tutil.py | 8 +++++++- trio/tests/test_util.py | 9 ++++++--- 6 files changed, 19 insertions(+), 11 deletions(-) diff --git a/docs/source/reference-lowlevel.rst b/docs/source/reference-lowlevel.rst index ebd0f57c03..2fe773cbb7 100644 --- a/docs/source/reference-lowlevel.rst +++ b/docs/source/reference-lowlevel.rst @@ -785,7 +785,7 @@ Here's how we'd extend our asyncio example to implement this pattern: asyncio_loop.call_soon_threadsafe(fn) # Revised 'done' callback: set a Future - done_fut = asyncio.Future() + done_fut = asyncio_loop.create_future() def done_callback(trio_main_outcome): done_fut.set_result(trio_main_outcome) diff --git a/notes-to-self/aio-guest-test.py b/notes-to-self/aio-guest-test.py index 5e9b398132..b64a11bd04 100644 --- a/notes-to-self/aio-guest-test.py +++ b/notes-to-self/aio-guest-test.py @@ -4,7 +4,7 @@ async def aio_main(): loop = asyncio.get_running_loop() - trio_done_fut = asyncio.Future() + trio_done_fut = loop.create_future() def trio_done_callback(main_outcome): print(f"trio_main finished: {main_outcome!r}") trio_done_fut.set_result(main_outcome) diff --git a/trio/_core/tests/test_guest_mode.py b/trio/_core/tests/test_guest_mode.py index 0184ff3103..b06849a836 100644 --- a/trio/_core/tests/test_guest_mode.py +++ b/trio/_core/tests/test_guest_mode.py @@ -323,7 +323,7 @@ def aiotrio_run(trio_fn, *, pass_not_threadsafe=True, **start_guest_run_kwargs): loop = asyncio.new_event_loop() async def aio_main(): - trio_done_fut = asyncio.Future() + trio_done_fut = loop.create_future() def trio_done_callback(main_outcome): print(f"trio_fn finished: {main_outcome!r}") diff --git a/trio/_core/tests/test_run.py b/trio/_core/tests/test_run.py index 02f5954e60..c56aaaa092 100644 --- a/trio/_core/tests/test_run.py +++ b/trio/_core/tests/test_run.py @@ -24,6 +24,7 @@ ignore_coroutine_never_awaited_warnings, buggy_pypy_asyncgens, restore_unraisablehook, + create_asyncio_future_in_new_loop, ) from ... import _core @@ -1574,9 +1575,7 @@ async def async_gen(arg): # pragma: no cover def test_calling_asyncio_function_gives_nice_error(): async def child_xyzzy(): - import asyncio - - await asyncio.Future() + await create_asyncio_future_in_new_loop() async def misguided(): await child_xyzzy() @@ -1598,7 +1597,7 @@ async def test_asyncio_function_inside_nursery_does_not_explode(): import asyncio nursery.start_soon(sleep_forever) - await asyncio.Future() + await create_asyncio_future_in_new_loop() assert "asyncio" in str(excinfo.value) diff --git a/trio/_core/tests/tutil.py b/trio/_core/tests/tutil.py index 84a5a9a9fb..3e8053f71f 100644 --- a/trio/_core/tests/tutil.py +++ b/trio/_core/tests/tutil.py @@ -1,4 +1,5 @@ # Utilities for testing +import asyncio import socket as stdlib_socket import threading import os @@ -7,7 +8,7 @@ import pytest import warnings -from contextlib import contextmanager +from contextlib import contextmanager, closing import gc @@ -139,3 +140,8 @@ def check_sequence_matches(seq, template): and os.uname().release[:4] < "12.2", reason="hangs on FreeBSD 12.1 and earlier, due to FreeBSD bug #246350", ) + + +def create_asyncio_future_in_new_loop(): + with closing(asyncio.new_event_loop()) as loop: + return loop.create_future() diff --git a/trio/tests/test_util.py b/trio/tests/test_util.py index 2ea0a1e287..2d57e0ebfc 100644 --- a/trio/tests/test_util.py +++ b/trio/tests/test_util.py @@ -3,7 +3,10 @@ import trio from .. import _core -from .._core.tests.tutil import ignore_coroutine_never_awaited_warnings +from .._core.tests.tutil import ( + ignore_coroutine_never_awaited_warnings, + create_asyncio_future_in_new_loop, +) from .._util import ( signal_raise, ConflictDetector, @@ -114,11 +117,11 @@ def generator_based_coro(): # pragma: no cover assert "asyncio" in str(excinfo.value) with pytest.raises(TypeError) as excinfo: - coroutine_or_error(asyncio.Future()) + coroutine_or_error(create_asyncio_future_in_new_loop()) assert "asyncio" in str(excinfo.value) with pytest.raises(TypeError) as excinfo: - coroutine_or_error(lambda: asyncio.Future()) + coroutine_or_error(create_asyncio_future_in_new_loop) assert "asyncio" in str(excinfo.value) with pytest.raises(TypeError) as excinfo: From 970034e32a4c68566135def068236a636ffa0aae Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Tue, 8 Jun 2021 21:26:48 +0100 Subject: [PATCH 18/20] filterwarnings distutils deprecation warnings --- trio/tests/test_exports.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/trio/tests/test_exports.py b/trio/tests/test_exports.py index 374ce8c044..ef7edb4ccb 100644 --- a/trio/tests/test_exports.py +++ b/trio/tests/test_exports.py @@ -1,3 +1,4 @@ +import re import sys import importlib import types @@ -69,6 +70,17 @@ def public_modules(module): ) @pytest.mark.parametrize("modname", PUBLIC_MODULE_NAMES) @pytest.mark.parametrize("tool", ["pylint", "jedi"]) +@pytest.mark.filterwarnings( + "ignore:" + + re.escape( + "The distutils package is deprecated and slated for removal in Python 3.12. " + "Use setuptools or check PEP 632 for potential alternatives" + ) + + ":DeprecationWarning", + "ignore:" + + re.escape("The distutils.sysconfig module is deprecated, use sysconfig instead") + + ":DeprecationWarning", +) def test_static_tool_sees_all_symbols(tool, modname): module = importlib.import_module(modname) From d37fe5121cbdfb533747b8b1c9020bd381cb1445 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Tue, 8 Jun 2021 21:27:13 +0100 Subject: [PATCH 19/20] filterwarnings NPN deprecation warnings --- trio/tests/test_ssl.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/trio/tests/test_ssl.py b/trio/tests/test_ssl.py index cf59b8bd0a..665024bed2 100644 --- a/trio/tests/test_ssl.py +++ b/trio/tests/test_ssl.py @@ -1,3 +1,5 @@ +import re + import pytest import threading @@ -1184,6 +1186,9 @@ async def test_selected_npn_protocol_before_handshake(client_ctx): server.selected_npn_protocol() +@pytest.mark.filterwarnings( + r"ignore: ssl module. NPN is deprecated, use ALPN instead:UserWarning" +) async def test_selected_npn_protocol_when_not_set(client_ctx): # NPN protocol still returns None when it's not set, # instead of raising an exception From 429f3fa5f87c6c519c74e3b92c65bbdaca12e2e2 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Thu, 10 Jun 2021 20:20:41 +0100 Subject: [PATCH 20/20] remove typed_ast git dep --- ci.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/ci.sh b/ci.sh index 0d5e77e6b4..b4f56f7114 100755 --- a/ci.sh +++ b/ci.sh @@ -69,8 +69,6 @@ python -c "import sys, struct, ssl; print('#' * 70); print('python:', sys.versio python -m pip install -U pip setuptools wheel python -m pip --version -python -m pip install 'typed-ast @ git+https://github.com/python/typed_ast; python_version >= "3.10"' - python setup.py sdist --formats=zip python -m pip install dist/*.zip