* Preserve imaginary zero signs when adding real values to complex numbers
* Refactor complex_add with match expression
* Correct complex real subtract op
* Remove unnecessary vm arugment
* rewrite finalize_modules with phased algorithm
Replace the absence of module finalization during interpreter shutdown
with a 5-phase algorithm matching pylifecycle.c finalize_modules():
1. Set special sys attributes to None, restore stdio
2. Set all sys.modules values to None, collect module dicts
3. Clear sys.modules dict
4. Clear module dicts in reverse import order (2-pass _PyModule_ClearDict)
5. Clear sys and builtins dicts last
This ensures __del__ methods are called during shutdown and modules are
cleaned up in reverse import order without hardcoded module names.
* dealloc the rigth way
* fix finalize_modules: only clear __main__ dict, mark daemon thread tests as expected failure
Without GC, clearing all module dicts during finalization causes __del__
handlers to fail (globals are None). Restrict Phase 4 to only clear
__main__ dict — other modules' globals stay intact for their __del__
handlers.
Mark test_daemon_threads_shutdown_{stdout,stderr}_deadlock as expected
failures — without GC+GIL, finalize_modules clears __main__ globals
while daemon threads are still running.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
* add __basicsize__ getter
* modify best_base function to get proper base
* inherit basicsize from the base type
---------
Signed-off-by: snowapril <sinjihng@gmail.com>
* compile accepts memoryview now
* Update test_compile to what it is in CPython3.12
* compile optimize flag
* added undocumented flags to flag validator
Initially this is only meant to be a small update for `test_io.py`.
But it turns out that `test.support` need a lot of cleanup especially
for `test.support.warnings_helper`.
The remaining failures are due to what appears to be a fundamental
difference between how RustPython and CPython handle surrogate
characters/codepoints-which-aren't-characters. They are wrapped with
`self.assertRaises(AssertionError)` so we will notice once they start
passing.
https://github.com/RustPython/RustPython/issues/935 is most likely
related.