Commit Graph

95 Commits

Author SHA1 Message Date
Jeong, YunWon
2bb9173caf Suspend Python threads before fork() (#7364)
* Suspend Python threads before fork()

Add stop-the-world thread suspension around fork() to prevent
deadlocks from locks held by dead parent threads in the child.

- Thread states: DETACHED / ATTACHED / SUSPENDED with atomic CAS
  transitions matching _PyThreadState_{Attach,Detach,Suspend}
- stop_the_world / start_the_world: park all non-requester threads
  before fork, resume after (parent) or reset (child)
- allow_threads (Py_BEGIN/END_ALLOW_THREADS): detach around blocking
  syscalls (os.read/write, waitpid, Lock.acquire, time.sleep) so
  stop_the_world can force-park via CAS
- Acquire/release import lock around fork lifecycle
- zero_reinit_after_fork: generic lock reset for parking_lot types
- gc_clear_raw: detach dict instead of clearing entries
- Lock-free double-check for descriptor cache reads (no read-side
  seqlock); write-side seqlock retained for writer serialization
- fork() returns PyResult, checks PythonFinalizationError, calls
  sys.audit
2026-03-07 20:20:16 +09:00
Jeong, YunWon
c98215ab3a Clear frame locals and stack on generator close + Add dir_fd support for rmdir, remove/unlink, scandir (#7222)
* Clear frame locals and stack on generator close

Add Frame::clear_locals_and_stack() to release references held by
closed generators/coroutines, matching _PyFrame_ClearLocals behavior.
Call it from Coro::close() after marking the coroutine as closed.

Update test_generators.py expectedFailure markers accordingly.

* Add dir_fd support for rmdir, remove/unlink, scandir

- rmdir: use unlinkat(fd, path, AT_REMOVEDIR) when dir_fd given
- remove/unlink: use unlinkat(fd, path, 0) when dir_fd given
- scandir: accept fd via fdopendir, add ScandirIteratorFd
- listdir: rewrite fd path to use raw readdir instead of nix::dir::Dir
- DirEntry: add d_type and dir_fd fields for fd-based scandir
- Update supports_fd/supports_dir_fd entries accordingly

* cells_free
2026-02-27 01:58:33 +09:00
Jeong, YunWon
c045593e4e impl more nt (#6984)
* mpl new features

* windows encodings

* impl nt functions

* revert

* codecs

* fix codecs
2026-02-04 09:53:02 +09:00
Jeong, YunWon
c0f3a09c2b more windows impl 2026-02-03 22:10:31 +09:00
Jeong, YunWon
cb2be65a8b fix timeout 2026-02-03 22:10:31 +09:00
CPython Developers
dd6e947122 Update os from v3.14.2 2026-02-03 22:10:31 +09:00
Jeong, YunWon
1132f66325 Set closefd=false for stdio file objects in VM init
- Prevent closing underlying fd when stdio wrappers are dropped
- Remove expectedFailure from test_fdopen in test_os.py
2026-02-02 01:57:03 +09:00
Jeong, YunWon
fcca0feb70 Add missing windows APIs 2026-01-29 16:48:33 +09:00
Jeong, YunWon
7ebb0f0c5c impl path_converter and os functions (#6484)
* os.setpgrp

* tcgetpgrp

* impl more os functions

* impl PathConverter
2025-12-25 09:21:09 +09:00
Jeong YunWon
4a352344b6 mark failing test_ctypes 2025-12-24 00:13:30 +09:00
Jeong, YunWon
df523cb58c skip spawnve on windows 2025-12-23 15:01:40 +09:00
Jeong, YunWon
3438fb2850 nt junction (#6407)
* pylib strip path

* nt._path_* functions,

* nt junction
2025-12-12 09:03:19 +09:00
Jeong, YunWon
f379ea8327 winapi._findfirstfile,nt.chmod (#6401) 2025-12-12 00:18:02 +09:00
Jeong, YunWon
1b17587585 __slots__ xor __dict__ , name mangling (#6392)
* __slots__ xor __dict__

* mangle_name for `__` prefixed members
2025-12-10 23:30:10 +09:00
Jeong, YunWon
14232ad0d2 new_last_{os,errno}_error (#6381)
* new_last_{os,errno}_error

* Remove os::errno_err

* enable ssl multithread test
2025-12-10 09:12:38 +09:00
Jeong, YunWon
a99164fd7b nt is_dir,is_file,listmount,listvolume (#6373)
* is_dir/is_file for windows

* listmount/listvolume

* check_env_var_len
2025-12-09 20:08:16 +09:00
Jeong, YunWon
7a5d81a469 Fix os.utime for windows/macos (#6354) 2025-12-09 06:07:48 +09:00
Jeong, YunWon
bb4e30a6df fspath try from (#6359) 2025-12-09 05:44:21 +09:00
Jeong, YunWon
bafaa1a826 scandir/lstat (#6357) 2025-12-09 04:32:06 +09:00
Jeong, YunWon
a484ba4790 st_file_attributes (#6353) 2025-12-09 02:49:36 +09:00
Jeong, YunWon
abc5c223a6 os.waitstatus_to_exitcode for windows (#6355) 2025-12-09 02:46:05 +09:00
Jeong, YunWon
42d0a583e8 fix remove 2025-12-09 02:43:58 +09:00
Jeong, YunWon
bf565e917a Windows execv, spawnv, wait (#6350)
* more const

* wait

* exec

* mkdir
2025-12-09 00:37:52 +09:00
Jeong, YunWon
4592787946 get_inheritable, dup for windows (#6343) 2025-12-08 23:55:03 +09:00
Shahar Naveh
f429ac4939 Use ast.unparse for generating patches with lib_updater.py (#6142)
* Use `ast.unparse` for decorator generation and every ut_method

* Ensure ut_method type for external patches

* use textwrap

* Apply patches to `test_os.py`

* Apoly on `test_xml_etree.py`

* Run on some test files

* Update `test_str.py`

* Update `test_logging.py` from 3.13.7
2025-09-11 22:42:19 +09:00
Shahar Naveh
c5c2bd050d Add tool for easier test updates (#6089)
* Add scripts/lib_updater.py

* Update `Lib/test/test_os.py` with tool

* Update `test_list.py` as well
2025-09-07 16:05:54 +09:00
Shahar Naveh
133aada0b7 Update os.py from 3.13.5 (#6076)
* Update `os.py` from 3.13.5

* Set availablity of some `os` functions

* revert some cfg

* Mark more failing tests
2025-08-08 14:37:35 +09:00
Ashwin Naren
4094c5bfc9 minor mark 2025-04-14 16:54:06 +09:00
Jeong YunWon
43e20a8cd9 Fix os.putenv & test_os.test_envronb 2024-07-28 16:24:17 +09:00
Jeong YunWon
85fa157d5a Update test_os from CPython v3.12.3 2024-05-09 11:51:05 +09:00
CPython Developers
a5f8d42d34 Update os from CPython 3.12.2 2024-04-23 12:56:32 +09:00
Daniel Chiquito
e6c73883ea Revert test skip 2024-03-21 13:36:28 -04:00
Daniel Chiquito
e315077630 Add TODO: RUSTPYTHON to skip reason 2024-03-21 11:31:03 -04:00
Daniel Chiquito
ac78517044 Skip TestScander.test_uninstantiable (#5204)
This test was marked as an expected failure. Because the garbage
collector is missing, that meant that the `os.scandir` object went
unclosed. This object was squatting on the file descriptors of all the
files contained in the test directory, which was breaking test_zipfile.
2024-03-21 14:44:03 +09:00
deantvv
6917b4c2ca os: ns_to_sec rounding (#5150)
In cpython, they use `_PyTime_ROUND_FLOOR` to read time.
But in RustPython, we use `[Duration::from_secs_f64](https://doc.rust-lang.org/std/time/struct.Duration.html#method.try_from_secs_f64)` to read time.

Therefore, RustPython isn't affected by the rounding issue in the way
that cpython does. We can safely ignore the `0.5*1e-9` bit in
`ns_to_sec` function.
2024-01-23 20:09:22 +09:00
Ankit Kumar Pandey
058f8c5500 Add fork support functions (#4972) 2023-06-01 15:29:16 +09:00
Ankit Kumar Pandey
322aa6887a add support for os.fork and related functions (#4877) 2023-04-25 02:39:54 +09:00
Dmitry Erlikh
a354f7bba1 Properly handle failing test_os tests on windows (#4764) 2023-04-20 14:42:16 +09:00
CPython Developers
a14593721f Update test_os from CPython 3.10.6 2022-08-15 02:36:46 +09:00
Jeong YunWon
eb0a892cc5 Use stable rust again 2022-08-14 22:08:45 +09:00
Dean Li
25a6b2b7c4 test: update test_os.py to 3.10 2022-04-18 22:58:00 +08:00
Dean Li
29c953d9a6 test: update test.support and test_io to 3.10
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`.
2022-04-18 22:50:55 +08: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
2df64f081f os: implement device_encoding 2022-02-08 07:47:57 +08:00
Dean Li
b95b580a65 test: mark os success tests 2022-01-22 22:20:04 +08:00
Dean Li
6f98288e84 test: use import_helper 2021-11-29 21:03:02 +08:00
Dean Li
5ee4fb899b test: use os_helper 2021-11-28 20:51:32 +08:00
Dean Li
39b9e1f91e test: os 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