0

Revert "Reland "Reland Migrate to python 3.11 from 3.8""

This reverts commit a5a4a98193.

Reason for revert:
LUCI Bisection has identified this change as the cause of a test failure. See the analysis: https://ci.chromium.org/ui/p/chromium/bisection/test-analysis/b/5987431141605376

Sample build with failed test: https://ci.chromium.org/b/8724910883092854417
Affected test(s):
[ninja://:chrome_wpt_tests/external/wpt/webdriver/tests/bidi/session/unsubscribe/invalid.py](https://ci.chromium.org/ui/test/chromium/ninja:%2F%2F:chrome_wpt_tests%2Fexternal%2Fwpt%2Fwebdriver%2Ftests%2Fbidi%2Fsession%2Funsubscribe%2Finvalid.py?q=VHash%3A1b1e9c5537be9730)

If this is a false positive, please report it at http://b.corp.google.com/createIssue?component=1199205&description=Analysis%3A+https%3A%2F%2Fci.chromium.org%2Fui%2Fp%2Fchromium%2Fbisection%2Ftest-analysis%2Fb%2F5987431141605376&format=PLAIN&priority=P3&title=Wrongly+blamed+https%3A%2F%2Fchromium-review.googlesource.com%2Fc%2Fchromium%2Fsrc%2F%2B%2F6168586&type=BUG

Original change's description:
> Reland "Reland Migrate to python 3.11 from 3.8"
>
> This is a reland of commit ae42a262c8
>
> The CL was reverted as it caused devices to hang when running tests
> on android. (https://github.com/python/cpython/issues/106883)
>
> This has been fixed with a patch that fixed a bug in the python
> 3.11 interpreter.
>
> https://chromium-review.googlesource.com/c/infra/infra/+/6155095
>
> And then rolling out that change to depot_tools:
> https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6158273
>
> Original change's description:
> > Reland Migrate to python 3.11 from 3.8
> >
> > Original CL: https://chromium-review.googlesource.com/c/chromium/src/+/5872818
> > was reverted and was not able to create an actual reland because of
> > rebase merge failure with "create reland" button.
> >
> > Previous CL was reverted from failing:
> > chromeos-jacuzzi-rel
> > chromeos-octopus-rel
> >
> > This is from a incompatibility in aioquic, which is now fixed with
> > an update to aioquick 1.2 (and its supporting libraries) as well as
> > adding python and permission changes to chromeos.
> >
> > crrev.com/5904256
> > crrev.com/5904734
> >
> > and some internal changes.
> >
> > The webtransport_h3_server.py file has to be changed here with the
> > vpython change, and then wpt can be rolled. The change is already
> > in the wpt repo, but has been manually excluded in the roll.
> >
> > Bug: 40942322
> > Change-Id: Id12b7085fbc1ffd7694712013e6f746e65c3499f
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5887447
> > Reviewed-by: Ben Pastene <bpastene@chromium.org>
> > Reviewed-by: Brian Sheedy <bsheedy@chromium.org>
> > Commit-Queue: Benjamin Joyce (Ben) <bjoyce@chromium.org>
> > Reviewed-by: Jonathan Lee <jonathanjlee@google.com>
> > Cr-Commit-Position: refs/heads/main@{#1370866}
>
> Bug: 40942322
> Change-Id: Icce4762639fa96104f81c114e853f8069c95cf85
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6168586
> Reviewed-by: Jonathan Lee <jonathanjlee@google.com>
> Reviewed-by: mmenke <mmenke@chromium.org>
> Reviewed-by: Ben Pastene <bpastene@chromium.org>
> Reviewed-by: Brian Sheedy <bsheedy@chromium.org>
> Commit-Queue: Benjamin Joyce (Ben) <bjoyce@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1410521}
>

Bug: 40942322
Change-Id: I0610989dbb4011d4d10b3c5b2cedaf1417e80c99
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6196028
Owners-Override: Ivana Žužić <izuzic@google.com>
Reviewed-by: Ivana Žužić <izuzic@google.com>
Commit-Queue: Ivana Žužić <izuzic@google.com>
Cr-Commit-Position: refs/heads/main@{#1410881}
This commit is contained in:
luci-bisection@appspot.gserviceaccount.com
2025-01-24 06:06:20 -08:00
committed by Chromium LUCI CQ
parent c1f3755a62
commit 468d53d6ec
13 changed files with 146 additions and 96 deletions
.vpython3
infra/config
generated
builders
ci
chromeos-amd64-generic-rel-gtest
chromeos-amd64-generic-rel
try
chromeos-amd64-generic-rel-gtest-and-tast
chromeos-amd64-generic-rel-gtest
testing
targets
net/tools/testserver
third_party/wpt_tools
tools/perf

@@ -22,20 +22,20 @@
# Read more about `vpython` and how to modify this file here: # Read more about `vpython` and how to modify this file here:
# https://chromium.googlesource.com/infra/infra/+/main/doc/users/vpython.md # https://chromium.googlesource.com/infra/infra/+/main/doc/users/vpython.md
python_version: "3.11" python_version: "3.8"
# The default set of platforms vpython checks does not yet include mac-arm64. # The default set of platforms vpython checks does not yet include mac-arm64.
# Setting `verify_pep425_tag` to the list of platforms we explicitly must support # Setting `verify_pep425_tag` to the list of platforms we explicitly must support
# allows us to ensure that vpython specs stay mac-arm64-friendly # allows us to ensure that vpython specs stay mac-arm64-friendly
verify_pep425_tag: [ verify_pep425_tag: [
{python: "cp311", abi: "cp311", platform: "manylinux1_x86_64"}, {python: "cp38", abi: "cp38", platform: "manylinux1_x86_64"},
{python: "cp311", abi: "cp311", platform: "linux_arm64"}, {python: "cp38", abi: "cp38", platform: "linux_arm64"},
{python: "cp311", abi: "cp311", platform: "macosx_10_10_intel"}, {python: "cp38", abi: "cp38", platform: "macosx_10_10_intel"},
{python: "cp311", abi: "cp311", platform: "macosx_11_0_arm64"}, {python: "cp38", abi: "cp38", platform: "macosx_11_0_arm64"},
{python: "cp311", abi: "cp311", platform: "win32"}, {python: "cp38", abi: "cp38", platform: "win32"},
{python: "cp311", abi: "cp311", platform: "win_amd64"} {python: "cp38", abi: "cp38", platform: "win_amd64"}
] ]
# Used by: # Used by:
@@ -111,7 +111,7 @@ wheel: <
> >
wheel: < wheel: <
name: "infra/python/wheels/ninja/${vpython_platform}" name: "infra/python/wheels/ninja/${vpython_platform}"
version: "version:1.10.2.4.chromium.1" version: "version:1.10.0.post2"
match_tag: < match_tag: <
platform: "manylinux1_x86_64" platform: "manylinux1_x86_64"
> >
@@ -150,7 +150,7 @@ wheel: <
> >
wheel: < wheel: <
name: "infra/python/wheels/opencv_python/${vpython_platform}" name: "infra/python/wheels/opencv_python/${vpython_platform}"
version: "version:4.8.1.78.chromium.1" version: "version:4.5.3.56.chromium.4"
# There is currently no Linux arm/arm64 version in CIPD. # There is currently no Linux arm/arm64 version in CIPD.
not_match_tag: < not_match_tag: <
platform: "linux_arm64" platform: "linux_arm64"
@@ -177,8 +177,8 @@ wheel: <
> >
wheel: < wheel: <
name: "infra/python/wheels/pyfakefs-py3" name: "infra/python/wheels/pyfakefs-py2_py3"
version: "version:5.5.0" version: "version:3.7.2"
> >
# Used by: # Used by:
@@ -189,7 +189,7 @@ wheel: <
> >
wheel: < wheel: <
name: "infra/python/wheels/python-dateutil-py2_py3" name: "infra/python/wheels/python-dateutil-py2_py3"
version: "version:2.8.1" version: "version:2.7.3"
> >
# Used by WPT importer # Used by WPT importer
@@ -210,8 +210,8 @@ wheel: <
version: "version:3.4.2" version: "version:3.4.2"
> >
wheel: < wheel: <
name: "infra/python/wheels/cachetools-py3" name: "infra/python/wheels/cachetools-py2_py3"
version: "version:5.3.3" version: "version:2.0.1"
> >
wheel: < wheel: <
name: "infra/python/wheels/uritemplate-py3" name: "infra/python/wheels/uritemplate-py3"
@@ -255,7 +255,7 @@ wheel: <
# //third_party/chromite/bin/cros chrome-sdk # //third_party/chromite/bin/cros chrome-sdk
wheel: < wheel: <
name: "infra/python/wheels/crcmod/${vpython_platform}" name: "infra/python/wheels/crcmod/${vpython_platform}"
version: "version:1.7.chromium.4" version: "version:1.7.chromium.3"
> >
wheel: < wheel: <
@@ -322,7 +322,7 @@ wheel: <
> >
wheel: < wheel: <
name: "infra/python/wheels/mozprocess-py3" name: "infra/python/wheels/mozprocess-py3"
version: "version:1.3.1" version: "version:1.3.0"
> >
wheel: < wheel: <
name: "infra/python/wheels/urllib3-py2_py3" name: "infra/python/wheels/urllib3-py2_py3"
@@ -362,7 +362,7 @@ wheel: <
> >
wheel: < wheel: <
name: "infra/python/wheels/aioquic/${vpython_platform}" name: "infra/python/wheels/aioquic/${vpython_platform}"
version: "version:1.2.0.chromium.1" version: "version:0.9.20.chromium.1"
> >
wheel: < wheel: <
name: "infra/python/wheels/pylsqpack/${vpython_platform}" name: "infra/python/wheels/pylsqpack/${vpython_platform}"
@@ -370,11 +370,11 @@ wheel: <
> >
wheel: < wheel: <
name: "infra/python/wheels/cryptography/${vpython_platform}" name: "infra/python/wheels/cryptography/${vpython_platform}"
version: "version:43.0.0" version: "version:3.3.1.chromium.1"
> >
wheel: < wheel: <
name: "infra/python/wheels/cffi/${vpython_platform}" name: "infra/python/wheels/cffi/${vpython_platform}"
version: "version:1.15.1.chromium.2" version: "version:1.14.5.chromium.7"
> >
wheel: < wheel: <
name: "infra/python/wheels/pycparser-py2_py3" name: "infra/python/wheels/pycparser-py2_py3"
@@ -433,9 +433,9 @@ wheel <
version: "version:0.19.0" version: "version:0.19.0"
> >
wheel: < wheel <
name: "infra/python/wheels/attrs-py3" name: "infra/python/wheels/attrs-py2_py3"
version: "version:23.1.0" version: "version:21.4.0"
> >
wheel < wheel <
@@ -450,7 +450,7 @@ wheel <
wheel < wheel <
name: "infra/python/wheels/py-py2_py3" name: "infra/python/wheels/py-py2_py3"
version: "version:1.11.0" version: "version:1.10.0"
> >
wheel < wheel <
@@ -472,7 +472,7 @@ wheel: <
# //testing/buildbot/generate_buildbot_json_coveragetest.py # //testing/buildbot/generate_buildbot_json_coveragetest.py
wheel: < wheel: <
name: "infra/python/wheels/coverage/${vpython_platform}" name: "infra/python/wheels/coverage/${vpython_platform}"
version: "version:7.3.1" version: "version:5.5.chromium.3"
> >
wheel: < wheel: <
@@ -494,7 +494,7 @@ wheel: <
# //tools/perf/crossbench # //tools/perf/crossbench
wheel: < wheel: <
name: "infra/python/wheels/pytz-py2_py3" name: "infra/python/wheels/pytz-py2_py3"
version: "version:2024.1" version: "version:2018.4"
> >
# Used by: # Used by:
@@ -514,7 +514,7 @@ wheel: <
# //content/test/gpu/gpu_tests/color_profile_manager_mac.py # //content/test/gpu/gpu_tests/color_profile_manager_mac.py
wheel: < wheel: <
name: "infra/python/wheels/pyobjc/${vpython_platform}" name: "infra/python/wheels/pyobjc/${vpython_platform}"
version: "version:10.0" version: "version:7.3.chromium.1"
match_tag: < match_tag: <
platform: "macosx_10_10_intel" platform: "macosx_10_10_intel"
> >
@@ -535,7 +535,7 @@ wheel: <
# //tools/perf/crossbench # //tools/perf/crossbench
wheel: < wheel: <
name: "infra/python/wheels/pandas/${vpython_platform}" name: "infra/python/wheels/pandas/${vpython_platform}"
version: "version:1.5.3.chromium.1" version: "version:1.3.2.chromium.1"
not_match_tag: < not_match_tag: <
platform: "linux_arm64" platform: "linux_arm64"
> >
@@ -573,10 +573,6 @@ wheel: <
name: "infra/python/wheels/selenium-py3" name: "infra/python/wheels/selenium-py3"
version: "version:4.1.0" version: "version:4.1.0"
> >
wheel: <
name: "infra/python/wheels/service-identity-py3"
version: "version:24.1.0"
>
wheel: < wheel: <
name: "infra/python/wheels/trio-py3" name: "infra/python/wheels/trio-py3"
version: "version:0.20.0" version: "version:0.20.0"
@@ -610,8 +606,8 @@ wheel: <
version: "version:2.4.0" version: "version:2.4.0"
> >
wheel: < wheel: <
name: "infra/python/wheels/pyopenssl-py3" name: "infra/python/wheels/pyopenssl-py2_py3"
version: "version:24.2.1" version: "version:20.0.0"
> >
# Used by //tools/md_browser to render Markdown. # Used by //tools/md_browser to render Markdown.
@@ -686,12 +682,6 @@ wheel: <
version: "version:3.1.2" version: "version:3.1.2"
> >
# Needed by pytype
wheel: <
name: "infra/python/wheels/pysocks-py3"
version: "version:1.7.1"
>
# Needed by pytype # Needed by pytype
wheel: < wheel: <
name: "infra/python/wheels/pycnite-py3" name: "infra/python/wheels/pycnite-py3"
@@ -710,7 +700,3 @@ wheel: <
version: "version:2.0.1" version: "version:2.0.1"
> >
wheel: <
name: "infra/python/wheels/apipkg-py2_py3"
version: "version:1.5"
>

@@ -492,7 +492,7 @@
{ {
"cipd_package": "infra/3pp/tools/cpython3/linux-amd64", "cipd_package": "infra/3pp/tools/cpython3/linux-amd64",
"location": "vpython_dir_linux_amd64", "location": "vpython_dir_linux_amd64",
"revision": "version:2@3.11.8.chromium.35" "revision": "version:2@3.8.10.chromium.34"
}, },
{ {
"cipd_package": "infra/tools/luci/vpython3/linux-amd64", "cipd_package": "infra/tools/luci/vpython3/linux-amd64",

@@ -497,7 +497,7 @@
{ {
"cipd_package": "infra/3pp/tools/cpython3/linux-amd64", "cipd_package": "infra/3pp/tools/cpython3/linux-amd64",
"location": "vpython_dir_linux_amd64", "location": "vpython_dir_linux_amd64",
"revision": "version:2@3.11.8.chromium.35" "revision": "version:2@3.8.10.chromium.34"
}, },
{ {
"cipd_package": "infra/tools/luci/vpython3/linux-amd64", "cipd_package": "infra/tools/luci/vpython3/linux-amd64",

@@ -497,7 +497,7 @@
{ {
"cipd_package": "infra/3pp/tools/cpython3/linux-amd64", "cipd_package": "infra/3pp/tools/cpython3/linux-amd64",
"location": "vpython_dir_linux_amd64", "location": "vpython_dir_linux_amd64",
"revision": "version:2@3.11.8.chromium.35" "revision": "version:2@3.8.10.chromium.34"
}, },
{ {
"cipd_package": "infra/tools/luci/vpython3/linux-amd64", "cipd_package": "infra/tools/luci/vpython3/linux-amd64",

@@ -497,7 +497,7 @@
{ {
"cipd_package": "infra/3pp/tools/cpython3/linux-amd64", "cipd_package": "infra/3pp/tools/cpython3/linux-amd64",
"location": "vpython_dir_linux_amd64", "location": "vpython_dir_linux_amd64",
"revision": "version:2@3.11.8.chromium.35" "revision": "version:2@3.8.10.chromium.34"
}, },
{ {
"cipd_package": "infra/tools/luci/vpython3/linux-amd64", "cipd_package": "infra/tools/luci/vpython3/linux-amd64",

@@ -248,7 +248,7 @@
{ {
'cipd_package': 'infra/3pp/tools/cpython3/linux-amd64', 'cipd_package': 'infra/3pp/tools/cpython3/linux-amd64',
'location': 'vpython_dir_linux_amd64', 'location': 'vpython_dir_linux_amd64',
'revision': 'version:2@3.11.8.chromium.35', 'revision': 'version:2@3.8.10.chromium.34',
}, },
{ {
'cipd_package': 'infra/tools/luci/vpython3/linux-amd64', 'cipd_package': 'infra/tools/luci/vpython3/linux-amd64',

@@ -228,7 +228,7 @@ targets.legacy_basic_suite(
targets.cipd_package( targets.cipd_package(
package = "infra/3pp/tools/cpython3/linux-amd64", package = "infra/3pp/tools/cpython3/linux-amd64",
location = "vpython_dir_linux_amd64", location = "vpython_dir_linux_amd64",
revision = "version:2@3.11.8.chromium.35", revision = "version:2@3.8.10.chromium.34",
), ),
targets.cipd_package( targets.cipd_package(
package = "infra/tools/luci/vpython3/linux-amd64", package = "infra/tools/luci/vpython3/linux-amd64",

@@ -26,20 +26,20 @@
# many dependencies and trying to load all dependencies from the main .vpython3 # many dependencies and trying to load all dependencies from the main .vpython3
# spec on ChromeOS VMs runs into disk space issues. # spec on ChromeOS VMs runs into disk space issues.
python_version: "3.11" python_version: "3.8"
# The default set of platforms vpython checks does not yet include mac-arm64. # The default set of platforms vpython checks does not yet include mac-arm64.
# Setting `verify_pep425_tag` to the list of platforms we explicitly must support # Setting `verify_pep425_tag` to the list of platforms we explicitly must support
# allows us to ensure that vpython specs stay mac-arm64-friendly # allows us to ensure that vpython specs stay mac-arm64-friendly
verify_pep425_tag: [ verify_pep425_tag: [
{python: "cp38", abi: "cp311", platform: "manylinux1_x86_64"}, {python: "cp38", abi: "cp38", platform: "manylinux1_x86_64"},
{python: "cp38", abi: "cp311", platform: "linux_arm64"}, {python: "cp38", abi: "cp38", platform: "linux_arm64"},
{python: "cp38", abi: "cp311", platform: "macosx_10_10_intel"}, {python: "cp38", abi: "cp38", platform: "macosx_10_10_intel"},
{python: "cp38", abi: "cp311", platform: "macosx_11_0_arm64"}, {python: "cp38", abi: "cp38", platform: "macosx_11_0_arm64"},
{python: "cp38", abi: "cp311", platform: "win32"}, {python: "cp38", abi: "cp38", platform: "win32"},
{python: "cp38", abi: "cp311", platform: "win_amd64"} {python: "cp38", abi: "cp38", platform: "win_amd64"}
] ]
wheel: < wheel: <

@@ -12,3 +12,6 @@ Description: This includes code for the manifest tool, lint tool, and wptserve.
for more details on maintenance. for more details on maintenance.
Local Modifications: Local Modifications:
- Removed all files except for those listed in wpt/WPTIncludeList. - Removed all files except for those listed in wpt/WPTIncludeList.
- Local patch to the webtransport-H3 server to stay on `aioquic` 0.x, which
can't be upgraded to 1.x until chromium/src is on python3.11
(https://crbug.com/387535231).

@@ -0,0 +1,90 @@
diff --git a/tools/webtransport/h3/webtransport_h3_server.py b/tools/webtransport/h3/webtransport_h3_server.py
index 2dd8f645551d6..8c55ba87e0e59 100644
--- a/tools/webtransport/h3/webtransport_h3_server.py
+++ b/tools/webtransport/h3/webtransport_h3_server.py
@@ -1,7 +1,6 @@
# mypy: allow-subclassing-any, no-warn-return-any
import asyncio
-import contextlib
import logging
import os
import ssl
@@ -10,21 +9,17 @@ import threading
import traceback
from enum import IntEnum
from urllib.parse import urlparse
-from typing import Any, Dict, List, Optional, Tuple, cast
+from typing import Any, Dict, List, Optional, Tuple
# TODO(bashi): Remove import check suppressions once aioquic dependency is resolved.
from aioquic.buffer import Buffer # type: ignore
from aioquic.asyncio import QuicConnectionProtocol, serve # type: ignore
from aioquic.asyncio.client import connect # type: ignore
-from aioquic.asyncio.protocol import QuicStreamAdapter # type: ignore
from aioquic.h3.connection import H3_ALPN, FrameType, H3Connection, ProtocolError, SettingsError # type: ignore
from aioquic.h3.events import H3Event, HeadersReceived, WebTransportStreamDataReceived, DatagramReceived, DataReceived # type: ignore
from aioquic.quic.configuration import QuicConfiguration # type: ignore
from aioquic.quic.connection import logger as quic_connection_logger # type: ignore
-from aioquic.quic.connection import (
- stream_is_client_initiated,
- stream_is_unidirectional,
-)
+from aioquic.quic.connection import stream_is_unidirectional
from aioquic.quic.events import QuicEvent, ProtocolNegotiated, ConnectionTerminated, StreamReset # type: ignore
from aioquic.tls import SessionTicket # type: ignore
@@ -415,7 +410,7 @@ class WebTransportSession:
_logger.warn(
"Sending a datagram while that's now allowed - discarding it")
return
- stream_id = self.session_id
+ flow_id = self.session_id
if self._http.datagram_setting is not None:
# We must have a WebTransport Session ID at this point because
# an extended CONNECT request is already received.
@@ -423,8 +418,8 @@ class WebTransportSession:
# TODO(yutakahirano): Make sure if this is the correct logic.
# Chrome always use 0 for the initial stream and the initial flow
# ID, we cannot check the correctness with it.
- stream_id = self._protocol._session_stream_id
- self._http.send_datagram(stream_id=stream_id, data=data)
+ flow_id = self._protocol._session_stream_id // 4
+ self._http.send_datagram(flow_id=flow_id, data=data)
def stop_stream(self, stream_id: int, code: int) -> None:
"""
@@ -607,25 +602,6 @@ async def _connect_server_with_timeout(host: str, port: int, timeout: float) ->
return True
-def _close_unusable_writer(reader: asyncio.StreamReader, writer: asyncio.StreamWriter) -> None:
- # Starting in python3.11, `StreamWriter.__del__` implicitly `close()`s
- # itself [0], if it has not done so already. Because aioquic sometimes
- # models a unidirectional stream with a bidirectional transport [1], the
- # `writer` here for a server -> client stream may log a benign but
- # scary-looking exception when it's GC'ed and unsuccessfully writes EOF.
- #
- # For the purpose of checking connectivity, work around this for now by
- # preemptively closing such streams and suppressing the resulting
- # exceptions.
- #
- # [0]: https://github.com/python/cpython/blob/3.11/Lib/asyncio/streams.py#L413
- # [1]: https://github.com/aiortc/aioquic/blob/1.2.0/src/aioquic/asyncio/protocol.py#L241
- stream_id = cast(QuicStreamAdapter, writer.transport).stream_id
- if stream_is_unidirectional(stream_id) and not stream_is_client_initiated(stream_id):
- with contextlib.suppress(ValueError):
- writer.close()
-
-
async def _connect_to_server(host: str, port: int) -> None:
configuration = QuicConfiguration(
alpn_protocols=H3_ALPN,
@@ -633,6 +609,5 @@ async def _connect_to_server(host: str, port: int) -> None:
verify_mode=ssl.CERT_NONE,
)
- async with connect(host, port, configuration=configuration,
- stream_handler=_close_unusable_writer) as protocol:
+ async with connect(host, port, configuration=configuration) as protocol:
await protocol.ping()

@@ -1,7 +1,6 @@
# mypy: allow-subclassing-any, no-warn-return-any # mypy: allow-subclassing-any, no-warn-return-any
import asyncio import asyncio
import contextlib
import logging import logging
import os import os
import ssl import ssl
@@ -10,21 +9,17 @@ import threading
import traceback import traceback
from enum import IntEnum from enum import IntEnum
from urllib.parse import urlparse from urllib.parse import urlparse
from typing import Any, Dict, List, Optional, Tuple, cast from typing import Any, Dict, List, Optional, Tuple
# TODO(bashi): Remove import check suppressions once aioquic dependency is resolved. # TODO(bashi): Remove import check suppressions once aioquic dependency is resolved.
from aioquic.buffer import Buffer # type: ignore from aioquic.buffer import Buffer # type: ignore
from aioquic.asyncio import QuicConnectionProtocol, serve # type: ignore from aioquic.asyncio import QuicConnectionProtocol, serve # type: ignore
from aioquic.asyncio.client import connect # type: ignore from aioquic.asyncio.client import connect # type: ignore
from aioquic.asyncio.protocol import QuicStreamAdapter # type: ignore
from aioquic.h3.connection import H3_ALPN, FrameType, H3Connection, ProtocolError, SettingsError # type: ignore from aioquic.h3.connection import H3_ALPN, FrameType, H3Connection, ProtocolError, SettingsError # type: ignore
from aioquic.h3.events import H3Event, HeadersReceived, WebTransportStreamDataReceived, DatagramReceived, DataReceived # type: ignore from aioquic.h3.events import H3Event, HeadersReceived, WebTransportStreamDataReceived, DatagramReceived, DataReceived # type: ignore
from aioquic.quic.configuration import QuicConfiguration # type: ignore from aioquic.quic.configuration import QuicConfiguration # type: ignore
from aioquic.quic.connection import logger as quic_connection_logger # type: ignore from aioquic.quic.connection import logger as quic_connection_logger # type: ignore
from aioquic.quic.connection import ( from aioquic.quic.connection import stream_is_unidirectional
stream_is_client_initiated,
stream_is_unidirectional,
)
from aioquic.quic.events import QuicEvent, ProtocolNegotiated, ConnectionTerminated, StreamReset # type: ignore from aioquic.quic.events import QuicEvent, ProtocolNegotiated, ConnectionTerminated, StreamReset # type: ignore
from aioquic.tls import SessionTicket # type: ignore from aioquic.tls import SessionTicket # type: ignore
@@ -415,7 +410,7 @@ class WebTransportSession:
_logger.warn( _logger.warn(
"Sending a datagram while that's now allowed - discarding it") "Sending a datagram while that's now allowed - discarding it")
return return
stream_id = self.session_id flow_id = self.session_id
if self._http.datagram_setting is not None: if self._http.datagram_setting is not None:
# We must have a WebTransport Session ID at this point because # We must have a WebTransport Session ID at this point because
# an extended CONNECT request is already received. # an extended CONNECT request is already received.
@@ -423,8 +418,8 @@ class WebTransportSession:
# TODO(yutakahirano): Make sure if this is the correct logic. # TODO(yutakahirano): Make sure if this is the correct logic.
# Chrome always use 0 for the initial stream and the initial flow # Chrome always use 0 for the initial stream and the initial flow
# ID, we cannot check the correctness with it. # ID, we cannot check the correctness with it.
stream_id = self._protocol._session_stream_id flow_id = self._protocol._session_stream_id // 4
self._http.send_datagram(stream_id=stream_id, data=data) self._http.send_datagram(flow_id=flow_id, data=data)
def stop_stream(self, stream_id: int, code: int) -> None: def stop_stream(self, stream_id: int, code: int) -> None:
""" """
@@ -607,25 +602,6 @@ async def _connect_server_with_timeout(host: str, port: int, timeout: float) ->
return True return True
def _close_unusable_writer(reader: asyncio.StreamReader, writer: asyncio.StreamWriter) -> None:
# Starting in python3.11, `StreamWriter.__del__` implicitly `close()`s
# itself [0], if it has not done so already. Because aioquic sometimes
# models a unidirectional stream with a bidirectional transport [1], the
# `writer` here for a server -> client stream may log a benign but
# scary-looking exception when it's GC'ed and unsuccessfully writes EOF.
#
# For the purpose of checking connectivity, work around this for now by
# preemptively closing such streams and suppressing the resulting
# exceptions.
#
# [0]: https://github.com/python/cpython/blob/3.11/Lib/asyncio/streams.py#L413
# [1]: https://github.com/aiortc/aioquic/blob/1.2.0/src/aioquic/asyncio/protocol.py#L241
stream_id = cast(QuicStreamAdapter, writer.transport).stream_id
if stream_is_unidirectional(stream_id) and not stream_is_client_initiated(stream_id):
with contextlib.suppress(ValueError):
writer.close()
async def _connect_to_server(host: str, port: int) -> None: async def _connect_to_server(host: str, port: int) -> None:
configuration = QuicConfiguration( configuration = QuicConfiguration(
alpn_protocols=H3_ALPN, alpn_protocols=H3_ALPN,
@@ -633,6 +609,5 @@ async def _connect_to_server(host: str, port: int) -> None:
verify_mode=ssl.CERT_NONE, verify_mode=ssl.CERT_NONE,
) )
async with connect(host, port, configuration=configuration, async with connect(host, port, configuration=configuration) as protocol:
stream_handler=_close_unusable_writer) as protocol:
await protocol.ping() await protocol.ping()

@@ -23,16 +23,12 @@ class FindDependenciesTest(unittest.TestCase):
'dependency_test_dir', 'other_animals', 'cat', 'cat') 'dependency_test_dir', 'other_animals', 'cat', 'cat')
cat_module_init_path = os.path.join(cat_module_path, '__init__.py') cat_module_init_path = os.path.join(cat_module_path, '__init__.py')
cat_object_path = os.path.join(cat_module_path, 'cat_object.py') cat_object_path = os.path.join(cat_module_path, 'cat_object.py')
answer_set = {
dog_object_path, cat_module_path, cat_module_init_path,
cat_object_path
}
dependencies = set( dependencies = set(
p for p in find_dependencies.FindPythonDependencies(dog_object_path)) p for p in find_dependencies.FindPythonDependencies(dog_object_path))
self.assertEqual(dependencies, {
for path in answer_set: dog_object_path, cat_module_path, cat_module_init_path,
self.assertIn(path, dependencies) cat_object_path
})
except ImportError: # crbug.com/559527 except ImportError: # crbug.com/559527
pass pass

@@ -83,7 +83,7 @@ class ScriptsSmokeTest(unittest.TestCase):
def testRunRecordWprHelp(self): def testRunRecordWprHelp(self):
return_code, stdout = self.RunPerfScript('record_wpr') return_code, stdout = self.RunPerfScript('record_wpr')
self.assertEqual(return_code, 0, stdout) self.assertEqual(return_code, 0, stdout)
self.assertIn('positional arguments:', stdout) self.assertIn('optional arguments:', stdout)
@decorators.Disabled('chromeos') # crbug.com/814068 @decorators.Disabled('chromeos') # crbug.com/814068
def testRunRecordWprList(self): def testRunRecordWprList(self):