45 Commits
Author SHA1 Message Date
youknowdot fd5b30eb5e Align socket and socketserver with Python 3.15 (#9156)
Import the canonical socket libraries and tests through update_lib, preserving the existing AF_ALG expected failures. Match setsockopt index/buffer conversion and error ordering, mask optlen with the final CPython deprecation warning, reject oversized Windows buffers before the host call, and preserve arbitrary-precision getaddrinfo ports and empty canonical names.

Assisted-by: OpenAI Codex:model version unavailable
2026-10-16 10:14:55 +09:00
Jeong, YunWonandLee Dogeon afad92bf1b Add OrderedDict, marshal, inspect, and chflags bitflagset (#8780)
* Implement _collections.OrderedDict

Extracted from #6799: native OrderedDict as a dict subclass,
iterator mutation tracking, and mapping-view set operations.

* Add OrderedDict, warnings source lines, and socket sendmsg

Implement _collections.OrderedDict as a dict subclass with a
linked list of insertion-order nodes.

Pack struct F/D as native float/double complex pairs, and report
unexpected __replace__ field names as a list repr.

Register encodings.latin_1 at startup. Reject NUL in input()
prompts. Copy non-exact type dicts in mapping order.

Fetch warning source lines through _bless_my_loader and unicode
splitlines. Keep the last warnings.filters list after deletion.

Snapshot sendmsg sequences before converting buffers, parse
ancillary ints with __index__, and dispatch AF_CAN by protocol.

Store sys.trace and sys.profile on each ThreadSlot so
_settraceallthreads/_setprofileallthreads are visible to
sys.gettrace/getprofile on other threads.

Use <frozen importlib._bootstrap> as frozen importlib
co_filename. Keep HEAPTYPE socket objects GC-tracked.

Assisted-by: Grok:grok-4.6

* Load marshal via readinto and dump sets in dumps order

marshal.load fills a scratch buffer with readinto on a
contiguous writable memoryview, and rejects a returned length
other than the requested size.

set and frozenset dumps write elements in sorted(v,
key=marshal.dumps) order.

Assisted-by: Grok:grok-4.6

* Add classmethod_descriptor and ABC IS_ABSTRACT flags

Give METH_CLASS methods a distinct classmethod_descriptor type.
Store Py_TPFLAGS_IS_ABSTRACT from __abstractmethods__ and look
up that attribute only in the type's own dict.

Expose defaultdict.default_factory as a member descriptor.
Inherit bool's unused number slots from int. Mark set and
frozenset __contains__ as METH_COEXIST.

Parse classmethod, staticmethod, object.__new__, and heap type
text signatures. Register interactive source in linecache.

Assisted-by: Grok:grok-4.6

* address review: odict reuse, descr call, new wrapper

Reuse odict node slots and walk the live list in next_after.
Require both | operands to be dicts. Drop the odict iterator
on GC clear. Bind classmethod descriptors through descr_get
and update IS_ABSTRACT under the type lock. Give odict keys
and items sq_contains. Walk tp_new_wrapper past new_wrapper
so HEAPTYPE socket subclasses can call socket.__new__.
Split FreeBSD Bluetooth protocol constants from Linux values.

Assisted-by: Grok:grok-4.6

* Represent chflags bits with bitflagset

Assisted-by: Grok:grok-4.6

* Represent access and mode bits with bitflagset

Assisted-by: Grok:grok-4.6

* Continue unfinished REPL suites as incomplete input

Assisted-by: Grok:grok-4.6

* Add pickle and os.stat inspect signatures

Give _pickle.Pickler the clinic constructor text signature and
accept fix_imports and buffer_callback as positional-or-keyword.
Allow #[pyfunction(text_signature)] and use it so os.stat reports
(path, *, dir_fd=None, follow_symlinks=True). Uncomment import
_pickle and drop the pickle inspect expectedFailures.

Assisted-by: Grok:grok-4.6

* Add Unpickler, dump/load, and lstat signatures

Give _pickle Unpickler, dump, dumps, load, and loads clinic
text signatures, and os.lstat (path, *, dir_fd=None).

Assisted-by: Grok:grok-4.6

* Complete OrderedDict with insertion-order links

Move the native OrderedDict into ordered_dict.rs and track order
with a linked list of nodes, keeping mapping-view set operations.

Assisted-by: Grok:grok-4.6

* address CI: stat casts, HCI_DATA_DIR, passing xfails

Compare stat permission bits as Mode so Linux clippy does not
flag a u32-to-u32 cast. Export HCI_DATA_DIR with the Bluetooth
socket option values. Drop expectedFailure from tests that now
pass.

Assisted-by: Grok:grok-4.6

* Fix wasm teardown deadlock and bluetooth constants

Assisted-by: Grok:grok-4.6

* Clear process-wide eval breaker bits in STW test

Assisted-by: Grok:grok-4.6

* Drop exclusive-held panic that tripped wasm clippy

Assisted-by: Grok:grok-4.6

* Fix OrderedDict contains and export Windows BDADDR

Assisted-by: Grok:grok-4.6

* Add cmp_to_key and hash-once LRU cache

_functools.cmp_to_key now returns KeyWrapper. LRU lookups store the
key hash on _lru_list_elem so __hash__ is not called again on hits
or eviction.

Assisted-by: Grok:grok-4.6

* Allow subclass keywords on list, tuple, and float

list.__init__ rejects keywords only when tp_new is still list's.
tuple/float.__new__ reject them only when tp_init is still the base's.

Assisted-by: Grok:grok-4.6

* Fix CI lint, test re-export, and structseq members

Drop the duplicate clear_eval_breaker_for_test re-export.
Format structseq imports. Expose struct sequence fields as
readonly members so assignment raises "readonly attribute".

Assisted-by: Grok:grok-4.6

* Allow subclass keywords on itertools and filter

Positional-only constructors ignore extra keywords when a subclass
has replaced tp_init, matching list/tuple/float.

Assisted-by: Grok:grok-4.6

* Remove text_signature derive parameter

Drop the string override on #[pyfunction] and #[pyclass]. Signatures
are generated from the Rust parameter list only. Restore inspect
expectedFailures that depended on the override.

Assisted-by: Grok:grok-4.6

* Rename set contains_method to __contains__

Keep a borrowed contains helper for slots and C-API. The coexist
pymethod is named __contains__.

Assisted-by: Grok:grok-4.6

* Use MonitoringEvent instead of EVENT_* aliases

Drop the unused MonitoringEvents bitflags and the EVENT_PY_START
style mask constants. Call sites use the enum and .mask().

Assisted-by: Grok:grok-4.6

* Store warnings filters as PyListRef

The list already serializes its elements. Drop the extra mutex around
the cached list pointer.

Assisted-by: Grok:grok-4.6

* Re-export clear_eval_breaker_for_test after rebase

Keep the STW test helper visible without bringing back stop_bit_set.

Assisted-by: Grok:grok-4.6

* Fix groupby reentrancy and islice arguments

Give _grouper its own tgtkey and take currvalue after the key
comparison. Accept __index__ on islice bounds, reject step 0, and
drain the source up to stop.

Assisted-by: Grok:grok-4.6

* SETREF warnings filters, onceregistry, and defaultaction

Keep the last list, dict, or str after the module attributes are
deleted by swapping the interpreter cache pointer. Do not store a
None fallback for _warnings_context.

Assisted-by: Grok:grok-4.6

* Iterate OrderedDict inner dict via next_entry

&PyDict is not an iterator after the borrowed-ref signature change.

Assisted-by: Grok:grok-4.6

* Remove expectedFailure from testBluetoothConstants

Linux now exports BTPROTO_HCI and the rest of the set.

Assisted-by: Grok:grok-4.6

* Borrow get_filter arguments as PyObject

Match the warn_explicit call site that passes borrowed
handles after the internal-helper borrow change.

Assisted-by: Grok:grok-4.6

* Fix bool slots and SemHandle safety docs

Leave unused bool number slots unset so inspect reports
__add__ on int. Document SemHandle::from_raw safety.

Assisted-by: Grok:grok-4.6

* Keep sendmsg errors and drop duplicate linecache

Replace sendmsg iterable TypeError only. Register REPL
source in linecache once per compiled input.

Assisted-by: Grok:grok-4.6

* Nest REPL parse or-patterns for clippy

Assisted-by: Grok:grok-4.6

* Mark pydoc os.stat signature test expectedFailure

Assisted-by: Grok:grok-4.6

---------

Co-authored-by: Lee Dogeon <dev.moreal@gmail.com>
2026-09-24 12:21:26 +09:00
Jeong, YunWon 05f1386fca host_env: publish remaining Windows socket constants (#8792)
* host_env: publish remaining Windows socket constants

Windows SOMAXCONN follows winsock2.h (0x7fffffff), not the Winsock 1.1
value windows-sys still exports. The socket module takes the signed
INADDR group constants and the other Winsock names host_env already
defines.

Assisted-by: Grok

* test_socket: expect Bluetooth constants to pass on Windows

The Windows names this test reads are published now, so the blanket
expectedFailure is an unexpected success there. Other platforms still
miss BTPROTO_HCI and the rest of the non-Windows set.

Assisted-by: Grok
2026-09-23 18:28:08 +09:00
Jeong, YunWon 8fda0eccee Fix fork-child SIGSEGV and yield-from throw() args (#8759)
* Unskip passing flaky CPython tests

Remove RUSTPYTHON skip overlays after Linux release repeats passed
for enum, threading, logging, subprocess, socket, int, re, strtod,
and regrtest cases.

Assisted-by: Grok:4.6

* Fix fork-child SIGSEGV and yield-from throw args

Forget JoinHandle of threads that did not survive fork instead
of dropping them. Zero-reinit the import lock and condvars in
the child rather than unlock/notify. Resume the world if
os.fork() fails.

Call a yield-from subiterator throw() without None fillers so
a 1-arg throw stays 1-arg.

Drop the stale Windows expectedFailure on logging queue config
and unskip test_reinit_tls_after_fork plus the asyncio
local_addr family test.

Assisted-by: Grok:4.6

* Restore import lock depth after fork; add WASI clock info

Zeroing IMP_LOCK in the child discarded its recursion count, so
imp.release_lock() raised and test_fork1 exited 1. Re-acquire the
saved depth, then drop the extra pre-fork hold.

Expose time.get_clock_info on WASI via clock_getres so test_int
Stopwatch can run.

Unskip lock_tests test_acquire_contended and test_thread_leak.

Assisted-by: Grok:4.6

* Honor chmod follow_symlinks=False via fchmodat

Linux chmod followed the symlink, so dangling links raised
FileNotFoundError instead of NotImplementedError. Use fchmodat
with AT_SYMLINK_NOFOLLOW and map ENOTSUP to NotImplementedError.

Unskip httpservers truncated Content-Length (CPython already
skips as root) and tempfile symlink-mode cleanup on Linux.

Assisted-by: Grok:4.6

* Unskip httplib local bad-hostname HTTPS test

The skip was leftover. With default ssl-rustls the test passes
under -W error on Linux.

Assisted-by: Grok:4.6

* Fix list cmp deadlock, wasm digit overflow, REPL prompt

Do not hold list/deque locks across item comparison callbacks.
Compute int-to-str digit bounds in u64 so the check cannot wrap
on wasm32. Snapshot set contents when list.extend copies a set.

For a non-TTY stdin, write the REPL prompt to stderr and read
lines from stdin. Flush stdout/stderr after each interactive
command. Set sys.ps1/ps2 to ">>> " and "... ".

Unskip list mutation compares, asyncio all_tasks race, importlib
deadlock/parallel/circular-import tests, and REPL stdout flush.

Assisted-by: Grok:4.6

* Avoid unnecessary u64 cast in int-to-str digit check

bits() is already u64, so `bits as u64` fails clippy
unnecessary_cast under -Dwarnings.

Assisted-by: Grok:4.6
2026-09-21 20:53:53 +09:00
Shahar Naveh a6d88b144e Update some libs and tests to 3.14.7 (#8593)
* test_weakref

* test_inspect

* socket

* test_copy

* pickle

* test_ast

* string

* zstd

* test_py_compile

* test_os

* mark failing test

* mark failing

* fix markers
2026-08-25 22:01:24 +09:00
Jeaeun Kim 8376a03366 Match CPython unsigned socket conversion errors (#8257)
Assisted-by: Codex:gpt-5.4
2026-07-15 23:16:42 +09:00
Shahar Naveh fcfb47d11b Update socket.py to 3.14.5 (#7866)
* Update `socket.py` to 3.14.5

* Don't have socket.sethostname on android

* Mark failing test
2026-05-13 19:52:56 +09:00
Jeong, YunWon 7aa38ebe9f Implement Windows SemLock in _multiprocessing module (#7199)
* Implement Windows SemLock in _multiprocessing module

Add SemLock class using Windows semaphore APIs (CreateSemaphoreW,
WaitForSingleObjectEx, ReleaseSemaphore) so test_multiprocessing
suites are no longer skipped with "lacks a functioning sem_open".
Also add sem_unlink as no-op and flags dict for Windows.

* Fix _multiprocessing recv to return bytes and improve SemLock reliability

- recv() now returns bytes instead of int (matching CPython)
- Remove spurious GetLastError() check after CreateSemaphoreW
- Add signal checking during blocking SemLock acquire

* Include winerror in OSError.__reduce__ on Windows

* Remove expectedFailure for tests now passing with Windows SemLock

* Fix OSError.__reduce__ to preserve winerror when filename is None

When filename is None, __reduce__ was reconstructing a 2-element
(errno, msg) tuple, dropping the winerror at position 3 in the
original args. Use the original args tuple instead, matching CPython.

* Validate maxvalue > 0 in SemLock and document winerror __reduce__ divergence

* Reject embedded null characters in mmap tagname and _winapi file mapping names
2026-02-24 10:12:29 +09:00
Padraic Fanning c0ef48111b Mark erroring tests 2026-02-01 20:27:22 -05:00
CPython Developers 65d178a4f5 Update socket from v3.14.2-288-g06f9c8ca1c 2026-02-01 20:23:50 -05:00
Terry Tianlin LuanandJeong, YunWon 609dbb1439 Downgraded skips in tests (#6716)
* Downgraded skips in tests

* Fixed failing tests

* Fixed test_ftplib + test_socket + test_ssl + test_threaded_import failures

* Removed comments about which tests are run in which environment

* Addressed PR comments

* Annotated skips on failing tests

* Removed unneeded tests

* Removed unneeded sys import from test_ftplib

* Added annotation to test_ftplib

* Readded skipIf to test_cleanup_with_symlink_modes with a more general ENV_POLLUTING_TESTS_WINDOWS

* Addressed PR comments

* Made changes to minimize diff in PR

* Apply suggestion from @youknowone

---------

Co-authored-by: Jeong, YunWon <69878+youknowone@users.noreply.github.com>
2026-01-15 21:43:22 +09:00
Jeong, YunWon 39aa6f9524 use accept_raw (#6578) 2025-12-29 23:17:16 +09:00
Jeong YunWon ed62c8ef58 mark failures 2025-12-29 11:27:08 +09:00
Jeong, YunWon 183cebe8a1 Upgrade socket from 3.13.11 2025-12-29 11:27:08 +09:00
Jeong YunWon 2271f74642 del for socket 2025-12-29 11:25:34 +09:00
Jeong, YunWon 012799f560 Fix enum and os.read related to signal (#6552)
* fix enum

* fix os.read to check signals
2025-12-28 10:13:03 +09:00
Jeong, YunWon 79cd048e1f native ExceptionGroup (#6358) 2025-12-09 23:02:44 +09:00
Jeong YunWon 9e2f6bd187 mark failing tests of test_socket 2025-03-30 14:20:17 +09:00
Jeong YunWon b620f03728 Update socket from CPython 3.12.2 2025-03-30 13:55:55 +09:00
Noa a86126419c Fix remaining tests 2025-03-25 19:05:12 -05:00
Noa 5c22697344 Implement fsencode/fsdecode for FsPath 2025-03-25 19:05:12 -05:00
Jeong YunWon 1cec856c63 skip flaky test_socket sendmsg tests in macos 2024-04-25 22:04:40 +09:00
Jeong YunWon 5fd5939395 skip flaky socket test in macOS 2024-04-23 16:24:15 +09:00
Daniel Chiquito de7e4e49da Disable broken test_socket.py tests
There are a substantial number of socket tests that are disabled due to
`bind(): bad family` errors. It seems like RustPython only supports a
small subset of the required connection families, so the failing tests
are broken for the same reasons.
2024-03-09 18:22:57 -05:00
dvermd 0d0139b322 Update enum to CPython 3.11.5 (#5074)
part of: #4564
2023-10-03 22:32:38 +09:00
Jeong YunWon dfb37d9a44 setattro uses Py<PyStr> 2023-03-20 19:00:02 +09:00
Jeong YunWon 367a948ff0 Adapt unittest.expectedFailureIf 2023-03-02 04:41:15 +09:00
Jeong YunWon 19504a6b9d mark failing tests again 2022-08-15 01:08:58 +09:00
CPython Developers 939257411b Update socket{server} from CPython 3.10.6 2022-08-15 00:34:06 +09:00
Padraic Fanning 0b1a54220e Unmark passing test on macOS and Windows 2022-07-04 20:52:03 -04:00
Padraic Fanning b39263db3b Mark erroring test on Windows 2022-07-04 20:50:03 -04:00
Padraic Fanning 92f790efc1 Mark erroring/failing tests 2022-07-04 20:18:56 -04:00
Padraic Fanning 165df16945 Unmark passing tests due to CI limitations 2022-06-22 20:19:39 -04:00
Padraic Fanning c8748bc98e Fix test.support imports 2022-02-13 17:56:08 -05:00
Padraic Fanning 75390dd787 Fix test.support imports 2022-02-12 20:48:57 -05:00
Dean Li 5ee4fb899b test: use os_helper 2021-11-28 20:51:32 +08:00
Jeong YunWon 913b78ca44 Revert "Merge pull request #3433 from deantvv/test-update"
This reverts commit 9fa5c5ac66, reversing
changes made to e7fa32c687.
2021-11-17 17:06:51 +09:00
Dean Li 49a5805d11 test: use os_helper 2021-11-13 02:18:33 +00:00
Padraic Fanning bd9aa2f938 Fix CI failures for macOS in test_socket 2021-10-17 19:01:37 -04:00
Padraic Fanning 9c219e3836 Clean up skip in test_socket 2021-10-17 19:01:36 -04:00
Lee Dogeon 63b1696458 Derive name from tp_name 2021-09-09 00:07:36 +09:00
Dean Li 06b40b3602 socket: impl herror
There is one todo that is waiting for hstrerror to land in libc crate.
For now it shows the same error as cpython when hstrerror is not
available.
2021-08-07 15:26:09 +08:00
coolreader18 a2fc8796e8 Fix windows tests 2021-06-11 16:15:33 -05:00
Noah 74f9722033 Mark failing tests 2021-06-10 20:54:49 -05:00
Noah b69c14c2a6 Add test_socket.py from CPython 3.8 2021-06-10 20:54:49 -05:00