Skip to content

Allow IPv6 datagram protocol addresses#15891

Open
popsiclelmlm wants to merge 1 commit into
python:mainfrom
popsiclelmlm:codex/asyncio-datagram-addr
Open

Allow IPv6 datagram protocol addresses#15891
popsiclelmlm wants to merge 1 commit into
python:mainfrom
popsiclelmlm:codex/asyncio-datagram-addr

Conversation

@popsiclelmlm

Copy link
Copy Markdown

Summary

  • Widen asyncio.DatagramProtocol.datagram_received's addr parameter to use socket._RetAddress.
  • Add regression coverage for IPv4 and IPv6 datagram protocol overrides.

Reproduction

Root cause

  • DatagramProtocol.datagram_received used a two-item tuple type as a practical approximation even though datagram addresses vary by socket family.
  • socket.recvfrom already models returned addresses as _RetAddress, which is broad enough for IPv4, IPv6, and non-IP socket families.

Changes

  • Import socket._RetAddress in stdlib/asyncio/protocols.pyi.
  • Use _RetAddress for DatagramProtocol.datagram_received.
  • Add stdlib/@tests/test_cases/asyncio/check_datagram_protocol.py with IPv4 and IPv6 override examples.

Tests

  • PATH="$PWD/.venv/bin:$PATH" pre-commit run --files stdlib/asyncio/protocols.pyi stdlib/@tests/test_cases/asyncio/check_datagram_protocol.py
  • PATH="$PWD/.venv/bin:$PATH" .venv/bin/python tests/regr_test.py stdlib --platform darwin -p 3.10
  • PATH="$PWD/.venv/bin:$PATH" npx pyright@1.1.410 stdlib/@tests/test_cases --pythonversion 3.10 -p pyrightconfig.testcases.json
  • PATH="$PWD/.venv/bin:$PATH" npx pyright@1.1.410 stdlib/asyncio --pythonversion 3.10 -p pyrightconfig.stricter.json
  • git diff --check

Screenshots/Logs

  • Not applicable; stdlib stub/test-only change.
  • Note: tests/runtests.py stdlib/asyncio also ran locally. Its pyright/pre-commit phases passed, but stdlib stubtest failed on this local Python 3.14 environment due unrelated runtime availability/difference issues such as missing _tkinter, missing _curses.BUTTON5_*, and annotationlib differences.

AI disclosure

  • Prepared with assistance from Codex.

Fixes #15169

@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

asyncio: DatagramProtocol.datagram_received has incorrect annotation for addr parameter

1 participant