summaryrefslogtreecommitdiffstats
path: root/Lib
Commit message (Collapse)AuthorAgeFilesLines
* GH-127236: `pathname2url()`: generate RFC 1738 URL for absolute POSIX path ↵Barney Gale2024-11-253-16/+22
| | | | | | | | | | | | | | | (#127194) When handed an absolute Windows path such as `C:\foo` or `//server/share`, the `urllib.request.pathname2url()` function returns a URL with an authority section, such as `///C:/foo` or `//server/share` (or before GH-126205, `////server/share`). Only the `file:` prefix is omitted. But when handed an absolute POSIX path such as `/etc/hosts`, or a Windows path of the same form (rooted but lacking a drive), the function returns a URL without an authority section, such as `/etc/hosts`. This patch corrects the discrepancy by adding a `//` prefix before drive-less, rooted paths when generating URLs.
* gh-127182: Fix `io.StringIO.__setstate__` crash when `None` is the first ↵sobolevn2024-11-251-0/+15
| | | | | value (#127219) Co-authored-by: Victor Stinner <vstinner@python.org>
* gh-127183: Add `_ctypes.CopyComPointer` tests (GH-127184)Jun Komoda2024-11-251-17/+115
| | | | | | | | | | | * Make `create_shelllink_persist` top level function. * Add `CopyComPointerTests`. * Add more tests. * Update tests. * Add assertions for `Release`'s return value.
* gh-127217: Fix pathname2url() for paths starting with multiple slashes on ↵Serhiy Storchaka2024-11-242-0/+7
| | | | Posix (GH-127218)
* gh-122356: restore the position of a file-like object after ↵Bénédikt Tran2024-11-242-2/+10
| | | | `zipfile.is_zipfile` (#122397)
* GH-127133: Remove ability to nest argument groups & mutually exclusive ↵Savannah Ostrowski2024-11-242-85/+18
| | | | groups (#127186)
* gh-113841: fix possible undefined division by 0 in _Py_c_pow() (GH-127211)Sergey B Kirpichev2024-11-241-0/+5
| | | `x**y == 1/x**-y ` thus changing `/=` to `*=` by negating the exponent.
* gh-126662: harmonize naming for three namedtuple base classes in ↵Stephen Morton2024-11-241-3/+3
| | | | | urllib.parse (GH-126663) harmonize naming for three namedtuple base classes in urllib.parse
* pathlib tests: move `walk()` tests into their own classes (GH-126651)Barney Gale2024-11-242-84/+107
| | | Move tests for Path.walk() into a new PathWalkTest class, and apply a similar change in tests for the ABCs. This allows us to properly tear down the walk test hierarchy in tearDown(), rather than leaving it to os_helper.rmtree().
* GH-125866: Preserve Windows drive letter case in file URIs (#127138)Barney Gale2024-11-232-2/+4
| | | | | Stop converting Windows drive letters to uppercase in `urllib.request.pathname2url()` and `url2pathname()`. This behaviour is unnecessary and inconsistent with pathlib's file URI implementation.
* gh-109746: Make _thread.start_new_thread delete state of new thread on its ↵Radislav Chugunov2024-11-221-0/+34
| | | | | | | | | | startup failure (GH-109761) If Python fails to start newly created thread due to failure of underlying PyThread_start_new_thread() call, its state should be removed from interpreter' thread states list to avoid its double cleanup. Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* gh-115999: Add free-threaded specialization for `UNPACK_SEQUENCE` (#126600)Kirill Podoprigora2024-11-221-0/+31
| | | | | | | | | | | Add free-threaded specialization for `UNPACK_SEQUENCE` opcode. `UNPACK_SEQUENCE_TUPLE/UNPACK_SEQUENCE_TWO_TUPLE` are already thread safe since tuples are immutable. `UNPACK_SEQUENCE_LIST` is not thread safe because of nature of lists (there is nothing preventing another thread from adding items to or removing them the list while the instruction is executing). To achieve thread safety we add a critical section to the implementation of `UNPACK_SEQUENCE_LIST`, especially around the parts where we check the size of the list and push items onto the stack. --------- Co-authored-by: Matt Page <mpage@meta.com> Co-authored-by: mpage <mpage@cs.stanford.edu>
* gh-88110: Clear concurrent.futures.thread._threads_queues after fork to ↵Andrei Bodrov2024-11-222-0/+20
| | | | | | | | | avoid joining parent process' threads (GH-126098) Threads are gone after fork, so clear the queues too. Otherwise the child process (here created via multiprocessing.Process) crashes on interpreter exit. Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* gh-126384: Add tests to verify the behavior of basic COM methods. (GH-126610)Jun Komoda2024-11-221-0/+188
|
* gh-109413: Fix libregrtest get_running() (#127153)Victor Stinner2024-11-221-1/+1
| | | Skip threads which are not running.
* gh-127001: Fix PATHEXT issues in shutil.which() on Windows (GH-127035)Serhiy Storchaka2024-11-222-242/+299
| | | | | | | | | * Name without a PATHEXT extension is only searched if the mode does not include X_OK. * Support multi-component PATHEXT extensions (e.g. ".foo.bar"). * Support files without extensions in PATHEXT contains dot-only extension (".", "..", etc). * Support PATHEXT extensions that end with a dot (e.g. ".foo.").
* gh-86463: Fix default prog in subparsers if usage is used in the main parser ↵Serhiy Storchaka2024-11-222-5/+48
| | | | | | | | | | (GH-125891) The usage parameter of argparse.ArgumentParser no longer affects the default value of the prog parameter in subparsers. Previously the full custom usage of the main parser was used as the prog prefix in subparsers.
* gh-127076: Ignore memory mmap in FileIO testing (#127088)Cody Maloney2024-11-222-7/+35
| | | | | | | | | | | | | `mmap`, `munmap`, and `mprotect` are used by CPython for memory management, which may occur in the middle of the FileIO tests. The system calls can also be used with files, so `strace` includes them in its `%file` and `%desc` filters. Filter out the `mmap` system calls related to memory allocation for the file tests. Currently FileIO doesn't do `mmap` at all, so didn't add code to track from `mmap` through `munmap` since it wouldn't be used. For now if an `mmap` on a fd happens, the call will be included (which may cause test to fail), and at that time support for tracking the address throug `munmap` could be added.
* gh-126700: pygettext: Support more gettext functions (GH-126912)Tomas R.2024-11-225-17/+88
| | | | Support multi-argument gettext functions: ngettext(), pgettext(), dgettext(), etc.
* GH-127078: `url2pathname()`: handle extra slash before UNC drive in URL path ↵Barney Gale2024-11-222-1/+4
| | | | | | | (#127132) Decode a file URI like `file://///server/share` as a UNC path like `\\server\share`. This form of file URI is created by software the simply prepends `file:///` to any absolute Windows path.
* GH-126766: `url2pathname()`: handle 'localhost' authority (#127129)Barney Gale2024-11-223-5/+13
| | | | | Discard any 'localhost' authority from the beginning of a `file:` URI. As a result, file URIs like `//localhost/etc/hosts` are correctly decoded as `/etc/hosts`.
* GH-126601: `pathname2url()`: handle NTFS alternate data streams (#126760)Barney Gale2024-11-222-14/+13
| | | | | | Adjust `pathname2url()` to encode embedded colon characters in Windows paths, rather than bailing out with an `OSError`. Co-authored-by: Steve Dower <steve.dower@microsoft.com>
* gh-126091: Always link generator frames when propagating a thrown-in ↵Jacob Bower2024-11-211-1/+21
| | | | | exception through a yield-from chain (#126092) Always link generator frames when propagating a thrown-in exception through a yield-from chain.
* gh-115999: Add free-threaded specialization for ``TO_BOOL`` (gh-126616)Donghee Na2024-11-211-0/+66
|
* gh-115999: Specialize `LOAD_GLOBAL` in free-threaded builds (#126607)mpage2024-11-211-1/+18
| | | | | | | | | | | | | | Enable specialization of LOAD_GLOBAL in free-threaded builds. Thread-safety of specialization in free-threaded builds is provided by the following: A critical section is held on both the globals and builtins objects during specialization. This ensures we get an atomic view of both builtins and globals during specialization. Generation of new keys versions is made atomic in free-threaded builds. Existing helpers are used to atomically modify the opcode. Thread-safety of specialized instructions in free-threaded builds is provided by the following: Relaxed atomics are used when loading and storing dict keys versions. This avoids potential data races as the dict keys versions are read without holding the dictionary's per-object lock in version guards. Dicts keys objects are passed from keys version guards to the downstream uops. This ensures that we are loading from the correct offset in the keys object. Once a unicode key has been stored in a keys object for a combined dictionary in free-threaded builds, the offset that it is stored in will never be reused for a different key. Once the version guard passes, we know that we are reading from the correct offset. The dictionary read fast-path is used to read values from the dictionary once we know the correct offset.
* gh-124470: Fix crash when reading from object instance dictionary while ↵Dino Viehland2024-11-211-0/+64
| | | | | replacing it (#122489) Delay free a dictionary when replacing it
* gh-127020: Make `PyCode_GetCode` thread-safe for free threading (#127043)Sam Gross2024-11-211-0/+30
| | | | Some fields in PyCodeObject are lazily initialized. Use atomics and critical sections to make their initializations and accesses thread-safe.
* gh-118761: Improve import time of `mimetypes` (#126979)Hugo van Kemenade2024-11-211-6/+16
|
* gh-124873: Tolerate 100 ms in TimerfdTests on Android (#127101)Victor Stinner2024-11-211-2/+2
| | | | On Android, TimerfdTests of test_os now uses 100 ms accuracy instead of 10 ms.
* gh-126780: Fix `ntpath.normpath()` for drive-relative paths (GH-126801)Nice Zombies2024-11-212-0/+7
|
* gh-126727: Fix locale.nl_langinfo(locale.ERA) (GH-126730)Serhiy Storchaka2024-11-211-0/+45
| | | | | It now returns multiple era description segments separated by semicolons. Previously it only returned the first segment on platforms with Glibc.
* gh-126997: Fix support of non-ASCII strings in pickletools (GH-127062)Serhiy Storchaka2024-11-212-4/+89
| | | | | * Fix support of STRING and GLOBAL opcodes with non-ASCII arguments. * dis() now outputs non-ASCII bytes in STRING, BINSTRING and SHORT_BINSTRING arguments as escaped (\xXX).
* gh-127076: Disable strace tests under LD_PRELOAD (#127086)Cody Maloney2024-11-211-0/+8
| | | | | | | | Distribution tooling (ex. sandbox on Gentoo and fakeroot on Debian) uses LD_PRELOAD to intercept system calls and potentially modify them when building. These tools can change the set of system calls, so disable system call testing under these cases. Co-authored-by: Michał Górny <mgorny@gentoo.org>
* GH-127010: Don't lazily track and untrack dicts (GH-127027)Mark Shannon2024-11-201-109/+0
|
* gh-97514: Authenticate the forkserver control socket. (GH-99309)Gregory P. Smith2024-11-204-16/+126
| | | | | | | | | | | | | | | | | | | This adds authentication to the forkserver control socket. In the past only filesystem permissions protected this socket from code injection into the forkserver process by limiting access to the same UID, which didn't exist when Linux abstract namespace sockets were used (see issue) meaning that any process in the same system network namespace could inject code. We've since stopped using abstract namespace sockets by default, but protecting our control sockets regardless of type is a good idea. This reuses the HMAC based shared key auth already used by `multiprocessing.connection` sockets for other purposes. Doing this is useful so that filesystem permissions are not relied upon and trust isn't implied by default between all processes running as the same UID with access to the unix socket. ### pyperformance benchmarks No significant changes. Including `concurrent_imap` which exercises `multiprocessing.Pool.imap` in that suite. ### Microbenchmarks This does _slightly_ slow down forkserver use. How much so appears to depend on the platform. Modern platforms and simple platforms are less impacted. This PR adds additional IPC round trips to the control socket to tell forkserver to spawn a new process. Systems with potentially high latency IPC are naturally impacted more. Typically a 1-4% slowdown on a very targeted process creation microbenchmark, with a worst case overloaded system slowdown of 20%. No evidence that these slowdowns appear in practical sense. See the PR for details.
* GH-126892: Reset warmup counters when JIT compiling code (GH-126893)Brandt Bucher2024-11-202-29/+26
|
* gh-126991: Add tests for unpickling bad object state (GH-127031)Serhiy Storchaka2024-11-201-0/+35
| | | This catches a memory leak in loading the BUILD opcode.
* gh-126615: `ctypes`: Make `COMError` public (GH-126686)Jun Komoda2024-11-202-4/+5
| | | Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
* GH-85168: Use filesystem encoding when converting to/from `file` URIs (#126852)Barney Gale2024-11-193-10/+22
| | | | | | | | Adjust `urllib.request.url2pathname()` and `pathname2url()` to use the filesystem encoding when quoting and unquoting file URIs, rather than forcing use of UTF-8. No changes are needed in the `nturl2path` module because Windows always uses UTF-8, per PEP 529.
* Merge remote-tracking branch 'upstream/main'Hugo van Kemenade2024-11-1911-11/+101
|\
| * gh-126914: Store the Preallocated Thread State's Pointer in a ↵Eric Snow2024-11-191-0/+30
| | | | | | | | | | PyInterpreterState Field (gh-126989) This approach eliminates the originally reported race. It also gets rid of the deadlock reported in gh-96071, so we can remove the workaround added then.
| * gh-109413: Enable mypy's `disallow_any_generics` setting when checking ↵sobolevn2024-11-194-4/+7
| | | | | | | | `libregrtest` (#127033)
| * gh-126947: Typechecking for _pydatetime.timedelta.__new__ arguments (#126949)Beomsoo Kim2024-11-192-1/+23
| | | | | | | | Co-authored-by: sobolevn <mail@sobolevn.me> Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
| * gh-118201: Simplify conv_confname (#126089)Malcolm Smith2024-11-193-6/+33
| |
| * gh-126980: Fix `bytearray.__buffer__` crash on `PyBUF_{READ,WRITE}` (#126981)sobolevn2024-11-191-0/+8
| | | | | | Co-authored-by: Victor Stinner <vstinner@python.org>
* | Python 3.14.0a2v3.14.0a2Hugo van Kemenade2024-11-191-231/+304
|/
* GH-84850: Remove `urllib.request.URLopener` and `FancyURLopener` (#125739)Barney Gale2024-11-193-862/+33
|
* Revert "GH-126491: GC: Mark objects reachable from roots before doing cycle ↵Hugo van Kemenade2024-11-192-14/+128
| | | | collection (GH-126502)" (#126983)
* gh-126594: Fix typeobject.c wrap_buffer() cast (#126754)Victor Stinner2024-11-191-0/+15
| | | | | Reject flags smaller than INT_MIN. Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* gh-126876: Fix socket internal_select() for large timeout (#126968)Victor Stinner2024-11-191-0/+27
| | | | | | If the timeout is larger than INT_MAX, replace it with INT_MAX, in the poll() code path. Add an unit test.