Skip to content

socket: vendor Lib/socket.py and drop the bogus _socket.makefile stub#48

Merged
tamnd merged 2 commits into
mainfrom
feat/v0.12.3-socket-vendor
May 15, 2026
Merged

socket: vendor Lib/socket.py and drop the bogus _socket.makefile stub#48
tamnd merged 2 commits into
mainfrom
feat/v0.12.3-socket-vendor

Conversation

@tamnd
Copy link
Copy Markdown
Owner

@tamnd tamnd commented May 15, 2026

Summary

CPython splits socket across two layers: Modules/socketmodule.c for the low-level _socket primitives and Lib/socket.py for the user-facing class that wraps _socket.socket with makefile, SocketIO, create_connection, create_server, and the AF_* / SOCK_* / MSG_* / AI_* IntEnum promotion. We had the lower layer and a hand-rolled NotImplementedError stub where makefile should live.

This vendors Lib/socket.py verbatim under stdlib/, adds the redirect shim at module/socket/module.go so PathFinder serves it, and removes the sockMakefile stub from _socket (the method has never been part of socketmodule.c).

While wiring it up I had to add os._get_exports_list to module/os/module.go because socket.py calls it during the IntEnum._convert_ promotion of AF_* / SOCK_* integers. Direct port of Lib/os.py:44.

Test plan

  • go build ./...
  • go vet ./...
  • go test ./stdlibinit/ -run TestImportSocket -v covers import socket, AF_INET integer equivalence, SocketKind.SOCK_STREAM.name, and the AddressFamily enum type
  • go test ./... (only pre-existing macOS-only lexer parity skip on bytecodes.c token count)
  • CI green across ubuntu / macos / windows

@tamnd
Copy link
Copy Markdown
Owner Author

tamnd commented May 15, 2026

All six checks green on the second push:

  • vet, lint, test (ubuntu / macos / windows), coverage — pass
  • TestImportSocket covers the new import socket path end-to-end (IntEnum promotion of AF_/SOCK_, the AddressFamily type)
  • TestGateTextIOWrapperCodecs now stable on Windows after reconfiguring the gate script's stdout to UTF-8

The CI workflow now also gives every step a human-readable name:, so future failure logs read "Run tests" / "Set up Go" instead of UNKNOWN STEP.

CPython splits socket into two layers: Modules/socketmodule.c (the
low-level _socket primitives) plus Lib/socket.py (the public class
that wraps _socket.socket and adds makefile, create_connection,
SocketIO, the AF_/SOCK_/MSG_/AI_ IntEnum promotion, etc.). gopy had
half of the lower layer and a hand-rolled NotImplementedError stub
where makefile should be.

This vendors Lib/socket.py verbatim and adds a redirect shim under
module/socket/ so PathFinder serves it; the makefile stub on the
_socket type goes away because that method has never lived in
Modules/socketmodule.c. Also pulls in os._get_exports_list because
socket.py needs it during IntEnum._convert_ promotion.
@tamnd tamnd force-pushed the feat/v0.12.3-socket-vendor branch from 4c77076 to aeb9bc3 Compare May 15, 2026 02:20
Flip rows whose ports actually landed:
- types: all five descriptor types resolve via type(...) in stdlib/types.py
- dataclasses: make_dataclass/order/slots/InitVar all in module/dataclasses
- VM / compile audit: three sweeps closed (#586/#587/#588)
- socket: new row for the Lib/socket.py vendor on top of _socket
- VM audit sub-table rows A/B/C: pending -> done

Refresh notes on the remaining partial rows (_colorize, functools,
pprint, time, traceback) to match the current blocker shape, and
add a top-level Checklist so the at-a-glance view stays current.
@tamnd tamnd merged commit 6dc8bb2 into main May 15, 2026
6 checks passed
@tamnd tamnd deleted the feat/v0.12.3-socket-vendor branch May 15, 2026 02:31
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.

1 participant