summaryrefslogtreecommitdiffstats
path: root/Modules/posixmodule.c
Commit message (Collapse)AuthorAgeFilesLines
* [3.11] bpo-11102: Make configure enable major(), makedev(), and minor() on ↵Miss Islington (bot)2023-12-281-4/+5
| | | | | | | | | | HP-UX (GH-19856) (GH-113541) 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.11] gh-111841: Fix os.putenv() and os.unsetenv() with embedded NUL on ↵Miss Islington (bot)2023-11-111-1/+6
| | | | | | | Windows (GH-111842) (GH-111967) (cherry picked from commit 0b06d2482d77e02c5d40e221f6046c9c355458b2) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.11] GH-111804: Drop posix.fallocate() under WASI (GH-111869) (GH-111920)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.
* [3.11] gh-109613: _pystat_fromstructstat() checks for exceptions (#109618) ↵Victor Stinner2023-09-211-46/+67
| | | | | | | | | | | | | | | | | | | (#109668) gh-109613: _pystat_fromstructstat() checks for exceptions (#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)
* [3.11] gh-107913: Fix possible losses of OSError error codes (GH-107930) ↵Serhiy Storchaka2023-08-271-45/+85
| | | | | | | | (GH-108524) 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)
* [3.11] gh-107801: Improve the accuracy of os.lseek docs (#107935) (#108137)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.11] gh-106242: Fix path truncation in os.path.normpath (GH-106816) (#107982)Steve Dower2023-08-151-1/+3
| | | Co-authored-by: Finn Womack <flan313@gmail.com>
* [3.11] gh-106881: Check for linux/limits.h before including it (#107397) ↵justdan62023-07-281-1/+1
| | | | | | | | | | | | (#107415) * [3.11] gh-106881: Check for linux/limits.h before including it (#107397) * Check for linux/limits.h before including it Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com> (cherry picked from commit 11c055f5ff1a353de6d2e77f2af24aaa782878ba) * Fix sphinx-lint error in NEWS entry
* [3.11] gh-86493: Fix possible leaks in some modules initialization ↵Serhiy Storchaka2023-07-191-8/+4
| | | | | | | | | (GH-106768) (GH-106855) (GH-106863) [3.11] [3.12] gh-86493: Fix possible leaks in some modules initialization (GH-106768) (GH-106855) Fix _ssl, _stat, _testinternalcapi, _threadmodule, cmath, math, posix, time. (cherry picked from commit 3e65baee72131b49f4ce8ca2da568a6f2001ce93). (cherry picked from commit a423ddbdeada8a2fd8657453b9e9f58ba0dd921d)
* [3.11] gh-86493: Fix possible leaks in modules initialization: ↵Serhiy Storchaka2023-07-181-45/+22
| | | | | | | _curses_panel, _decimal, posix, xxsubtype (GH-106767) (GH-106849) (GH-106851) (cherry picked from commit 745492355b94d109e47827e5865846f25ae42d26) (cherry picked from commit 970cb8eabaaf5a8311f1aba4ca4968ef7385fce8)
* [3.11] gh-105375: Improve posix error handling (GH-105592) (#105597)Miss Islington (bot)2023-06-091-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.11] gh-101857: Allow xattr detection on musl libc (GH-101858) (#101894)Miss Islington (bot)2023-05-211-1/+2
| | | | | | | | | | | | | | | gh-101857: Allow xattr detection on musl libc (GH-101858) 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 (cherry picked from commit 8be8101bca34b60481ec3d7ecaea4a3379fb7dbb) Co-authored-by: Sam James <sam@gentoo.org> Co-authored-by: Gregory P. Smith <greg@krypto.org>
* [3.11] gh-104106: Add gcc fallback of mkfifoat/mknodat for macOS (gh-104129) ↵Dong-hee Na2023-05-051-0/+8
| | | | | (gh-104187) gh-104106: Add gcc fallback of mkfifoat/mknodat for macOS (gh-104129)
* gh-102179: Fix `os.dup2` error reporting for negative fds (GH-102180)Miss Islington (bot)2023-03-041-5/+0
| | | | | (cherry picked from commit c2bd55d26f8eb2850eb9f9026b5d7f0ed1420b65) Co-authored-by: Alexey Izbyshev <izbyshev@ispras.ru>
* gh-100649: Update native_thread_id after fork (gh-100650)Miss Islington (bot)2023-01-011-0/+4
| | | | | | Update native_thread_id after fork (cherry picked from commit d52d4942cfdd52a50f88b87b1ff2a67375dbcf47) Co-authored-by: Gabriele N. Tornetta <P403n1x87@users.noreply.github.com>
* GH-95896: posixmodule.c: fix osdefs.h inclusion to not depend on compiler ↵Miss Islington (bot)2022-11-261-11/+3
| | | | | | | | (GH-95897) (cherry picked from commit ec2b76aa8b7c6313293ff9c6814e8bc31e08fcaf) Co-authored-by: TheShermanTanker <32636402+TheShermanTanker@users.noreply.github.com> Co-authored-by: Steve Dower <steve.dower@python.org>
* [3.11] gh-99337: Fix compile errors with gcc 12 on macOS (GH-99470) (#99638)Miss Islington (bot)2022-11-211-4/+16
| | | | | | | | | | | | | | gh-99337: Fix compile errors with gcc 12 on macOS (GH-99470) Fix a number of compile errors with GCC-12 on macOS: 1. In pylifecycle.c the compile rejects _Pragma within a declaration 2. posixmodule.c was missing a number of ..._RUNTIME macros for non-clang on macOS 3. _ctypes assumed that __builtin_available is always present on macOS (cherry picked from commit cdde29dde90947df9bac39c1d19479914fb3db09) Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com> Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com>
* [3.11] gh-96288: Add a sentence to `os.mkdir`'s docstring. (GH-96271). (#98065)Jelle Zijlstra2022-10-081-2/+3
| | | | | (cherry picked from commit 1523c9e9d47e7d67e4889987ff0f38eb7b881fdd) Co-authored-by: Hagai Helman Tov <hagai.helman@gmail.com>
* fixes gh-96078: os.sched_yield release the GIL while calling sched_yield(2). ↵Miss Islington (bot)2022-10-071-1/+6
| | | | | | | (gh-97965) (cherry picked from commit b9d2e8171696514e9226164005f7bf24bf69e66d) Co-authored-by: Dong-hee Na <donghee.na@python.org>
* [3.11] gh-97897: Prevent os.mkfifo and os.mknod segfaults with macOS 13 SDK ↵Miss Islington (bot)2022-10-061-8/+52
| | | | | | | | | | | | | (GH-97944) (#97969) The macOS 13 SDK includes support for the `mkfifoat` and `mknodat` system calls. Using the `dir_fd` option with either `os.mkfifo` or `os.mknod` could result in a segfault if cpython is built with the macOS 13 SDK but run on an earlier version of macOS. Prevent this by adding runtime support for detection of these system calls ("weaklinking") as is done for other newer syscalls on macOS. (cherry picked from commit 6d0a0191a4e5477bd843e62c24d7f3bcad4fd5fc) Co-authored-by: Ned Deily <nad@python.org>
* [3.11] gh-95174: Handle missing dup() and constants in WASI (GH-95229) ↵Christian Heimes2022-07-311-1/+4
| | | | | (GH-95272) Co-authored-by: Christian Heimes <christian@python.org>
* [3.11] GH-93899: fix checks for eventfd flags (GH-95170). (#95342)Kumar Aditya2022-07-281-3/+7
| | | | | (cherry picked from commit 4dd099bafff14639ef5d2185965016d8f253353f) Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
* gh-90473: Make chmod a dummy on WASI, skip chmod tests (GH-93534) (GH-93550)Miss Islington (bot)2022-06-061-0/+4
| | | | | | WASI does not have the ``chmod(2)`` syscall yet. (cherry picked from commit 22fed605e096eb74f3aa33f6d25aee76fdc2a3fa) Co-authored-by: Christian Heimes <christian@python.org>
* bpo-41818: Add os.login_tty() for *nix. (#29658)Soumendra Ganguly2022-05-051-9/+60
| | | | | | * Add `os.login_tty(fd)` for Unix. Reviewed-by: Christian Heimes <christian@python.org> Signed-off-by: Gregory P. Smith [Google LLC] <greg@krypto.org>
* gh-90887: posix module: Add more flags for fcopy_file (#31300)David CARLIER2022-05-031-0/+3
| | | | | | Closes #90887 Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* bpo-46785: Fix race condition between os.stat() and unlink on Windows (GH-31858)Itai Steinherz2022-05-021-1/+11
|
* gh-64783: Fix signal.NSIG value on FreeBSD (#91929)Victor Stinner2022-04-251-2/+4
| | | | | | | | | Fix signal.NSIG value on FreeBSD to accept signal numbers greater than 32, like signal.SIGRTMIN and signal.SIGRTMAX. * Add Py_NSIG constant. * Add pycore_signal.h internal header file. * _Py_Sigset_Converter() now includes the range of valid signals in the error message.
* gh-90623: signal.raise_signal() calls PyErr_CheckSignals() (#91756)Victor Stinner2022-04-211-1/+10
| | | | signal.raise_signal() and os.kill() now call PyErr_CheckSignals() to check immediately for pending signals.
* gh-91731: Replace Py_BUILD_ASSERT() with static_assert() (#91730)Victor Stinner2022-04-201-4/+8
| | | | | | | | | | | | Python 3.11 now uses C11 standard which adds static_assert() to <assert.h>. * In pytime.c, replace Py_BUILD_ASSERT() with preprocessor checks on SIZEOF_TIME_T with #error. * On macOS, py_mach_timebase_info() now accepts timebase members with the same size than _PyTime_t. * py_get_monotonic_clock() now saturates GetTickCount64() to _PyTime_MAX: GetTickCount64() is unsigned, whereas _PyTime_t is signed.
* bpo-46968: Add os.sysconf_names['SC_MINSIGSTKSZ'] (GH-31824)Victor Stinner2022-03-111-0/+3
|
* bpo-46606: os.getgroups() doesn't overallocate (GH-31569)Victor Stinner2022-02-261-32/+25
|
* bpo-46606: Remove redundant +1. (GH-31561)Inada Naoki2022-02-251-1/+1
|
* bpo-46606: Reduce stack usage of getgroups and setgroups (GH-31073)Inada Naoki2022-02-221-56/+23
| | | NGROUPS_MAX was 32 before Linux 2.6.4 but 65536 since Linux 2.6.4.
* bpo-46541: Replace core use of _Py_IDENTIFIER() with statically initialized ↵Eric Snow2022-02-081-6/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | global objects. (gh-30928) We're no longer using _Py_IDENTIFIER() (or _Py_static_string()) in any core CPython code. It is still used in a number of non-builtin stdlib modules. The replacement is: PyUnicodeObject (not pointer) fields under _PyRuntimeState, statically initialized as part of _PyRuntime. A new _Py_GET_GLOBAL_IDENTIFIER() macro facilitates lookup of the fields (along with _Py_GET_GLOBAL_STRING() for non-identifier strings). https://bugs.python.org/issue46541#msg411799 explains the rationale for this change. The core of the change is in: * (new) Include/internal/pycore_global_strings.h - the declarations for the global strings, along with the macros * Include/internal/pycore_runtime_init.h - added the static initializers for the global strings * Include/internal/pycore_global_objects.h - where the struct in pycore_global_strings.h is hooked into _PyRuntimeState * Tools/scripts/generate_global_objects.py - added generation of the global string declarations and static initializers I've also added a --check flag to generate_global_objects.py (along with make check-global-objects) to check for unused global strings. That check is added to the PR CI config. The remainder of this change updates the core code to use _Py_GET_GLOBAL_IDENTIFIER() instead of _Py_IDENTIFIER() and the related _Py*Id functions (likewise for _Py_GET_GLOBAL_STRING() instead of _Py_static_string()). This includes adding a few functions where there wasn't already an alternative to _Py*Id(), replacing the _Py_Identifier * parameter with PyObject *. The following are not changed (yet): * stop using _Py_IDENTIFIER() in the stdlib modules * (maybe) get rid of _Py_IDENTIFIER(), etc. entirely -- this may not be doable as at least one package on PyPI using this (private) API * (maybe) intern the strings during runtime init https://bugs.python.org/issue46541
* bpo-40280: Address more test failures on Emscripten (GH-31050)Christian Heimes2022-02-051-2/+2
| | | Co-authored-by: Brett Cannon <brett@python.org>
* bpo-46362: Ensure ntpath.abspath() uses the Windows API correctly (GH-30571)neonene2022-01-131-2/+43
| | | This makes ntpath.abspath()/getpath_abspath() follow normpath(), since some WinAPIs such as PathCchSkipRoot() require backslashed paths.
* bpo-46315: Add ifdef HAVE_ feature checks for WASI compatibility (GH-30507)Christian Heimes2022-01-131-0/+9
|
* bpo-46222: posixmodule sendfile FreeBSD's constants updates. (GH-30327)David CARLIER2022-01-031-0/+4
| | | | | | | * posixodule sendfile FreeBSD's constants updates. * 📜🤖 Added by blurb_it. Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
* bpo-45855: Replaced deprecated `PyImport_ImportModuleNoBlock` with ↵Kumar Aditya2021-12-121-1/+1
| | | | PyImport_ImportModule (GH-30046)
* bpo-46008: Add _PyInterpreterState_Main(). (gh-29978)Eric Snow2021-12-081-2/+2
| | | | | PyInterpreterState_Main() is a plain function exposed in the public C-API. For internal usage we can take the more efficient approach in this PR. https://bugs.python.org/issue46008
* bpo-45582: Port getpath[p].c to Python (GH-29041)Steve Dower2021-12-031-0/+28
| | | | | The getpath.py file is frozen at build time and executed as code over a namespace. It is never imported, nor is it meant to be importable or reusable. However, it should be easier to read, modify, and patch than the previous code. This commit attempts to preserve every previously tested quirk, but these may be changed in the future to better align platforms.
* bpo-40280: Move hard-coded feature checks to configure (GH-29789)Christian Heimes2021-11-261-20/+0
| | | Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
* bpo-41498: Fix build on platforms without sigset_t (GH-29770)Christian Heimes2021-11-251-0/+8
|
* bpo-45434: pyport.h no longer includes <stdlib.h> (GH-28914)Victor Stinner2021-10-131-1/+2
| | | | | Include <stdlib.h> explicitly in C files. Python.h includes <wchar.h>.
* pycore_pystate.h no longer redefines PyThreadState_GET() (GH-28921)Victor Stinner2021-10-131-13/+11
| | | | | | | | | | | | | | | | | | | | | | Redefining the PyThreadState_GET() macro in pycore_pystate.h is useless since it doesn't affect files not including it. Either use _PyThreadState_GET() directly, or don't use pycore_pystate.h internal C API. For example, the _testcapi extension don't use the internal C API, but use the public PyThreadState_Get() function instead. Replace PyThreadState_Get() with _PyThreadState_GET(). The _PyThreadState_GET() macro is more efficient than PyThreadState_Get() and PyThreadState_GET() function calls which call fail with a fatal Python error. posixmodule.c and _ctypes extension now include <windows.h> before pycore header files (like pycore_call.h). _PyTraceback_Add() now uses _PyErr_Fetch()/_PyErr_Restore() instead of PyErr_Fetch()/PyErr_Restore(). The _decimal and _xxsubinterpreters extensions are now built with the Py_BUILD_CORE_MODULE macro defined to get access to the internal C API.
* bpo-45439: Move _PyObject_CallNoArgs() to pycore_call.h (GH-28895)Victor Stinner2021-10-121-1/+2
| | | | | | | * Move _PyObject_CallNoArgs() to pycore_call.h (internal C API). * _ssl, _sqlite and _testcapi extensions now call the public PyObject_CallNoArgs() function, rather than _PyObject_CallNoArgs(). * _lsprof extension is now built with Py_BUILD_CORE_MODULE macro defined to get access to internal _PyObject_CallNoArgs().
* bpo-45439: Rename _PyObject_CallNoArg() to _PyObject_CallNoArgs() (GH-28891)Victor Stinner2021-10-111-3/+3
| | | | | Fix typo in the private _PyObject_CallNoArg() function name: rename it to _PyObject_CallNoArgs() to be consistent with the public function PyObject_CallNoArgs().
* Clean up initialization __class_getitem__ with Py_GenericAlias. (GH-28450)Serhiy Storchaka2021-09-191-1/+1
| | | | | The cast to PyCFunction is redundant. Overuse of redundant casts can hide actual bugs.
* bpo-44219: Release the GIL during isatty syscalls (GH-28250)Vincent Michel2021-09-091-0/+2
| | | | | | Release the GIL while performing isatty() system calls on arbitrary file descriptors. In particular, this affects os.isatty(), os.device_encoding() and io.TextIOWrapper. By extension, io.open() in text mode is also affected.
* bpo-45012: Release GIL around stat in os.scandir (GH-28085)Stanisław Skonieczny2021-09-071-2/+8
| | | | | Releasing GIL allows other threads to continue its work when os.scandir is fetching DirEntry.stat info from file system.