Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test against 3.10 beta #1921

Merged
merged 34 commits into from
Jun 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
ed869ac
Added the "compact" keyword argument to TracebackException.__init__()
agronholm Feb 25, 2021
8c62409
Test against 3.10 alpha
altendky Mar 6, 2021
2a946a4
Correct matrix variable references
altendky Mar 6, 2021
9e8692f
Add 3.10 to Linux and macOS as well
altendky Mar 6, 2021
16f2508
Merge branch 'traceback-compact' into test_3.10a
altendky Mar 7, 2021
e42c887
reorder ubunty python versions
altendky Mar 7, 2021
0af8e6c
Pass _seen=None through to TracebackException.__init__() monkey patch
altendky Mar 8, 2021
034dde3
Merge branch 'master' into test_3.10a
altendky Mar 8, 2021
8963957
Handle _seen=None properly for TracebackException.from_exception()
altendky Mar 8, 2021
702fbb9
Try indexing to pick fancy alpha-latest for cpython and straight for …
altendky Mar 8, 2021
5558db5
Try fromJSON to make an array in GitHub Actions
altendky Mar 8, 2021
183b8c8
Try fromJSON with format to make an array in GitHub Actions
altendky Mar 8, 2021
423d497
More formatting for GHA
altendky Mar 8, 2021
78a4971
Less ${{ }} for GHA
altendky Mar 8, 2021
dfcdf50
Add 3.10-dev as well
altendky Mar 8, 2021
46fd668
Use typed-ast from git for 3.10 for now
altendky Mar 8, 2021
37daed7
Use threading.__excepthook__ in disable_threading_excepthook() when a…
altendky Mar 8, 2021
3fb82d1
Document python-version: craziness for handling alpha->release easily
altendky Mar 8, 2021
bc3ef16
Merge branch 'master' into test_3.10a
altendky Mar 13, 2021
444c323
Merge branch 'master' into test_3.10a
altendky Mar 16, 2021
ca055e4
Merge branch 'master' into test_3.10a
altendky Mar 27, 2021
f93c427
Merge branch 'master' into test_3.10a
altendky Apr 12, 2021
68fd627
Merge branch 'master' into test_3.10a
altendky Apr 12, 2021
3d154d3
Merge branch 'master' into test_3.10a
altendky Apr 13, 2021
35eb6fc
Merge branch 'master' into test_3.10a
altendky May 7, 2021
d883dbe
Merge branch 'master' into test_3.10a
altendky May 17, 2021
c069b12
avoid deprecated asyncio.Future()
graingert Jun 8, 2021
970034e
filterwarnings distutils deprecation warnings
graingert Jun 8, 2021
d37fe51
filterwarnings NPN deprecation warnings
graingert Jun 8, 2021
2ffb578
Merge branch 'master' of github.com:python-trio/trio into test_3.10a
graingert Jun 8, 2021
429f3fa
remove typed_ast git dep
graingert Jun 10, 2021
3e192d1
Merge branch 'master' into test_3.10a
altendky Jun 10, 2021
c079d3c
Merge branch 'master' into test_3.10a
altendky Jun 14, 2021
43e99f8
Merge branch 'master' into test_3.10a
altendky Jun 14, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ['']
Expand All @@ -41,7 +41,15 @@ jobs:
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: '${{ matrix.python }}'
# 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
run: ./ci.sh
Expand All @@ -59,7 +67,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.10', '3.8-dev', '3.9-dev', '3.10-dev']
check_formatting: ['0']
pypy_nightly_branch: ['']
extra_name: ['']
Expand All @@ -77,7 +85,7 @@ jobs:
uses: actions/setup-python@v2
if: "!endsWith(matrix.python, '-dev')"
with:
python-version: '${{ matrix.python }}'
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')
Expand All @@ -98,14 +106,14 @@ 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
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: '${{ matrix.python }}'
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:
Expand Down
2 changes: 1 addition & 1 deletion docs/source/reference-lowlevel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion notes-to-self/aio-guest-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 12 additions & 3 deletions trio/_core/_multierror.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,10 +381,13 @@ def traceback_exception_init(
limit=None,
lookup_lines=True,
capture_locals=False,
compact=False,
altendky marked this conversation as resolved.
Show resolved Hide resolved
_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(
Expand All @@ -396,8 +399,14 @@ def traceback_exception_init(
lookup_lines=lookup_lines,
capture_locals=capture_locals,
_seen=_seen,
**kwargs,
)

seen_was_none = _seen is None

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 = []
Expand All @@ -411,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
Expand Down
2 changes: 1 addition & 1 deletion trio/_core/tests/test_guest_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
7 changes: 3 additions & 4 deletions trio/_core/tests/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
ignore_coroutine_never_awaited_warnings,
buggy_pypy_asyncgens,
restore_unraisablehook,
create_asyncio_future_in_new_loop,
)

from ... import _core
Expand Down Expand Up @@ -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()
Expand All @@ -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)


Expand Down
14 changes: 12 additions & 2 deletions trio/_core/tests/tutil.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Utilities for testing
import asyncio
import socket as stdlib_socket
import threading
import os
Expand All @@ -7,7 +8,7 @@

import pytest
import warnings
from contextlib import contextmanager
from contextlib import contextmanager, closing

import gc

Expand Down Expand Up @@ -97,7 +98,11 @@ def restore_unraisablehook():

@contextmanager
def disable_threading_excepthook():
altendky marked this conversation as resolved.
Show resolved Hide resolved
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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is mysterious :-). What's going on here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was for disabling the thread hooks that pytest started using in 6.2 or so to catch and complain about uncaught exceptions in threads. In certain cases, IIRC, we literally have explanations in the code, or even the error messages, saying that yes, these will fall out un-handled in the thread or whatever but that that's the way it is and we know. But @graingert did this bit. The added bit here is to use the 'original' excepthook instead of a noop when it is available (in 3.10). This additional feature in 3.10 let's this code be more consistent with the restore_unraisablehook() above.

Hopefully that's in the direction you were wondering about...

try:
yield
finally:
Expand Down Expand Up @@ -135,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()
12 changes: 12 additions & 0 deletions trio/tests/test_exports.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
import sys
import importlib
import types
Expand Down Expand Up @@ -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)

Expand Down
4 changes: 4 additions & 0 deletions trio/tests/test_ssl.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
import sys

import pytest
Expand Down Expand Up @@ -1198,6 +1199,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
Expand Down
9 changes: 6 additions & 3 deletions trio/tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down