summaryrefslogtreecommitdiffstats
path: root/Modules/posixmodule.c
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* bpo-40178: Convert the remaining os functions to Argument Clinic. (GH-19360)Serhiy Storchaka2020-04-181-124/+157
| | | | | Convert os.getgrouplist(), os.initgroups(), os.sendfile() and os.get_terminal_size().
* bpo-40268: Reformat posixmodule.c includes (GH-19536)Victor Stinner2020-04-151-172/+166
|
* bpo-40268: Remove unused osdefs.h includes (GH-19532)Victor Stinner2020-04-151-3/+3
| | | When the include is needed, add required symbol in a comment.
* bpo-40268: Remove unused structmember.h includes (GH-19530)Victor Stinner2020-04-151-4/+4
| | | | | | If only offsetof() is needed: include stddef.h instead. When structmember.h is used, add a comment explaining that PyMemberDef is used.
* bpo-40268: Remove explicit pythread.h includes (#19529)Victor Stinner2020-04-151-1/+0
| | | | Remove explicit pythread.h includes: it is always included by Python.h.
* bpo-40268: Remove a few pycore_pystate.h includes (GH-19510)Victor Stinner2020-04-141-1/+1
|
* bpo-40268: Rename _PyInterpreterState_GET_UNSAFE() (GH-19509)Victor Stinner2020-04-141-7/+7
| | | | | | | Rename _PyInterpreterState_GET_UNSAFE() to _PyInterpreterState_GET() for consistency with _PyThreadState_GET() and to have a shorter name (help to fit into 80 columns). Add also "assert(tstate != NULL);" to the function.
* bpo-39481: Make os.DirEntry generic (GH-19415)Batuhan Taşkaya2020-04-071-0/+2
|
* bpo-40089: Add _at_fork_reinit() method to locks (GH-19195)Victor Stinner2020-04-071-1/+2
| | | | | | | | | | | | | | | Add a private _at_fork_reinit() method to _thread.Lock, _thread.RLock, threading.RLock and threading.Condition classes: reinitialize the lock after fork in the child process; reset the lock to the unlocked state. Rename also the private _reset_internal_locks() method of threading.Event to _at_fork_reinit(). * Add _PyThread_at_fork_reinit() private function. It is excluded from the limited C API. * threading.Thread._reset_internal_locks() now calls _at_fork_reinit() on self._tstate_lock rather than creating a new Python lock object.
* bpo-40190: Add support for _SC_AIX_REALMEM in sysconf (GH-19380)Batuhan Taşkaya2020-04-051-0/+3
|
* bpo-40094: Add os.waitstatus_to_exitcode() (GH-19201)Victor Stinner2020-04-011-0/+79
| | | | | | | | | | | | | | Add os.waitstatus_to_exitcode() function to convert a wait status to an exitcode. Suggest waitstatus_to_exitcode() usage in the documentation when appropriate. Use waitstatus_to_exitcode() in: * multiprocessing, os, subprocess and _bootsubprocess modules; * test.support.wait_process(); * setup.py: run_command(); * and many tests.
* bpo-40014: Fix os.getgrouplist() (GH-19126)Victor Stinner2020-03-241-22/+25
| | | | | | | | Fix os.getgrouplist(): if getgrouplist() function fails because the group list is too small, retry with a larger group list. On failure, the glibc implementation of getgrouplist() sets ngroups to the total number of groups. For other implementations, double the group list size.
* bpo-40014: Fix os.getgrouplist() on macOS (GH-19118)Victor Stinner2020-03-231-0/+19
| | | | | On macOS, getgrouplist() returns a non-zero value without setting errno if the group list is too small. Double the list size and call it again in this case.
* bpo-39968: Convert extension modules' macros of get_module_state() to inline ↵Hai Shi2020-03-161-43/+50
| | | | functions (GH-19017)
* bpo-39947: Use _PyInterpreterState_GET_UNSAFE() (GH-18978)Victor Stinner2020-03-131-7/+7
| | | | | | | Replace _PyInterpreterState_Get() function call with _PyInterpreterState_GET_UNSAFE() macro which is more efficient but don't check if tstate or interp is NULL. _Py_GetConfigsAsDict() now uses _PyThreadState_GET().
* bpo-39573: Use Py_IS_TYPE() macro to check for types (GH-18809)Andy Lester2020-03-061-2/+1
| | | Co-authored-by: Victor Stinner <vstinner@python.org>
* bpo-39184: Add audit events to functions in `fcntl`, `msvcrt`, `os`, ↵Saiyang Gou2020-02-131-17/+134
| | | | `resource`, `shutil`, `signal`, `syslog` (GH-18407)