Commit graph

1284 commits

Author SHA1 Message Date
Victor Stinner
288d6d04ae
[3.12] gh-93312: Include <sys/pidfd.h> to get PIDFD_NONBLOCK (#127593) (#127631)
gh-93312: Include <sys/pidfd.h> to get PIDFD_NONBLOCK (#127593)

(cherry picked from commit fcbe6ecdb6)
2024-12-05 09:59:53 +00:00
Serhiy Storchaka
844d908adb
[3.12] gh-126303: Fix pickling and copying of os.sched_param objects (GH-126336) (GH-126424)
(cherry picked from commit d3840503b0)
2024-11-05 06:52:51 +00:00
Jelle Zijlstra
4ab19f912d
[3.12] gh-124917: Allow keyword args to os.path.exists/lexists on Windows (GH-124918) (#125334)
(cherry picked from commit cc2938a189)
2024-10-11 15:18:46 -07:00
Serhiy Storchaka
39dea212f4
[3.12] gh-121905: Consistently use "floating-point" instead of "floating point" (GH-121907) (GH-122013)
(cherry picked from commit 1a0c7b9ba4)
2024-07-19 09:08:33 +00:00
Miss Islington (bot)
e004914045
[3.12] gh-120586: Fix several "unused function" warnings in posixmodule.c (GH-120588) (#120617)
gh-120586: Fix several "unused function" warnings in `posixmodule.c` (GH-120588)
(cherry picked from commit 3df2022931)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2024-06-17 07:01:15 +00:00
Serhiy Storchaka
f98ec7574a
[3.12] gh-89928: Fix integer conversion of device numbers (GH-31794) (GH-120054)
Fix os.major(), os.minor() and os.makedev().
Support device numbers larger than 2**63-1.
Support non-existent device number (NODEV).
(cherry picked from commit 7111d9605f)
2024-06-04 17:12:13 +00:00
Nice Zombies
09a85eaa4c
gh-118263: Add additional arguments to path_t (Argument Clinic type) in posixmodule (GH-119608) 2024-05-28 11:13:01 +01:00
Nice Zombies
874a4f7d08
gh-118507 : Refactor ntpath native functions (gh-119381)
This refactoring will make future backports easier without changing behaviours,
apart from correcting a bug when passing a pipe to `ntpath.isfile`.
2024-05-22 15:49:26 +01:00
Miss Islington (bot)
6d0850c4c8
gh-118486: Simplify test_win32_mkdir_700 to check the exact ACL (GH-119056)
(cherry picked from commit 94591dca51)

Co-authored-by: Steve Dower <steve.dower@python.org>
2024-05-15 11:21:57 +00:00
Steve Dower
eb29e2f590
gh-118486: Support mkdir(mode=0o700) on Windows (GH-118488) 2024-05-09 19:18:56 +01:00
Miss Islington (bot)
eca377f203
gh-117267: Ensure DirEntry.stat().st_ctime still contains creation time during deprecation period (GH-117354)
(cherry picked from commit 985917dc8d)

Co-authored-by: Steve Dower <steve.dower@python.org>
2024-04-03 22:32:09 +00:00
Sam Gross
92564331de
[3.12] gh-113964: Don't prevent new threads until all non-daemon threads 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 60e105c1c1)
2024-03-19 15:22:42 -04:00
Miss Islington (bot)
d4e8cbbed4
[3.12] gh-116541: Handle errors correctly in _pystatvfs_fromstructstatvfs (GH-116542) (#116643)
gh-116541: Handle errors correctly in `_pystatvfs_fromstructstatvfs` (GH-116542)
(cherry picked from commit f8147d01da)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2024-03-12 10:30:40 +00:00
Miss Islington (bot)
3f92cf272e
[3.12] gh-116520: Fix error handling in os_get_terminal_size_impl in posixmodule (GH-116521) (#116539)
gh-116520: Fix error handling in `os_get_terminal_size_impl` in `posixmodule` (GH-116521)
(cherry picked from commit b4b4e764a7)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2024-03-09 11:36:02 +00:00
Miss Islington (bot)
cbd94fdb6c
[3.12] gh-116448: Handle errors correctly in os_waitid_impl in posixmodule (GH-116449) (#116451)
gh-116448: Handle errors correctly in `os_waitid_impl` in `posixmodule` (GH-116449)
(cherry picked from commit 882fcede83)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2024-03-07 09:03:28 +00:00
Miss Islington (bot)
5c69f60ae1
[3.12] gh-116404: Handle errors correctly in wait_helper in posixmodule (GH-116405) (#116406)
gh-116404: Handle errors correctly in `wait_helper` in `posixmodule` (GH-116405)
(cherry picked from commit 22ccf13b33)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2024-03-06 09:05:45 +00:00
Miss Islington (bot)
7b7cf75c02
gh-111877: Fixes stat() handling for inaccessible files on Windows (GH-113716)
(cherry picked from commit ed066481c7)

Co-authored-by: Steve Dower <steve.dower@python.org>
2024-01-12 15:53:27 +00:00
Miss Islington (bot)
0e3cf5bcac
[3.12] bpo-11102: Make configure enable major(), makedev(), and minor() on HP-UX (GH-19856) (GH-113540)
Always include <sys/types.h> before <sys/sysmacros.h>.

(cherry picked from commit f108468970)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-12-28 11:12:16 +00:00
Miss Islington (bot)
3bd8b74330
[3.12] gh-111841: Fix os.putenv() and os.unsetenv() with embedded NUL on Windows (GH-111842) (GH-111966)
(cherry picked from commit 0b06d2482d)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-11-11 08:02:08 +00:00
Brett Cannon
5a8e6f8bcc
[3.12] GH-111804: Drop posix.fallocate() under WASI (GH-111869) (GH-111919)
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.
2023-11-09 15:35:51 -08:00
Miss Islington (bot)
e25d8b40cd
GH-111293: Fix DirEntry.inode dropping higher bits on Windows (GH-111294)
(cherry picked from commit b468538d35)

Co-authored-by: zcxsythenew <30565051+zcxsythenew@users.noreply.github.com>
2023-10-26 17:08:41 +00:00
Alex Waygood
da75bd6c31
[3.12] gh-109782: Ensure os.path.isdir has the same signature on all 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>
2023-10-02 19:25:06 +00:00
Miss Islington (bot)
47e96c6782
[3.12] gh-109613: _pystat_fromstructstat() checks for exceptions (GH-109618) (#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 d4cea794a7)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-10-02 17:09:45 +02:00
Miss Islington (bot)
3e20303717
[3.12] gh-107913: Fix possible losses of OSError error codes (GH-107930) (#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 2b15536fa9)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-08-27 01:24:40 +02:00
Erlend E. Aasland
41634edb2b
[3.12] gh-107801: Improve the accuracy of os.lseek docs (#107935) (#108136)
- 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 dd4442c8f5)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2023-08-20 01:05:00 +02:00
Steve Dower
ede9895881
[3.12] gh-106242: Fix path truncation in os.path.normpath (GH-106816) (#107981)
* 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>
2023-08-17 01:19:48 +02:00
justdan6
80aebd54c8
[3.12] gh-106881: Check for linux/limits.h before including it (#107397) (#107414)
* Check for linux/limits.h before including it

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
(cherry picked from commit 11c055f5ff)
2023-07-28 16:29:31 -07:00
Serhiy Storchaka
a423ddbdea
[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 3e65baee72)
2023-07-18 15:14:10 +03:00
Serhiy Storchaka
970cb8eaba
[3.12] gh-86493: Fix possible leaks in modules initialization: _curses_panel, _decimal, posix, xxsubtype (GH-106767) (#106849)
(cherry picked from commit 745492355b)
2023-07-18 10:03:59 +03:00
Miss Islington (bot)
c14f6ea7e4
[3.12] gh-105375: Improve posix error handling (GH-105592) (#105598)
Fix a bug where an IndexError could end up being overwritten.
(cherry picked from commit f668f73bc8)

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2023-06-11 21:33:30 +02:00
Miss Islington (bot)
c7a9d96a25
[3.12] gh-104690 Disallow thread creation and fork at interpreter 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 ce558e69d4)

Co-authored-by: chgnrdv <52372310+chgnrdv@users.noreply.github.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-06-04 04:32:00 +00:00
Miss Islington (bot)
68bf3fe0e4
gh-104820: Fixes os.stat on Windows to better handle file systems that do not support FileIdInformation (GH-104892)
(cherry picked from commit 6031727a37)

Co-authored-by: Steve Dower <steve.dower@python.org>
2023-05-29 17:57:04 +01:00
Miss Islington (bot)
635ce29257
gh-104803: Implement ntpath.isdevdrive for checking whether a path is on a Windows Dev Drive (GH-104805)
(cherry picked from commit bfd20d257e)

Co-authored-by: Steve Dower <steve.dower@python.org>
2023-05-29 13:36:08 +01:00
Ronald Oussoren
616fcad6e2
GH-103545: Add macOS specific constants for `os.setpriority to os` (#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>
2023-05-19 09:15:11 +02:00
Eric Snow
a9c6e0618f
gh-99113: Add Py_MOD_PER_INTERPRETER_GIL_SUPPORTED (gh-104205)
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).
2023-05-05 21:11:27 +00:00
Dong-hee Na
e5b8b19d99
gh-104106: Add gcc fallback of mkfifoat/mknodat for macOS (gh-104129) 2023-05-05 12:27:25 +09:00
Finn Womack
b701dce340
gh-102765: Update ntpath.isdir/isfile/islink/exists to use GetFileInformationByName when available (GH-103485) 2023-04-27 14:23:26 +00:00
Nikita Sobolev
119f67de08
gh-103167: Fix -Wstrict-prototypes warnings by using (void) for functions with no args (GH-103168) 2023-04-05 09:22:33 +02:00
Steve Dower
0f175766e2
gh-99726: Improves correctness of stat results for Windows, and uses faster 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.
2023-03-16 17:27:21 +00:00
Steve Dower
cb35882773
gh-102519: Add os.listdrives, os.listvolumes and os.listmounts on Windows (GH-102544) 2023-03-10 12:21:37 +00:00
Max Bachmann
c6858d1e7f
gh-102255: Improve build support for Windows API partitions (GH-102256)
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.
2023-03-09 21:09:12 +00:00
Eric Snow
cf6e7c5e55
gh-100227: Isolate the Import State to Each Interpreter (gh-101941)
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
2023-03-09 09:46:21 -07:00
Alexey Izbyshev
c2bd55d26f
gh-102179: Fix os.dup2 error reporting for negative fds (#102180) 2023-03-04 19:54:08 +05:30
Max Bachmann
938e36f824
gh-102336: Remove code specifically for handling Windows 7 (GH-102337) 2023-03-01 00:31:21 +00:00
Irit Katriel
2db23d10bf
gh-102192: Replace PyErr_Fetch/Restore etc by more efficient alternatives (in Modules/) (#102196) 2023-02-24 21:43:03 +00:00
Max Bachmann
1fa38906f0
gh-102141: replace use of getpid on Windows with GetCurrentProcessId (GH-102142) 2023-02-24 12:38:21 +00:00
Rayyan Ansari
739c026f44
gh-101881: Support (non-)blocking read/write functions on Windows pipes (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.
2023-02-16 14:52:24 +00:00
Sam James
8be8101bca
gh-101857: Allow xattr detection on musl libc (#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

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-02-13 23:21:58 -08:00
Michael Droettboom
86ebd5c3fa
gh-101196: Make isdir/isfile/exists faster on Windows (GH-101324)
Co-authored-by: Eryk Sun <eryksun@gmail.com>
2023-02-08 14:34:24 +00:00
Eric Snow
6036c3e856
gh-59956: Clarify GILState-related Code (gh-101161)
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
2023-01-19 16:04:14 -07:00