mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-29 03:04:38 +08:00
* Align weak-reference collection with Python 3.15 finalization Trace and retain owned callback edges independently of weak referent links. Clear callback-bearing weakrefs before finalizers, suppress callbacks from unreachable weakrefs, and close remaining weakref ingress after resurrection checks while the world is stopped. Publish and unlink intrusive nodes safely. Refresh weakref and canonical weakref/GC/finalization tests through update_lib from pinned CPython 3.15.0. Retire four obsolete guards only after fresh body passes, retaining applicable RustPython limitations. Assisted-by: OpenAI Codex:model version unavailable * Refresh canonical IO tests for weakref finalization Migrate the complete CPython 3.15.0 test_io package at d220409 with the fail-closed legacy-map updater, preserving all ten existing guards. Retire the seven consolidated standalone suites and update io/file dependency paths with mapping regression tests. The canonical GC tests ignore ResourceWarning without retaining its source, so callback-free weakrefs correctly reflect surviving owners. This closes the stale test dependency exposed by the lifecycle change. Assisted-by: OpenAI Codex:model version unavailable * Protect weakref callbacks with the original referent stripe Follow CPython's free-threading weakref locking model instead of keeping an independent callback RwLock. Retain the original referent stripe key so callback access stays synchronized after GC clears the referent. Unlink and steal callbacks under that stripe, then release ownership outside the lock. Preserve synchronization for running-world GC paths and gc.get_referents while keeping ordinary weakref upgrades unchanged. Assisted-by: OpenAI Codex:model version unavailable * Defer weakref GC tracking until referent publication Keep freshly allocated weakrefs out of GC's object lists until they are linked and their referent is published. Release the referent stripe before tracking, since tracking can collect and invoke finalizers. Generic reuse losers remain untracked. Exercise the allocator boundary directly for reference, proxy, callable proxy and subclass payloads, and ensure completed constructors track their objects. This prevents observers from retaining a half-built dead weakref that later becomes live. Assisted-by: OpenAI Codex:model version unavailable * Retain the original weakref stripe lock like CPython Store a safe handle to the selected static weakref stripe instead of retaining and rehashing the referent address. Keep the same lock after referent clearing, matching CPython free-threaded weakrefs_lock. The nonthreaded handle is zero-sized and introduces no locking. Preserve lock selection, acquire/release ordering, fork reset, deferred GC publication, and callback-owner release outside the stripe. No new locks or unsafe code are needed. Assisted-by: OpenAI Codex:model version unavailable
29 lines
1.1 KiB
Python
Vendored
29 lines
1.1 KiB
Python
Vendored
"""Tests for the io module and its implementations (_io and _pyio)
|
|
|
|
Tests are split across multiple files to increase
|
|
parallelism and focus on specific implementation pieces.
|
|
|
|
* test_io
|
|
* test_bufferedio - tests file buffering
|
|
* test_memoryio - tests BytesIO and StringIO
|
|
* test_fileio - tests FileIO
|
|
* test_file - tests the file interface
|
|
* test_general - tests everything else in the io module
|
|
* test_univnewlines - tests universal newline support
|
|
* test_largefile - tests operations on a file greater than 2**32 bytes
|
|
(only enabled with -ulargefile)
|
|
* test_free_threading/test_io - tests thread safety of io objects
|
|
|
|
.. attention::
|
|
When writing tests for io, it's important to test both the C and Python
|
|
implementations. This is usually done by writing a base test that refers to
|
|
the type it is testing as an attribute. Then it provides custom subclasses to
|
|
test both implementations. This directory contains lots of examples.
|
|
"""
|
|
|
|
import os
|
|
from test.support import load_package_tests
|
|
|
|
def load_tests(*args):
|
|
return load_package_tests(os.path.dirname(__file__), *args)
|