Repository navigation
Align socket receive and control argument binding - #9668
Draft
youknowdot wants to merge 1 commit into
Draft
youknowdot wants to merge 1 commit into
youknowdot wants to merge 1 commit into
Conversation
Reuse keyword parsing for receive buffers, preserve conversion ordering and argument lifetimes, and avoid zero-length receive waits. Assisted-by: OpenAI Codex:model version not exposed
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
recv_into/recvfrom_intokeyword binding through the VM's existingArgSpechelper, preserving buffer export and numeric conversion order.recvandrecv_into, including on closed sockets, as CPython does.sendtoandsetsockoptarguments before conversion, retain original arguments through I/O, and acquiresendto's buffer export before converting flags without holding its data lock across callbacks.Only production Rust files change. Existing special no-keyword and
sendtooverload diagnostics remain.Evidence and validation
Checked CPython 3.15 source (
Modules/socketmodule.c:sock_recv_guts,sock_recv_into,sock_recvfrom_into,sock_sendto, andsock_setsockopt). Bounded CPython 3.15.0 probes using only an owned socketpair confirmed:buffer,nbytes, andflagskeywords.recvandrecv_intoreturn immediately, including after closing the socket.sendtorejects an invalid buffer before invoking a flags callback.setsockoptarity does not invoke numeric callbacks.rustfmtandgit diff --checkpassed. Exact-head cached patches for #9638, #9640, and #9642 each apply cleanly over this change.Passed on Linux against main
0b081b0283987c7b2d79327dd481f403d515580b:cargo check -p rustpython-vm -p rustpython-host_env -p rustpython-stdlib --features rustpython-stdlib/threading --locked --offline -j1cargo clippy -p rustpython-vm -p rustpython-host_env -p rustpython-stdlib --features rustpython-stdlib/threading --locked --offline -j1 -- -D warningsRustPython runtime tests, the full Rust suites, Python suites, and other-platform testing were not run. CPython probes establish reference behavior, not execution of the patched RustPython interpreter.
Known limits
The receive methods already had a text-signature mismatch with CPython's keyword support. Their representation now becomes generic
(*args, **kwargs); this patch does not repair introspection metadata. Writable-buffer error wording remains that of the shared buffer helper rather than claiming exact CPython wording.The zero-byte results above were observed on Linux. On non-poll platforms CPython checks high-descriptor selectability before returning zero, so these observations do not establish blanket cross-platform equivalence.
Independent source review passed with no blocker.
Integration note
#9651 changes
ArgSpec::parse_withfromFntoFnMut. This change exposes that existing helper and deliberately does not duplicate #9651's callback change. There is one adjacent-line textual conflict: preservepub fn parse_withfrom this change andmut check: impl FnMutfrom #9651. The receive parser remains compatible with either callback signature.AI assistance
The source investigation, patch, reference probes, and this draft were prepared with OpenAI Codex assistance under the maintainer's direction. Human review is requested before merge.