summaryrefslogtreecommitdiffstats
path: root/Modules/posixmodule.c
Commit message (Collapse)AuthorAgeFilesLines
* gh-118486: Support mkdir(mode=0o700) on Windows (GH-118488)Steve Dower2024-05-091-2/+37
|
* gh-117267: Ensure DirEntry.stat().st_ctime still contains creation time ↵Miss Islington (bot)2024-04-031-0/+4
| | | | | | | during deprecation period (GH-117354) (cherry picked from commit 985917dc8d34e2d2f717f7a981580a8dcf18d53a) 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-3/+3
| | | | | | | | | | | | | | 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-116541: Handle errors correctly in `_pystatvfs_fromstructstatvfs` ↵Miss Islington (bot)2024-03-121-32/+36
| | | | | | | | (GH-116542) (#116643) gh-116541: Handle errors correctly in `_pystatvfs_fromstructstatvfs` (GH-116542) (cherry picked from commit f8147d01da44da2434496d868c86c2785f7244cd) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
* [3.12] gh-116520: Fix error handling in `os_get_terminal_size_impl` in ↵Miss Islington (bot)2024-03-091-6/+17
| | | | | | | | `posixmodule` (GH-116521) (#116539) gh-116520: Fix error handling in `os_get_terminal_size_impl` in `posixmodule` (GH-116521) (cherry picked from commit b4b4e764a798bab60324871074ce4cdebb9d01bb) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
* [3.12] gh-116448: Handle errors correctly in `os_waitid_impl` in ↵Miss Islington (bot)2024-03-071-9/+19
| | | | | | | | `posixmodule` (GH-116449) (#116451) gh-116448: Handle errors correctly in `os_waitid_impl` in `posixmodule` (GH-116449) (cherry picked from commit 882fcede83af783a834b759e4643130dc1307ee3) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
* [3.12] gh-116404: Handle errors correctly in `wait_helper` in `posixmodule` ↵Miss Islington (bot)2024-03-061-26/+29
| | | | | | | | (GH-116405) (#116406) gh-116404: Handle errors correctly in `wait_helper` in `posixmodule` (GH-116405) (cherry picked from commit 22ccf13b332902142fe0c52c593f9efc152c7761) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
* gh-111877: Fixes stat() handling for inaccessible files on Windows (GH-113716)Miss Islington (bot)2024-01-121-6/+10
| | | | | (cherry picked from commit ed066481c76c6888ff5709f5b9f93b92c232a4a6) Co-authored-by: Steve Dower <steve.dower@python.org>
* [3.12] bpo-11102: Make configure enable major(), makedev(), and minor() on ↵Miss Islington (bot)2023-12-281-4/+5
| | | | | | | | | | HP-UX (GH-19856) (GH-113540) Always include <sys/types.h> before <sys/sysmacros.h>. (cherry picked from commit f108468970bf4e70910862476900f924fb701399) Co-authored-by: Zackery Spytz <zspytz@gmail.com> 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/+6
| | | | | | | Windows (GH-111842) (GH-111966) (cherry picked from commit 0b06d2482d77e02c5d40e221f6046c9c355458b2) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.12] GH-111804: Drop posix.fallocate() under WASI (GH-111869) (GH-111919)Brett Cannon2023-11-091-2/+5
| | | | | | | | | GH-111804: Drop posix.fallocate() under WASI (GH-111869) Drop posix.fallocate() under WASI. The underlying POSIX function, posix_fallocate(), was found to vary too much between implementations to remain in WASI. As such, while it was available in WASI preview1, it's been dropped in preview2.
* GH-111293: Fix DirEntry.inode dropping higher bits on Windows (GH-111294)Miss Islington (bot)2023-10-261-3/+3
| | | | | (cherry picked from commit b468538d356552f0242763fe44a17b1939e8bd55) Co-authored-by: zcxsythenew <30565051+zcxsythenew@users.noreply.github.com>
* [3.12] gh-109782: Ensure `os.path.isdir` has the same signature on all ↵Alex Waygood2023-10-021-5/+5
| | | | | | | platforms (GH-109790) (#110233) gh-109782: Ensure `os.path.isdir` has the same signature on all platforms (GH-109790) Co-authored-by: Amin Alaee <mohammadamin.alaee@gmail.com>
* [3.12] gh-109613: _pystat_fromstructstat() checks for exceptions (GH-109618) ↵Miss Islington (bot)2023-10-021-49/+72
| | | | | | | | | | | | | | | | | | | | (#109641) gh-109613: _pystat_fromstructstat() checks for exceptions (GH-109618) Fix os.stat() and os.DirEntry.stat(): check for exceptions. Previously, on Python built in debug mode, these functions could trigger a fatal Python error (and abort the process) when a function succeeded with an exception set. _pystat_fromstructstat() now exits immediately if an exception is raised, rather only checking for exceptions at the end. It fix following fatal error in fill_time(): Fatal Python error: _Py_CheckSlotResult: Slot * of type int succeeded with an exception set (cherry picked from commit d4cea794a7b9b745817d2bd982d35412aef04710) Co-authored-by: Victor Stinner <vstinner@python.org>
* [3.12] gh-107913: Fix possible losses of OSError error codes (GH-107930) ↵Miss Islington (bot)2023-08-261-43/+85
| | | | | | | | | | | | (#108523) gh-107913: Fix possible losses of OSError error codes (GH-107930) Functions like PyErr_SetFromErrno() and SetFromWindowsErr() should be called immediately after using the C API which sets errno or the Windows error code. (cherry picked from commit 2b15536fa94d07e9e286826c23507402313ec7f4) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.12] gh-107801: Improve the accuracy of os.lseek docs (#107935) (#108136)Erlend E. Aasland2023-08-191-4/+9
| | | | | | | | | | - name the last parameter *whence*, like it is for seek() methods on file objects - add param docstrings - structure the valid *whence* params (cherry picked from commit dd4442c8f597af1ec3eaf20f7ad89c4ac7e2dbc9) Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
* [3.12] gh-106242: Fix path truncation in os.path.normpath (GH-106816) (#107981)Steve Dower2023-08-161-1/+3
| | | | | | | | | * gh-106242: Fix path truncation in os.path.normpath (GH-106816) * gh-106242: Minor fixup to avoid compiler warnings --------- Co-authored-by: Finn Womack <flan313@gmail.com> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.12] gh-106881: Check for linux/limits.h before including it (#107397) ↵justdan62023-07-281-1/+1
| | | | | | | | (#107414) * Check for linux/limits.h before including it Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com> (cherry picked from commit 11c055f5ff1a353de6d2e77f2af24aaa782878ba)
* [3.12] gh-86493: Fix possible leaks in some modules initialization ↵Serhiy Storchaka2023-07-181-8/+4
| | | | | | (GH-106768) (GH-106855) Fix _ssl, _stat, _testinternalcapi, _threadmodule, cmath, math, posix, time. (cherry picked from commit 3e65baee72131b49f4ce8ca2da568a6f2001ce93)
* [3.12] gh-86493: Fix possible leaks in modules initialization: ↵Serhiy Storchaka2023-07-181-37/+22
| | | | | | _curses_panel, _decimal, posix, xxsubtype (GH-106767) (#106849) (cherry picked from commit 745492355b94d109e47827e5865846f25ae42d26)
* [3.12] gh-105375: Improve posix error handling (GH-105592) (#105598)Miss Islington (bot)2023-06-111-4/+8
| | | | | | Fix a bug where an IndexError could end up being overwritten. (cherry picked from commit f668f73bc88cce0112b304d87aa998fb28013c71) Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
* [3.12] gh-104690 Disallow thread creation and fork at interpreter ↵Miss Islington (bot)2023-06-041-2/+19
| | | | | | | | | | | | | | | | | | | | | 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-104820: Fixes os.stat on Windows to better handle file systems that do ↵Miss Islington (bot)2023-05-291-4/+8
| | | | | | | not support FileIdInformation (GH-104892) (cherry picked from commit 6031727a37c6003f78e3b0c7414a0a214855dd08) Co-authored-by: Steve Dower <steve.dower@python.org>
* gh-104803: Implement ntpath.isdevdrive for checking whether a path is on a ↵Miss Islington (bot)2023-05-291-0/+90
| | | | | | | Windows Dev Drive (GH-104805) (cherry picked from commit bfd20d257e4ad16a25f4bac0ea4dbb719cdf6bc7) Co-authored-by: Steve Dower <steve.dower@python.org>
* GH-103545: Add macOS specific constants for ``os.setpriority`` to ``os`` ↵Ronald Oussoren2023-05-191-0/+12
| | | | | | | | | (#104606) This adds a number of PRIO_DARWIN_* constants to the os module for use with os.setpriority. --------- Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
* gh-99113: Add Py_MOD_PER_INTERPRETER_GIL_SUPPORTED (gh-104205)Eric Snow2023-05-051-0/+1
| | | Here we are doing no more than adding the value for Py_mod_multiple_interpreters and using it for stdlib modules. We will start checking for it in gh-104206 (once PyInterpreterState.ceval.own_gil is added in gh-104204).
* gh-104106: Add gcc fallback of mkfifoat/mknodat for macOS (gh-104129)Dong-hee Na2023-05-051-4/+12
|
* gh-102765: Update ntpath.isdir/isfile/islink/exists to use ↵Finn Womack2023-04-271-118/+191
| | | | GetFileInformationByName when available (GH-103485)
* gh-103167: Fix `-Wstrict-prototypes` warnings by using `(void)` for ↵Nikita Sobolev2023-04-051-2/+2
| | | | functions with no args (GH-103168)
* gh-99726: Improves correctness of stat results for Windows, and uses faster ↵Steve Dower2023-03-161-45/+146
| | | | | 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: Add os.listdrives, os.listvolumes and os.listmounts on Windows ↵Steve Dower2023-03-101-0/+194
| | | | (GH-102544)
* gh-102255: Improve build support for Windows API partitions (GH-102256)Max Bachmann2023-03-091-18/+40
| | | | | 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-100227: Isolate the Import State to Each Interpreter (gh-101941)Eric Snow2023-03-091-5/+8
| | | | | | | | | | | | Specific changes: * move the import lock to PyInterpreterState * move the "find_and_load" diagnostic state to PyInterpreterState Note that the import lock exists to keep multiple imports of the same module in the same interpreter (but in different threads) from stomping on each other. Independently, we use a distinct global lock to protect globally shared import state, especially related to loaded extension modules. For now we can rely on the GIL as that lock but with a per-interpreter GIL we'll need a new global lock. The remaining state in _PyRuntimeState.imports will (probably) continue being global. https://github.com/python/cpython/issues/100227
* gh-102179: Fix `os.dup2` error reporting for negative fds (#102180)Alexey Izbyshev2023-03-041-5/+0
|
* gh-102336: Remove code specifically for handling Windows 7 (GH-102337)Max Bachmann2023-03-011-84/+28
|
* gh-102192: Replace PyErr_Fetch/Restore etc by more efficient alternatives ↵Irit Katriel2023-02-241-3/+2
| | | | (in Modules/) (#102196)
* gh-102141: replace use of getpid on Windows with GetCurrentProcessId (GH-102142)Max Bachmann2023-02-241-6/+9
|
* gh-101881: Support (non-)blocking read/write functions on Windows pipes ↵Rayyan Ansari2023-02-161-2/+0
| | | | | | | | | | | | (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-101857: Allow xattr detection on musl libc (#101858)Sam James2023-02-141-1/+2
| | | | | | | | | | Previously, we checked exclusively for `__GLIBC__` (AND'd with some other conditions). Checking for `__linux__` instead should be fine. This fixes using e.g. `os.listxattr()` on systems using musl libc. Bug: https://bugs.gentoo.org/894130 Co-authored-by: Gregory P. Smith <greg@krypto.org>
* gh-101196: Make isdir/isfile/exists faster on Windows (GH-101324)Michael Droettboom2023-02-081-0/+310
| | | Co-authored-by: Eryk Sun <eryksun@gmail.com>
* gh-59956: Clarify GILState-related Code (gh-101161)Eric Snow2023-01-191-6/+1
| | | | | | | | | | The objective of this change is to help make the GILState-related code easier to understand. This mostly involves moving code around and some semantically equivalent refactors. However, there are a also a small number of slight changes in structure and behavior: * tstate_current is moved out of _PyRuntimeState.gilstate * autoTSSkey is moved out of _PyRuntimeState.gilstate * autoTSSkey is initialized earlier * autoTSSkey is re-initialized (after fork) earlier https://github.com/python/cpython/issues/59956
* gh-100649: Update native_thread_id after fork (gh-100650)Gabriele N. Tornetta2023-01-011-0/+4
| | | Update native_thread_id after fork
* gh-100228: Warn from os.fork() if other threads exist. (#100229)Gregory P. Smith2022-12-291-0/+103
| | | | | 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-69564: Clarify use of octal format of mode argument in help(os.chmod) ↵amaajemyfren2022-12-211-2/+10
| | | | | (#20621) Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
* gh-81057: Fix a Reference Leak in the posix Module (gh-100140)Eric Snow2022-12-091-0/+1
| | | | | The leak was introduced in gh-100082. https://github.com/python/cpython/issues/81057
* gh-81057: Move time Globals to _PyRuntimeState (gh-100122)Eric Snow2022-12-081-25/+5
| | | https://github.com/python/cpython/issues/81057
* gh-81057: Move OS-Related Globals to _PyRuntimeState (gh-100082)Eric Snow2022-12-081-16/+38
| | | https://github.com/python/cpython/issues/81057
* bpo-15999: Accept arbitrary values for boolean parameters. (#15609)Serhiy Storchaka2022-12-031-8/+8
| | | builtins and extension module functions and methods that expect boolean values for parameters now accept any Python object rather than just a bool or int type. This is more consistent with how native Python code itself behaves.
* GH-95896: posixmodule.c: fix osdefs.h inclusion to not depend on compiler ↵TheShermanTanker2022-11-261-11/+3
| | | | | (#95897) Co-authored-by: Steve Dower <steve.dower@python.org>
* gh-99537: Use Py_SETREF(var, NULL) in C code (#99687)Victor Stinner2022-11-231-8/+4
| | | Replace "Py_DECREF(var); var = NULL;" with "Py_SETREF(var, NULL);".