summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_os.py
Commit message (Collapse)AuthorAgeFilesLines
* [3.12] GH-89727: Fix FD leak on `os.fwalk()` generator finalization. ↵Miss Islington (bot)2024-05-301-0/+21
| | | | | | | | | | | (GH-119766) (#119768) GH-89727: Fix FD leak on `os.fwalk()` generator finalization. (GH-119766) Follow-up to 3c890b50. Ensure we `os.close()` open file descriptors when the `os.fwalk()` generator is finalized. (cherry picked from commit a5fef800d31648d19cecc240a2fa0dc71371753e) Co-authored-by: Barney Gale <barney.gale@gmail.com>
* [3.12] GH-89727: Fix `os.fwalk()` recursion error on deep trees (GH-119638) ↵Miss Islington (bot)2024-05-301-2/+0
| | | | | | | | | | | (#119765) GH-89727: Fix `os.fwalk()` recursion error on deep trees (GH-119638) Implement `os.fwalk()` using a list as a stack to avoid emitting recursion errors on deeply nested trees. (cherry picked from commit 3c890b503c740767d0eb9a0e74b47f17a1e69452) Co-authored-by: Barney Gale <barney.gale@gmail.com>
* gh-118486: Simplify test_win32_mkdir_700 to check the exact ACL (GH-119056)Miss Islington (bot)2024-05-151-15/+8
| | | | | (cherry picked from commit 94591dca510c796c7d40e9b4167ea56f2fdf28ca) Co-authored-by: Steve Dower <steve.dower@python.org>
* gh-118486: Support mkdir(mode=0o700) on Windows (GH-118488)Steve Dower2024-05-091-0/+19
|
* gh-118802: Fix ACL use in test for non-English Windows (GH-118831)Miss Islington (bot)2024-05-091-3/+2
| | | | | (cherry picked from commit 82acc5f2113bffd0ed902851f4ccf5b9be8980b2) Co-authored-by: Steve Dower <steve.dower@python.org>
* [3.12] gh-113964: Don't prevent new threads until all non-daemon threads ↵Sam Gross2024-03-191-8/+9
| | | | | | | | | | | | | | exit (GH-116677) (#117029) Starting in Python 3.12, we prevented calling fork() and starting new threads during interpreter finalization (shutdown). This has led to a number of regressions and flaky tests. We should not prevent starting new threads (or `fork()`) until all non-daemon threads exit and finalization starts in earnest. This changes the checks to use `_PyInterpreterState_GetFinalizing(interp)`, which is set immediately before terminating non-daemon threads. (cherry picked from commit 60e105c1c11ecca1680d03c38aa06bcc77a28714)
* [3.12] gh-116401: Fix blocking os.fwalk() and shutil.rmtree() on opening a ↵Serhiy Storchaka2024-03-131-4/+78
| | | | | named pipe (GH-116421) (GH-116716) (cherry picked from commit aa7bcf284f006434b07839d82f325618f7a5c06c)
* gh-114435: Allow test_stat_inaccessible_file() to have matching ino/dev ↵Miss Islington (bot)2024-02-231-4/+3
| | | | | | | | (GH-114571) This may occur if Windows allows reading stat information from a file even if the current user does not have access. (cherry picked from commit d91ddff5de61447844f1dac575d2e670c8d7e26b) Co-authored-by: Steve Dower <steve.dower@python.org>
* [3.12] gh-115596: Fix ProgramPriorityTests in test_os permanently changing ↵Miss Islington (bot)2024-02-171-16/+15
| | | | | | | the process priority (GH-115610) (GH-115616) (cherry picked from commit 90dd653a6122a6c5b4b1fe5abe773c4751e5ca25) Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>
* [3.12] Fix ProgramPriorityTests on FreeBSD with high nice value (GH-100145) ↵Miss Islington (bot)2024-02-171-1/+2
| | | | | | | | | | (GH-115614) It expects priority to be capped with 19, which is the cap for Linux, but for FreeBSD the cap is 20 and the test fails under the similar conditions. Tweak the condition to cover FreeBSD as well. (cherry picked from commit 437924465de5cb81988d1e580797b07090c26a28) Co-authored-by: Dmitry Marakasov <amdmi3@amdmi3.ru>
* gh-111877: Fixes stat() handling for inaccessible files on Windows (GH-113716)Miss Islington (bot)2024-01-121-0/+60
| | | | | (cherry picked from commit ed066481c76c6888ff5709f5b9f93b92c232a4a6) Co-authored-by: Steve Dower <steve.dower@python.org>
* [3.12] gh-113090: Fix test.support.os_support.can_chmod() on Windows ↵Miss Islington (bot)2023-12-141-1/+1
| | | | | | | (GH-113091) (GH-113099) (cherry picked from commit c6e953be125c491226adc1a5bc9c804ce256aa17) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.12] gh-111841: Fix os.putenv() and os.unsetenv() with embedded NUL on ↵Miss Islington (bot)2023-11-111-1/+4
| | | | | | | Windows (GH-111842) (GH-111966) (cherry picked from commit 0b06d2482d77e02c5d40e221f6046c9c355458b2) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.12] gh-109888: Fix test_os _kill_with_event() on Windows (GH-110421) ↵Miss Islington (bot)2023-10-051-23/+27
| | | | | | | | | | | | | | | | | | | | (#110442) gh-109888: Fix test_os _kill_with_event() on Windows (GH-110421) Replace os.kill() with proc.kill() which catchs PermissionError. Rewrite _kill_with_event(): * Use subprocess context manager ("with proc:"). * Use sleeping_retry() to wait until the child process is ready. * Replace SIGINT with proc.kill() on error. * Replace 10 seconds with SHORT_TIMEOUT to wait until the process is ready. * Replace 0.5 seconds with SHORT_TIMEOUT to wait for the process exit. (cherry picked from commit aaf297c048694cd9652790f8b74e69f7ddadfbde) Co-authored-by: Victor Stinner <vstinner@python.org>
* [3.12] gh-109295: Fix test_os.test_access_denied() for TEMP=cwd (GH-109299) ↵Miss Islington (bot)2023-09-121-1/+1
| | | | | | | | | | | | (#109304) gh-109295: Fix test_os.test_access_denied() for TEMP=cwd (GH-109299) Fix test_os.test_access_denied() when the TEMP environment variable is equal to the current working directory. Run the test using a different filename, since self.fname already exists in this case. (cherry picked from commit 7dedfd36dc16d9e1e15d7d0b0a636dd401a5a543) Co-authored-by: Victor Stinner <vstinner@python.org>
* [3.12] gh-104690 Disallow thread creation and fork at interpreter ↵Miss Islington (bot)2023-06-041-0/+16
| | | | | | | | | | | | | | | | | | | | | finalization (GH-104826) (#105277) gh-104690 Disallow thread creation and fork at interpreter finalization (GH-104826) Disallow thread creation and fork at interpreter finalization. in the following functions, check if interpreter is finalizing and raise `RuntimeError` with appropriate message: * `_thread.start_new_thread` and thus `threading` * `posix.fork` * `posix.fork1` * `posix.forkpty` * `_posixsubprocess.fork_exec` when a `preexec_fn=` is supplied. --------- (cherry picked from commit ce558e69d4087dd3653207de78345fbb8a2c7835) Co-authored-by: chgnrdv <52372310+chgnrdv@users.noreply.github.com> Co-authored-by: Gregory P. Smith <greg@krypto.org>
* gh-75729: Fix os.spawn tests not handling spaces on Windows (#99150)C.A.M. Gerlach2023-04-081-45/+57
| | | | | | | | | | | | | * Quote paths in os.spawn tests on Windows so they work with spaces * Add NEWS entry for os spawn test fix * Fix code style to avoid double negative in os.spawn tests Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> --------- Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* gh-99726: Improves correctness of stat results for Windows, and uses faster ↵Steve Dower2023-03-161-1/+11
| | | | | API when available (GH-102149) This deprecates `st_ctime` fields on Windows, with the intent to change them to contain the correct value in 3.14. For now, they should keep returning the creation time as they always have.
* gh-102519: Avoid failing tests due to inaccessible volumes (GH-102706)Steve Dower2023-03-151-6/+11
|
* gh-102519: Add os.listdrives, os.listvolumes and os.listmounts on Windows ↵Steve Dower2023-03-101-0/+43
| | | | (GH-102544)
* gh-102255: Improve build support for Windows API partitions (GH-102256)Max Bachmann2023-03-091-3/+5
| | | | | Add `MS_WINDOWS_DESKTOP`, `MS_WINDOWS_APPS`, `MS_WINDOWS_SYSTEM` and `MS_WINDOWS_GAMES` preprocessor definitions to allow switching off functionality missing from particular API partitions ("partitions" are used in Windows to identify overlapping subsets of APIs). CPython only officially supports `MS_WINDOWS_DESKTOP` and `MS_WINDOWS_SYSTEM` (APPS is included by normal desktop builds, but APPS without DESKTOP is not covered). Other configurations are a convenience for people building their own runtimes. `MS_WINDOWS_GAMES` is for the Xbox subset of the Windows API, which is also available on client OS, but is restricted compared to `MS_WINDOWS_DESKTOP`. These restrictions may change over time, as they relate to the build headers rather than the OS support, and so we assume that Xbox builds will use the latest available version of the GDK.
* gh-102179: Fix `os.dup2` error reporting for negative fds (#102180)Alexey Izbyshev2023-03-041-0/+20
|
* gh-101881: Support (non-)blocking read/write functions on Windows pipes ↵Rayyan Ansari2023-02-161-0/+1
| | | | | | | | | | | | (GH-101882) * fileutils: handle non-blocking pipe IO on Windows Handle erroring operations on non-blocking pipes by reading the _doserrno code. Limit writes on non-blocking pipes that are too large. * Support blocking functions on Windows Use the GetNamedPipeHandleState and SetNamedPipeHandleState Win32 API functions to add support for os.get_blocking and os.set_blocking.
* gh-101196: Make isdir/isfile/exists faster on Windows (GH-101324)Michael Droettboom2023-02-081-0/+2
| | | Co-authored-by: Eryk Sun <eryksun@gmail.com>
* gh-100228: Warn from os.fork() if other threads exist. (#100229)Gregory P. Smith2022-12-291-0/+28
| | | | | Not comprehensive, best effort warning. There are cases when threads exist on some platforms that this code cannot detect. macOS when API permissions allow and Linux with a readable /proc procfs present are the currently supported cases where a warning should show up reliably. Starting with a DeprecationWarning for now, it is less disruptive than something like RuntimeWarning and most likely to only be seen in people's CI tests - a good place to start with this messaging.
* gh-89727: Fix os.walk RecursionError on deep trees (#99803)Jon Burdo2022-12-191-0/+43
| | | | | Use a stack to implement os.walk iteratively instead of recursively to avoid hitting recursion limits on deeply nested trees.
* gh-81057: Move OS-Related Globals to _PyRuntimeState (gh-100082)Eric Snow2022-12-081-6/+7
| | | https://github.com/python/cpython/issues/81057
* gh-99547: Add isjunction methods for checking if a path is a junction (GH-99548)Charles Machalow2022-11-221-0/+17
|
* gh-98393: Update test_os for bytes-like types (#98487)Victor Stinner2022-11-021-34/+12
| | | Address Serhiy Storchaka's review.
* gh-98393: os module reject bytes-like, only accept bytes (#98394)Victor Stinner2022-10-181-20/+12
| | | | | The os module and the PyUnicode_FSDecoder() function no longer accept bytes-like paths, like bytearray and memoryview types: only the exact bytes type is accepted for bytes strings.
* gh-43414: os.get_terminal_size() now uses the actual file descriptor on ↵Raghunandan Bhat2022-07-281-0/+13
| | | | Windows instead of mapping to standard handles (#93203)
* gh-90473: Fix more tests on platforms without umask (GH-95164)Christian Heimes2022-07-231-0/+8
|
* gh-90473: Make chmod a dummy on WASI, skip chmod tests (GH-93534)Christian Heimes2022-06-061-2/+3
| | | WASI does not have the ``chmod(2)`` syscall yet.
* gh-90473: WASI requires proper open(2) flags (GH-93529)Christian Heimes2022-06-061-1/+2
|
* gh-90473: Skip and document more failing tests on WASI (GH-93436)Christian Heimes2022-06-021-1/+7
| | | | | | | - Mark more ``umask()`` cases - ``dup()`` is not supported - ``/dev/null`` is not available - document missing features - mark more modules as not available
* gh-90473: Misc test fixes for WASI (GH-93218)Christian Heimes2022-05-251-0/+2
| | | | | | | | * ``sys.executable`` is not set * WASI does not support subprocess * ``pwd`` module is not available * WASI checks ``open`` syscall flags more strict, needs r, w, rw flag. * ``umask`` is not available * ``/dev/null`` may not be accessible
* gh-90473: Decrease recursion limit and skip tests on WASI (GH-92803)Christian Heimes2022-05-191-2/+7
|
* bpo-46785: Fix race condition between os.stat() and unlink on Windows (GH-31858)Itai Steinherz2022-05-021-0/+44
|
* bpo-40280: Enable most file-at() and nanosleep APIs again (GH-32238)Christian Heimes2022-04-021-1/+9
|
* bpo-47015: Update test_os from asyncore to asyncio (GH-31876)Oleg Iarygin2022-03-201-157/+79
|
* bpo-40280: Skip more tests on Emscripten (GH-31947)Christian Heimes2022-03-171-1/+9
| | | | | | - lchmod, lchown are not fully implemented - skip umask tests - cannot fstat unlinked or renamed files yet - ignore musl libc issues that affect Emscripten
* bpo-40280: Skip more tests/features that don't apply to Emscripten (GH-31791)Christian Heimes2022-03-101-0/+3
| | | | | | | - fd inheritance can't be modified because Emscripten doesn't support subprocesses anyway. - setpriority always fails - geteuid no longer causes problems with latest emsdk - umask is a stub - geteuid / getuid always return 0, but process cannot chown to random uid.
* bpo-40280: Block more non-working syscalls in Emscripten (GH-31757)Christian Heimes2022-03-081-0/+1
| | | | | | | | | - getgroups always fails. - geteuid and getegid always return 0 (root), which confuse tarfile and tests. - hardlinks (link, linkat) always fails. - non-encodable file names are not supported by NODERAWFS layer. - mark more tests with dependency on subprocess and multiprocessing. Mocking does not work if the module fails to import.
* bpo-40280: Address more test failures on Emscripten (GH-31050)Christian Heimes2022-02-051-0/+4
| | | Co-authored-by: Brett Cannon <brett@python.org>
* bpo-40280: Skip subprocess-based tests on wasm32-emscripten (GH-30615)Christian Heimes2022-01-251-0/+8
|
* bpo-46426: Improve tests for the dir_fd argument (GH-30668)Serhiy Storchaka2022-01-211-8/+2
| | | | | | | Ensure that directory file descriptors refer to directories different from the current directory, and that src_dir_fd and dst_dir_fd refer to different directories. Add context manager open_dir_fd() in test.support.os_helper.
* Revert "bpo-28533: Remove asyncore, asynchat, smtpd modules (GH-29521)" ↵Victor Stinner2021-12-071-2/+5
| | | | | (GH-29951) This reverts commit 9bf2cbc4c498812e14f20d86acb61c53928a5a57.
* bpo-42540: reallocation of id_mutex should not force default allocator ↵Sam Gross2021-11-171-0/+16
| | | | | | | (GH-29564) Unlike the other locks reinitialized by _PyRuntimeState_ReInitThreads, the "interpreters.main->id_mutex" is not freed by _PyRuntimeState_Fini and should not force the default raw allocator.
* bpo-28533: Remove asyncore, asynchat, smtpd modules (GH-29521)Victor Stinner2021-11-151-5/+2
| | | | | | | | | | | | | | | | Remove the asyncore and asynchat modules, deprecated in Python 3.6: use the asyncio module instead. Remove the smtpd module, deprecated in Python 3.6: the aiosmtpd module can be used instead, it is based on asyncio. * Remove asyncore, asynchat and smtpd documentation * Remove test_asyncore, test_asynchat and test_smtpd * Rename Lib/asynchat.py to Lib/test/support/_asynchat.py * Rename Lib/asyncore.py to Lib/test/support/_asyncore.py * Rename Lib/smtpd.py to Lib/test/support/_smtpd.py * Remove DeprecationWarning from private _asyncore, _asynchat and _smtpd modules * _smtpd: remove deprecated properties
* bpo-44631: Make the repr() of the _Environ class more readable. (#27128)Leonardo Freua2021-07-201-3/+5
| | | Co-authored-by: Łukasz Langa <lukasz@langa.pl>