summaryrefslogtreecommitdiffstats
path: root/Modules/posixmodule.c
Commit message (Collapse)AuthorAgeFilesLines
* [3.10] gh-102179: Fix `os.dup2` error reporting for negative fds (GH-102180) ↵Miss Islington (bot)2023-03-041-5/+0
| | | | | | | | | (#102419) * gh-102179: Fix `os.dup2` error reporting for negative fds (GH-102180) (cherry picked from commit c2bd55d26f8eb2850eb9f9026b5d7f0ed1420b65) Co-authored-by: Alexey Izbyshev <izbyshev@ispras.ru> Co-authored-by: Kumar Aditya <59607654+kumaraditya303@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.10] gh-96288: Add a sentence to `os.mkdir`'s docstring. (GH-96271). (#98066)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.10] gh-97897: Prevent os.mkfifo and os.mknod segfaults with macOS 13 SDK ↵Miss Islington (bot)2022-10-061-8/+52
| | | | | | | | | | | | | (GH-97944) (#97967) 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.10] GH-93899: fix checks for eventfd flags (GH-95170). (#95345)Kumar Aditya2022-07-281-3/+7
| | | | | (cherry picked from commit 4dd099bafff14639ef5d2185965016d8f253353f) Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
* bpo-46785: Fix race condition between os.stat() and unlink on Windows (GH-31858)Itai Steinherz2022-05-101-1/+11
| | | | | | * [3.10] bpo-46785: Fix race condition between os.stat() and unlink on Windows (GH-31858). (cherry picked from commit 39e6b8ae6a5b49bb23746fdcc354d148ff2d98e3) Co-authored-by: Itai Steinherz <itaisteinherz@gmail.com>
* [3.10] bpo-41498: Fix build on platforms without sigset_t (GH-29770) (GH-29773)Miss Islington (bot)2021-11-251-0/+8
| | | | | | | | (cherry picked from commit dc19e8698327cae3d6274b73c135375955f1d0d0) Co-authored-by: Christian Heimes <christian@python.org> Automerge-Triggered-By: GH:tiran
* bpo-44219: Release the GIL during isatty syscalls (GH-28250) (GH-28255)Miss Islington (bot)2021-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. (cherry picked from commit 06148b1870fceb1a21738761b8e1ac3bf654319b) Co-authored-by: Vincent Michel <vxgmichel@gmail.com>
* bpo-43916: Remove _disabled_new() function (GH-25745)Victor Stinner2021-04-301-12/+3
| | | | | posix and _hashlib use the new Py_TPFLAGS_DISALLOW_INSTANTIATION flag on their heap types, rather than using a custom tp_new function (_disabled_new).
* bpo-30555: Fix WindowsConsoleIO fails in the presence of fd redirection ↵Segev Finer2021-04-231-4/+2
| | | | | | | | (GH-1927) This works by not caching the handle and instead getting the handle from the file descriptor each time, so that if the actual handle changes by fd redirection closing/opening the console handle beneath our feet, we will keep working correctly.
* bpo-43538: Add extra arguments to os.startfile (GH-25538)Steve Dower2021-04-231-3/+22
|
* bpo-38222: Check specifically for a drive, not just a colon (GH-25540)Steve Dower2021-04-221-2/+2
|
* bpo-38822: Fixed os.stat failing on inaccessible directories. (GH-25527)Steve Dower2021-04-221-2/+21
| | | It would just fail if the path was inaccessible and had a trailing slash. It should fall back to the parent directory's metadata.
* bpo-40137: Add pycore_moduleobject.h internal header (GH-25507)Victor Stinner2021-04-211-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add pycore_moduleobject.h internal header file with static inline functions to access module members: * _PyModule_GetDict() * _PyModule_GetDef() * _PyModule_GetState() These functions don't check at runtime if their argument has a valid type and can be inlined even if Python is not built with LTO. _PyType_GetModuleByDef() uses _PyModule_GetDef(). Replace PyModule_GetState() with _PyModule_GetState() in the extension modules, considered as performance sensitive: * _abc * _functools * _operator * _pickle * _queue * _random * _sre * _struct * _thread * _winapi * array * posix The following extensions are now built with the Py_BUILD_CORE_MODULE macro defined, to be able to use the internal pycore_moduleobject.h header: _abc, array, _operator, _queue, _sre, _struct.
* bpo-43105: Importlib now resolves relative paths when creating module spec ↵Steve Dower2021-04-071-0/+49
| | | | objects from file locations (GH-25121)
* bpo-43106: Add os.O_EVTONLY/O_FSYNC/O_SYMLINK/O_NOFOLLOW_ANY (GH-24428)Dong-hee Na2021-02-031-1/+12
|
* bpo-42692: fix __builtin_available check on older compilers (GH-23873)Joshua Root2021-01-041-1/+7
| | | | | | A compiler that doesn't define `__has_builtin` will error out when it is used on the same line as the check for it. Automerge-Triggered-By: GH:ronaldoussoren
* bpo-42655: Fix subprocess extra_groups gid conversion (GH-23762)Jakub Kulík2020-12-291-4/+4
|
* bpo-41625: Do not add os.splice on AIX due to compatibility issues (GH-23608)Pablo Galindo2020-12-021-1/+1
|
* bpo-42519: Replace PyMem_MALLOC() with PyMem_Malloc() (GH-23586)Victor Stinner2020-12-011-15/+16
| | | | | | | | | | | No longer use deprecated aliases to functions: * Replace PyMem_MALLOC() with PyMem_Malloc() * Replace PyMem_REALLOC() with PyMem_Realloc() * Replace PyMem_FREE() with PyMem_Free() * Replace PyMem_Del() with PyMem_Free() * Replace PyMem_DEL() with PyMem_Free() Modify also the PyMem_DEL() macro to use directly PyMem_Free().
* bpo-1635741: Convert _imp to multi-phase init (GH-23378)Victor Stinner2020-11-181-1/+1
| | | | | | | | | | | | Convert the _imp extension module to the multi-phase initialization API (PEP 489). * Add _PyImport_BootstrapImp() which fix a bootstrap issue: import the _imp module before importlib is initialized. * Add create_builtin() sub-function, used by _imp_create_builtin(). * Initialize PyInterpreterState.import_func earlier, in pycore_init_builtins(). * Remove references to _PyImport_Cleanup(). This function has been renamed to finalize_modules() and moved to pylifecycle.c.
* bpo-41625: Add a guard for Linux for splice() constants in the os module ↵Pablo Galindo2020-11-171-1/+1
| | | | (GH-23350)
* bpo-41625: Expose the splice() system call in the os module (GH-21947)Pablo Galindo2020-11-171-1/+77
|
* bpo-41001: Add os.eventfd() (#20930)Christian Heimes2020-11-131-0/+91
| | | Co-authored-by: Kyle Stanley <aeros167@gmail.com>
* bpo-42237: Fix os.sendfile() on illumos (GH-23154)Jakub Stasiak2020-11-121-0/+15
|
* bpo-41100: Support macOS 11 and Apple Silicon (GH-22855)Ronald Oussoren2020-11-081-175/+647
| | | | | | | | | | | Co-authored-by: Lawrence D’Anna <lawrence_danna@apple.com> * Add support for macOS 11 and Apple Silicon (aka arm64) As a side effect of this work use the system copy of libffi on macOS, and remove the vendored copy * Support building on recent versions of macOS while deploying to older versions This allows building installers on macOS 11 while still supporting macOS 10.9.
* bpo-42029: Remove IRIX code (GH-23023)Victor Stinner2020-10-291-4/+3
| | | | IRIX code was slowy removed in Python 2.4 (--with-sgi-dl), Python 3.3 (Irix threads), and Python 3.7.
* bpo-42152: Use PyDict_Contains and PyDict_SetDefault if appropriate. (GH-22986)Serhiy Storchaka2020-10-261-7/+5
| | | | | | | If PyDict_GetItemWithError is only used to check whether the key is in dict, it is better to use PyDict_Contains instead. And if it is used in combination with PyDict_SetItem, PyDict_SetDefault can replace the combination.
* bpo-40422: Move _Py_closerange to fileutils.c (GH-22680)Kyle Evans2020-10-131-76/+1
| | | | | | | This API is relatively lightweight and organizationally, given that it's used by multiple modules, it makes sense to move it to fileutils. Requires making sure that _posixsubprocess is compiled with the appropriate Py_BUIILD_CORE_BUILTIN macro.
* bpo-40422: Move _Py_*_SUPPRESS_IPH bits into _Py_closerange (GH-22672)Kyle Evans2020-10-121-2/+2
| | | | | | This suppression is no longer needed in os_closerange_impl, as it just invokes the internal _Py_closerange implementation. On the other hand, consumers of _Py_closerange may not have any other reason to suppress invalid parameter issues, so narrow the scope to here.
* bpo-40423: Optimization: use close_range(2) if available (GH-22651)Kyle Evans2020-10-111-3/+14
| | | | | | | close_range(2) should be preferred at all times if it's available, otherwise we'll use closefrom(2) if available with a fallback to fdwalk(3) or plain old loop over fd range in order of most efficient to least. [note that this version does check for ENOSYS, but currently ignores all other errors] Automerge-Triggered-By: @pablogsal
* bpo-40422: create a common _Py_closerange API (GH-19754)Kyle Evans2020-10-111-24/+46
| | | | | | | Such an API can be used both for os.closerange and subprocess. For the latter, this yields potential improvement for platforms that have fdwalk but wouldn't have used it there. This will prove even more beneficial later for platforms that have close_range(2), as the new API will prefer that over all else if it's available. The new API is structured to look more like close_range(2), closing from [start, end] rather than the [low, high) of os.closerange(). Automerge-Triggered-By: @gpshead
* bpo-41985: Add _PyLong_FileDescriptor_Converter and AC converter for ↵Serhiy Storchaka2020-10-091-17/+1
| | | | "fildes". (GH-22620)
* bpo-41687: Fix error handling in Solaris sendfile implementation (GH-22128)Jakub Kulík2020-09-091-3/+2
| | | | | | | I just realized that my recent PR with sendfile on Solaris ([PR 22040](https://github.com/python/cpython/pull/22040)) has broken error handling. Sorry for that, this simple followup fixes that. Automerge-Triggered-By: @1st1
* bpo-41687: Fix sendfile implementation to work with Solaris (#22040)Jakub Kulík2020-09-051-0/+19
|
* bpo-41440: add os.cpu_count() support for VxWorks RTOS (GH-21685)pxinwr2020-08-071-0/+5
|
* bpo-36346: Make using the legacy Unicode C API optional (GH-21437)Serhiy Storchaka2020-07-101-9/+61
| | | | Add compile time option USE_UNICODE_WCHAR_CACHE. Setting it to 0 makes the interpreter not using the wchar_t cache and the legacy Unicode C API.
* bpo-41056: Use the fildes converter for fd to please Coverity. (GH-21011)Gregory P. Smith2020-06-201-2/+2
| | | | | | | | | There are a bunch of other fd: int uses in this file, I expect many if not all of them would be better off using the fildes converter. This particular one was flagged by Coverity as it presumably flags fpathconf as not accepting negative fds. I'd expect the other fd's to have been flagged as well otherwise. I'm marking this one as skip news as it really is a no-op.
* PyOS_AfterFork_Child() pass tstate to _PyEval_ReInitThreads() (GH-20598)Victor Stinner2020-06-021-2/+6
|
* PyOS_AfterFork_Child() uses PyStatus (GH-20596)Victor Stinner2020-06-021-5/+32
| | | | | | | | PyOS_AfterFork_Child() helper functions now return a PyStatus: PyOS_AfterFork_Child() is now responsible to handle errors. * Move _PySignal_AfterFork() to the internal C API * Add #ifdef HAVE_FORK on _PyGILState_Reinit(), _PySignal_AfterFork() and _PyInterpreterState_DeleteExceptMain().
* bpo-40792: Make the result of PyNumber_Index() always having exact type int. ↵Serhiy Storchaka2020-05-281-3/+3
| | | | | | | | | | | | (GH-20443) Previously, the result could have been an instance of a subclass of int. Also revert bpo-26202 and make attributes start, stop and step of the range object having exact type int. Add private function _PyNumber_Index() which preserves the old behavior of PyNumber_Index() for performance to use it in the conversion functions like PyLong_AsLong().
* bpo-37129: Add os.RWF_APPEND flag for os.pwritev() (GH-20336)YoSTEALTH2020-05-271-1/+5
|
* bpo-37999: No longer use __int__ in implicit integer conversions. (GH-15636)Serhiy Storchaka2020-05-261-5/+0
| | | | Only __index__ should be used to make integer conversions lossless.
* bpo-40653: Move _dirnameW out of #ifdef HAVE_SYMLINK/#endif (GH-20144)Minmin Gong2020-05-181-2/+6
|
* bpo-40549: posixmodule.c uses defining_class (GH-20075)Victor Stinner2020-05-141-81/+97
| | | | | | | | | Pass PEP 573 defining_class to os.DirEntry methods. The module state is now retrieve from defining_class rather than Py_TYPE(self), to support subclasses (even if DirEntry doesn't support subclasses yet). * Pass the module rather than defining_class to DirEntry_fetch_stat(). * Only get the module state once in _posix_clear(), _posix_traverse() and _posixmodule_exec().
* bpo-40549: Convert posixmodule.c to multiphase init (GH-19982)Victor Stinner2020-05-101-117/+134
| | | | | | | | | | | | | | | Convert posixmodule.c ("posix" or "nt" module) to the multiphase initialization (PEP 489). * Create the module using PyModuleDef_Init(). * Create ScandirIteratorType and DirEntryType with the new PyType_FromModuleAndSpec() (PEP 573) * Get the module state from ScandirIteratorType and DirEntryType with the new PyType_GetModule() (PEP 573) * Pass module to functions which access the module state. * convert_sched_param() gets a new module parameter. It is now called directly since Argument Clinic doesn't support passing the module to an argument converter callback. * Remove _posixstate_global macro.
* bpo-40453: Add PyConfig._isolated_subinterpreter (GH-19820)Victor Stinner2020-05-011-3/+4
| | | | | | | | | An isolated subinterpreter cannot spawn threads, spawn a child process or call os.fork(). * Add private _Py_NewInterpreter(isolated_subinterpreter) function. * Add isolated=True keyword-only parameter to _xxsubinterpreters.create(). * Allow again os.fork() in "non-isolated" subinterpreters.
* bpo-38061: os.closerange() uses closefrom() on FreeBSD (GH-19696)Victor Stinner2020-04-241-7/+20
| | | | | | | | | On FreeBSD, os.closerange(fd_low, fd_high) now calls closefrom(fd_low) if fd_high is greater than or equal to sysconf(_SC_OPEN_MAX). Initial patch by Ed Maste (emaste), Conrad Meyer (cem), Kyle Evans (kevans) and Kubilay Kocak (koobs): https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=242274
* bpo-40138: Fix Windows os.waitpid() for large exit code (GH-19637)Victor Stinner2020-04-221-6/+29
| | | | | | | | Fix the Windows implementation of os.waitpid() for exit code larger than "INT_MAX >> 8". The exit status is now interpreted as an unsigned number. os.waitstatus_to_exitcode() now accepts wait status larger than INT_MAX.