]> git.ipfire.org Git - thirdparty/Python/cpython.git/log
thirdparty/Python/cpython.git
10 months agogh-127353: Allow to force color output on Windows (#127354)
Andrey Efremov [Thu, 12 Dec 2024 20:17:39 +0000 (03:17 +0700)] 
gh-127353: Allow to force color output on Windows (#127354)

10 months agogh-127865: Fix build failure for systems without thread local support (GH-127866)
velemas [Thu, 12 Dec 2024 18:07:55 +0000 (20:07 +0200)] 
gh-127865: Fix build failure for systems without thread local support (GH-127866)

This PR fixes the build issue introduced by the commit 628f6eb from
GH-112207 on systems without thread local support.

10 months agogh-127879: Fix data race in `_PyFreeList_Push` (#127880)
Sam Gross [Thu, 12 Dec 2024 17:59:13 +0000 (17:59 +0000)] 
gh-127879: Fix data race in `_PyFreeList_Push` (#127880)

Writes to the `ob_tid` field need to use atomics because it may be
concurrently read by a non-locking dictionary, list, or structmember
read.

10 months agoGH-127807: pathlib ABCs: remove `PathBase._unsupported_msg()` (#127855)
Barney Gale [Thu, 12 Dec 2024 17:39:24 +0000 (17:39 +0000)] 
GH-127807: pathlib ABCs: remove `PathBase._unsupported_msg()` (#127855)

This method helped us customise the `UnsupportedOperation` message
depending on the type. But we're aiming to make `PathBase` a proper ABC
soon, so `NotImplementedError` is the right exception to raise there.

10 months agoGH-125174: Fix compiler warning (GH-127860)
Mark Shannon [Thu, 12 Dec 2024 11:22:20 +0000 (11:22 +0000)] 
GH-125174: Fix compiler warning (GH-127860)

Fix compiler warning

10 months agoGH-127381: pathlib ABCs: remove remaining uncommon `PathBase` methods (#127714)
Barney Gale [Thu, 12 Dec 2024 06:49:34 +0000 (06:49 +0000)] 
GH-127381: pathlib ABCs: remove remaining uncommon `PathBase` methods (#127714)

Remove the following methods from `pathlib._abc.PathBase`:

- `expanduser()`
- `hardlink_to()`
- `touch()`
- `chmod()`
- `lchmod()`
- `owner()`
- `group()`
- `from_uri()`
- `as_uri()`

These operations aren't regularly supported in virtual filesystems, so they
don't win a place in the `PathBase` interface. (Some of them probably don't
deserve a place in `Path` :P.) They're quasi-abstract (except `lchmod()`),
and they're not called by other `PathBase` methods.

10 months agoSimplify and speed-up an itertools recipe (gh-127848)
Raymond Hettinger [Thu, 12 Dec 2024 03:24:56 +0000 (21:24 -0600)] 
Simplify and speed-up an itertools recipe (gh-127848)

10 months agogh-127740: Add some more tests for earlier PR #127756 (#127818)
Srinivas Reddy Thatiparthy (తాటిపర్తి శ్రీనివాస్ రెడ్డి) [Thu, 12 Dec 2024 02:18:12 +0000 (07:48 +0530)] 
gh-127740: Add some more tests for earlier PR #127756 (#127818)

10 months agogh-127146: Some expected failures in Emscripten time tests (#127843)
Hood Chatham [Thu, 12 Dec 2024 01:11:00 +0000 (02:11 +0100)] 
gh-127146: Some expected failures in Emscripten time tests (#127843)

Disables two tests in the test_time suite, and adjusts test_os to reflect
precision limits in Emscripten.

10 months agogh-115999: Specialize `CALL_KW` in free-threaded builds (#127713)
mpage [Wed, 11 Dec 2024 23:18:22 +0000 (15:18 -0800)] 
gh-115999: Specialize `CALL_KW` in free-threaded builds (#127713)

* Enable specialization of CALL_KW

* Fix bug pushing frame in _PY_FRAME_KW

`_PY_FRAME_KW` pushes a pointer to the new frame onto the stack for
consumption by the next uop. When pushing the frame fails, we do not
want to push the result, `NULL`, to the stack because it is not
a valid stackref. This works in the default build because `PyStackRef_NULL`
 and `NULL` are the same value, so the `PyStackRef_XCLOSE()` in the error
handler ignores it. In the free-threaded build the values are not the same;
`PyStackRef_XCLOSE()` will attempt to decref a null pointer.

10 months agogh-111609: Test `end_offset` in SyntaxError subclass (#127830)
Nice Zombies [Wed, 11 Dec 2024 18:32:54 +0000 (19:32 +0100)] 
gh-111609: Test `end_offset` in SyntaxError subclass (#127830)

Test `end_offset` in SyntaxError subclass

10 months agoGH-125174: Mark objects as statically allocated. (#127797)
Mark Shannon [Wed, 11 Dec 2024 17:37:38 +0000 (17:37 +0000)] 
GH-125174: Mark objects as statically allocated. (#127797)

* Set a bit in the unused part of the refcount on 64 bit machines and the free-threaded build.

* Use the top of the refcount range on 32 bit machines

10 months agogh-118915: C API: Document frame locals proxies. (#127720)
Peter Bierma [Wed, 11 Dec 2024 16:28:44 +0000 (11:28 -0500)] 
gh-118915: C API: Document frame locals proxies. (#127720)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
10 months agogh-127065: Make methodcaller thread-safe and re-entrant (GH-127746)
Pieter Eendebak [Wed, 11 Dec 2024 15:06:07 +0000 (16:06 +0100)] 
gh-127065: Make methodcaller thread-safe and re-entrant (GH-127746)

The function `operator.methodcaller` was not thread-safe since the additional
of the vectorcall method in gh-89013. In the free threading build the issue
is easy to trigger, for the normal build harder.

This makes the `methodcaller` safe by:

* Replacing the lazy initialization with initialization in the constructor.
* Using a stack allocated space for the vectorcall arguments and falling back
  to `tp_call` for calls with more than 8 arguments.

10 months agoGH-127058: Make `PySequence_Tuple` safer and probably faster. (#127758)
Mark Shannon [Wed, 11 Dec 2024 14:02:59 +0000 (14:02 +0000)] 
GH-127058: Make `PySequence_Tuple` safer and probably faster. (#127758)

* Use a small buffer, then list when constructing a tuple from an arbitrary sequence.

10 months agogh-123401: Fix http.cookies module to support obsolete RFC 850 date format (#123405)
Nano [Wed, 11 Dec 2024 13:28:19 +0000 (21:28 +0800)] 
gh-123401: Fix http.cookies module to support obsolete RFC 850 date format (#123405)

Co-authored-by: Wulian <1055917385@qq.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
10 months agoCI: Use bash to properly expand variable (#127822)
Hugo van Kemenade [Wed, 11 Dec 2024 12:57:51 +0000 (14:57 +0200)] 
CI: Use bash to properly expand variable (#127822)

10 months agogh-126992: Change pickle code to base 10 for load_long and load_int (GH-127042)
Justin Applegate [Wed, 11 Dec 2024 12:37:59 +0000 (05:37 -0700)] 
gh-126992: Change pickle code to base 10 for load_long and load_int (GH-127042)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
10 months agogh-127791: Fix, document, and test `PyUnstable_AtExit` (#127793)
Peter Bierma [Wed, 11 Dec 2024 11:14:04 +0000 (06:14 -0500)] 
gh-127791: Fix, document, and test `PyUnstable_AtExit` (#127793)

10 months agoAdd `extern "C"` around `PyTraceMalloc_` functions. (#127772)
Peter Hawkins [Wed, 11 Dec 2024 09:27:07 +0000 (04:27 -0500)] 
Add `extern "C"` around `PyTraceMalloc_` functions. (#127772)

Pretty much everything else exported by Python.h has an extern "C"
annotation, yet this header appears to be missing one.

10 months agogh-127740: For odd-length input to bytes.fromhex(...) change the error message to...
Srinivas Reddy Thatiparthy (తాటిపర్తి శ్రీనివాస్ రెడ్డి) [Wed, 11 Dec 2024 07:35:17 +0000 (13:05 +0530)] 
gh-127740: For odd-length input to bytes.fromhex(...) change the error message to  ValueError: fromhex() arg must be of even length (#127756)

10 months agoGH-127381: pathlib ABCs: remove `PathBase.samefile()` and rarer `is_*()` (#127709)
Barney Gale [Wed, 11 Dec 2024 00:09:55 +0000 (00:09 +0000)] 
GH-127381: pathlib ABCs: remove `PathBase.samefile()` and rarer `is_*()` (#127709)

Remove `PathBase.samefile()`, which is fairly specific to the local FS, and
relies on `stat()`, which we're aiming to remove from `PathBase`.

Also remove `PathBase.is_mount()`, `is_junction()`, `is_block_device()`,
`is_char_device()`, `is_fifo()` and `is_socket()`. These rely on POSIX
file type numbers that we're aiming to remove from the `PathBase` API.

10 months agogh-126821: Add versionadded annotation to use_system_logger feature. (#127755)
Russell Keith-Magee [Tue, 10 Dec 2024 21:32:04 +0000 (05:32 +0800)] 
gh-126821: Add versionadded annotation to use_system_logger feature. (#127755)

Add versionadded annotation to use_system_logger feature.

10 months agoDocs: Fix indents in `xmlrpc.client.rst` (#127782)
Yuki Kobayashi [Tue, 10 Dec 2024 17:35:00 +0000 (02:35 +0900)] 
Docs: Fix indents in `xmlrpc.client.rst` (#127782)

10 months agogh-59705: Set OS thread name when Thread.name is changed (#127702)
Victor Stinner [Tue, 10 Dec 2024 16:33:11 +0000 (17:33 +0100)] 
gh-59705: Set OS thread name when Thread.name is changed (#127702)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
10 months agogh-127563: use `dk_log2_index_bytes=3` in empty dicts (GH-127568)
Bénédikt Tran [Tue, 10 Dec 2024 15:58:17 +0000 (16:58 +0100)] 
gh-127563: use `dk_log2_index_bytes=3` in empty dicts (GH-127568)

This fixes a UBSan failure (unaligned zero-size memcpy) in `dictobject.c`.

10 months agogh-126937: ctypes: fix TypeError when a field's size is >65535 bytes (GH-126938)
Melissa0x1f992 [Tue, 10 Dec 2024 12:13:11 +0000 (06:13 -0600)] 
gh-126937: ctypes: fix TypeError when a field's size is >65535 bytes (GH-126938)

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
10 months agogh-127257: ssl: Raise OSError for ERR_LIB_SYS (GH-127361)
Petr Viktorin [Tue, 10 Dec 2024 10:56:24 +0000 (11:56 +0100)] 
gh-127257: ssl: Raise OSError for ERR_LIB_SYS (GH-127361)

From the ERR_raise manpage:

    ERR_LIB_SYS

        This "library code" indicates that a system error is
        being reported.  In this case, the reason code given
        to `ERR_raise()` and `ERR_raise_data()` *must* be
        `errno(3)`.

This PR only handles ERR_LIB_SYS for the high-lever error types
SSL_ERROR_SYSCALL and SSL_ERROR_SSL, i.e., not the ones where
OpenSSL indicates it has some more information about the issue.

10 months agogh-126491: Revert "GH-126491: Lower heap size limit with faster marking (GH-127519...
Petr Viktorin [Tue, 10 Dec 2024 10:53:56 +0000 (11:53 +0100)] 
gh-126491: Revert "GH-126491: Lower heap size limit with faster marking (GH-127519)" (GH-127770)

Revert "GH-126491: Lower heap size limit with faster marking (GH-127519)"

This reverts commit 023b7d2141467017abc27de864f3f44677768cb3, which introduced
a refleak.

10 months agoAdd zizmor to pre-commit and fix most findings (#127749)
Hugo van Kemenade [Tue, 10 Dec 2024 10:51:12 +0000 (12:51 +0200)] 
Add zizmor to pre-commit and fix most findings (#127749)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
10 months agogh-101100: Fix sphinx warnings in `whatsnew/3.0.rst` (#127662)
Yuki Kobayashi [Tue, 10 Dec 2024 10:22:37 +0000 (19:22 +0900)] 
gh-101100: Fix sphinx warnings in `whatsnew/3.0.rst` (#127662)

10 months agogh-125420: implement `Sequence.count` API on `memoryview` objects (#125443)
Bénédikt Tran [Tue, 10 Dec 2024 10:12:33 +0000 (11:12 +0100)] 
gh-125420: implement `Sequence.count` API on `memoryview` objects (#125443)

10 months agoadd help blurb for "extralargefile" (#127710)
Skip Montanaro [Tue, 10 Dec 2024 08:17:25 +0000 (02:17 -0600)] 
add help blurb for "extralargefile" (#127710)

10 months agogh-127718: Add colour to `test.regrtest` output (#127719)
Hugo van Kemenade [Tue, 10 Dec 2024 07:44:15 +0000 (09:44 +0200)] 
gh-127718: Add colour to `test.regrtest` output (#127719)

10 months agogh-126775: make linecache.checkcache threadsafe and GC re-entrency safe (#126776)
Thomas Grainger [Tue, 10 Dec 2024 07:40:54 +0000 (07:40 +0000)] 
gh-126775: make linecache.checkcache threadsafe and GC re-entrency safe (#126776)

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Bartosz Sławecki <bartoszpiotrslawecki@gmail.com>
10 months agogh-127651: Use __file__ in diagnostics if origin is missing (#127660)
Shantanu [Tue, 10 Dec 2024 04:55:20 +0000 (20:55 -0800)] 
gh-127651: Use __file__ in diagnostics if origin is missing (#127660)

See the left hand side in https://github.com/python/cpython/pull/123929/files#diff-c22186367cbe20233e843261998dc027ae5f1f8c0d2e778abfa454ae74cc59deL2840-L2849

---------

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
10 months agogh-125420: implement `Sequence.index` API on `memoryview` objects (#125446)
Bénédikt Tran [Tue, 10 Dec 2024 02:48:38 +0000 (03:48 +0100)] 
gh-125420: implement `Sequence.index` API on `memoryview` objects (#125446)

10 months agogh-127629: Add ctypes to the Emscripten build (#127683)
Hood Chatham [Tue, 10 Dec 2024 02:32:58 +0000 (03:32 +0100)] 
gh-127629: Add ctypes to the Emscripten build (#127683)

Adds tooling to build libffi and add ctypes to the stdlib for Emscripten.

10 months agoGH-127456: pathlib ABCs: add protocol for path parser (#127494)
Barney Gale [Mon, 9 Dec 2024 18:31:22 +0000 (18:31 +0000)] 
GH-127456: pathlib ABCs: add protocol for path parser (#127494)

Change the default value of `PurePathBase.parser` from `ParserBase()` to
`posixpath`. As a result, user subclasses of `PurePathBase` and `PathBase`
use POSIX path syntax by default, which is very often desirable.

Move `pathlib._abc.ParserBase` to `pathlib._types.Parser`, and convert it
to a runtime-checkable protocol.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
10 months agogh-127637: add tests for `dis` command-line interface (#127759)
Bénédikt Tran [Mon, 9 Dec 2024 18:02:22 +0000 (19:02 +0100)] 
gh-127637: add tests for `dis` command-line interface (#127759)

10 months agogh-127732: Add Windows Server 2025 detection to platform module (GH-127733)
Wulian [Mon, 9 Dec 2024 12:24:26 +0000 (20:24 +0800)] 
gh-127732: Add Windows Server 2025 detection to platform module (GH-127733)

10 months agogh-126925: Modify how iOS test results are gathered (#127592)
Russell Keith-Magee [Mon, 9 Dec 2024 05:28:57 +0000 (13:28 +0800)] 
gh-126925: Modify how iOS test results are gathered (#127592)

Adds a `use_system_log` config item to enable stdout/stderr redirection for
Apple platforms. This log streaming is then used by a new iOS test runner
script, allowing the display of test suite output at runtime. The iOS test
runner script can be used by any Python project, not just the CPython test
suite.

10 months agogh-127503: Fix realpath handling in emscripten cli (#127632)
Hood Chatham [Mon, 9 Dec 2024 02:03:11 +0000 (03:03 +0100)] 
gh-127503: Fix realpath handling in emscripten cli (#127632)

Corrects the handling of realpath on Linux.

10 months agogh-127503 Don't propagate native PATH to Emscripten Python (#127633)
Hood Chatham [Mon, 9 Dec 2024 02:01:37 +0000 (03:01 +0100)] 
gh-127503 Don't propagate native PATH to Emscripten Python (#127633)

Modifies the handling of PATH to ensure that native executables aren't picked
up when running under node.

10 months agogh-127111: Emscripten Move link flags from `LDFLAGS_NODIST` to `LINKFORSHARED` (...
Hood Chatham [Mon, 9 Dec 2024 01:34:28 +0000 (02:34 +0100)] 
gh-127111: Emscripten Move link flags from `LDFLAGS_NODIST` to `LINKFORSHARED` (#127666)

Corrects the usage of linking flags to avoid compilation errors related to the
use of `-sEXPORTED_FUNCTIONS` when linking shared libraries.

11 months agogh-127734: improve signature of `urllib.request.HTTPPasswordMgrWithPriorAuth.__init__...
Stephen Morton [Sun, 8 Dec 2024 18:46:34 +0000 (10:46 -0800)] 
gh-127734: improve signature of `urllib.request.HTTPPasswordMgrWithPriorAuth.__init__` (#127735)

improve signature of urllib.request.HTTPPasswordMgrWithPriorAuth.__init__

11 months agoGH-127381: pathlib ABCs: remove `PathBase.unlink()` and `rmdir()` (#127736)
Barney Gale [Sun, 8 Dec 2024 18:45:09 +0000 (18:45 +0000)] 
GH-127381: pathlib ABCs: remove `PathBase.unlink()` and `rmdir()` (#127736)

Virtual filesystems don't always make a distinction between deleting files
and empty directories, and sometimes support deleting non-empty directories
in a single operation. Here we remove `PathBase.unlink()` and `rmdir()`,
leaving `_delete()` as the sole deletion method, now made abstract. I hope
to drop the underscore prefix later on.

11 months ago[doc] Fix typos in `interpreter_definition.md` (#127742)
Stan Ulbrych [Sun, 8 Dec 2024 18:01:55 +0000 (18:01 +0000)] 
[doc] Fix typos in `interpreter_definition.md` (#127742)

11 months agogh-87138: convert SHA-3 object type to heap type (GH-127670)
Bénédikt Tran [Sun, 8 Dec 2024 17:31:10 +0000 (18:31 +0100)] 
gh-87138: convert SHA-3 object type to heap type (GH-127670)

11 months agogh-123378: fix post-merge typos in comments and NEWS (#127739)
Bénédikt Tran [Sun, 8 Dec 2024 13:47:22 +0000 (14:47 +0100)] 
gh-123378: fix post-merge typos in comments and NEWS (#127739)

11 months agogh-127610: Added validation for more than one var-positional and var-keyword paramete...
Apostol Fet [Sun, 8 Dec 2024 10:05:15 +0000 (13:05 +0300)] 
gh-127610: Added validation for more than one var-positional and var-keyword parameters in inspect.Signature (GH-127657)

11 months agoGH-126789: fix some sysconfig data on late site initializations (#127729)
Filipe Laíns 🇵🇸 [Sun, 8 Dec 2024 05:57:22 +0000 (05:57 +0000)] 
GH-126789: fix some sysconfig data on late site initializations (#127729)

11 months agoGH-127090: Fix `urllib.response.addinfourl.url` value for opened `file:` URIs (#127091)
Barney Gale [Sat, 7 Dec 2024 17:58:42 +0000 (17:58 +0000)] 
GH-127090: Fix `urllib.response.addinfourl.url` value for opened `file:` URIs (#127091)

The canonical `file:` URL (as generated by `pathname2url()`) is now used as the `url` attribute of the returned `addinfourl` object. The `addinfourl.url` attribute reflects the resolved URL for both `file:` or `http[s]:` URLs now.

11 months agoGive `poplib.POP3.rpop` a proper docstring (#127370)
Stan Ulbrych [Sat, 7 Dec 2024 16:13:49 +0000 (16:13 +0000)] 
Give `poplib.POP3.rpop` a proper docstring (#127370)

Previously `poplib.POP3.rpop` had a "Not sure what this does" docstring, now it has been fixed.

11 months agogh-119786: fix typo in `InternalDocs/garbage_collector.md` (#127687)
Srinivas Reddy Thatiparthy (తాటిపర్తి శ్రీనివాస్ రెడ్డి) [Sat, 7 Dec 2024 10:12:45 +0000 (15:42 +0530)] 
gh-119786: fix typo in `InternalDocs/garbage_collector.md` (#127687)

11 months agoGH-127381: pathlib ABCs: remove `PathBase.resolve()` and `absolute()` (#127707)
Barney Gale [Fri, 6 Dec 2024 21:39:45 +0000 (21:39 +0000)] 
GH-127381: pathlib ABCs: remove `PathBase.resolve()` and `absolute()` (#127707)

Remove our implementation of POSIX path resolution in `PathBase.resolve()`.
This functionality is rather fragile and isn't necessary in most cases. It
depends on `PathBase.stat()`, which we're looking to remove.

Also remove `PathBase.absolute()`. Many legitimate virtual filesystems lack
the notion of a 'current directory', so it's wrong to include in the basic
interface.

11 months agoGH-127652: stop using `--wasi preview2` in `wasi.py` (GH-127704)
Brett Cannon [Fri, 6 Dec 2024 18:42:05 +0000 (10:42 -0800)] 
GH-127652: stop using `--wasi preview2` in `wasi.py` (GH-127704)

It's only to use WASI 0.2 code to back preview1 APIs and is considered experimental anyway.

11 months agoGH-127381: pathlib ABCs: remove `PathBase.rename()` and `replace()` (#127658)
Barney Gale [Fri, 6 Dec 2024 18:10:00 +0000 (18:10 +0000)] 
GH-127381: pathlib ABCs: remove `PathBase.rename()` and `replace()` (#127658)

These methods are obviated by `PathBase.move()`, which can move directories
and supports any `PathBase` object as a target.

11 months agoFix typo in `Lib/_android_support.py` (#127699)
Stan Ulbrych [Fri, 6 Dec 2024 17:50:58 +0000 (17:50 +0000)] 
Fix typo in `Lib/_android_support.py` (#127699)

11 months agogh-119786: Add jit.md. Move adaptive.md to a section of interpreter.md. (#127175)
Irit Katriel [Fri, 6 Dec 2024 16:36:06 +0000 (16:36 +0000)] 
gh-119786: Add jit.md. Move adaptive.md to a section of interpreter.md. (#127175)

11 months agogh-59705: Add _thread.set_name() function (#127338)
Victor Stinner [Fri, 6 Dec 2024 16:27:12 +0000 (17:27 +0100)] 
gh-59705: Add _thread.set_name() function (#127338)

On Linux, threading.Thread now sets the thread name to the operating
system.

* configure now checks if pthread_getname_np()
  and pthread_setname_np() functions are available.
* Add PYTHREAD_NAME_MAXLEN macro.
* Add _thread._NAME_MAXLEN constant for test_threading.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
11 months agogh-127314: Don't mention the GIL when calling without a thread state on the free...
Peter Bierma [Fri, 6 Dec 2024 15:58:19 +0000 (10:58 -0500)] 
gh-127314: Don't mention the GIL when calling without a thread state on the free-threaded build (#127315)

Co-authored-by: Victor Stinner <vstinner@python.org>
11 months agogh-125610: Fix `STORE_ATTR_INSTANCE_VALUE` specialization check (GH-125612)
Sam Gross [Fri, 6 Dec 2024 15:48:24 +0000 (15:48 +0000)] 
gh-125610: Fix `STORE_ATTR_INSTANCE_VALUE` specialization check (GH-125612)

The `STORE_ATTR_INSTANCE_VALUE` opcode doesn't support objects with
non-NULL managed dictionaries, so don't specialize to that op in that case.

11 months agogh-126024: fix UBSan failure in `unicodeobject.c:find_first_nonascii` (GH-127566)
Bénédikt Tran [Fri, 6 Dec 2024 14:31:30 +0000 (15:31 +0100)] 
gh-126024: fix UBSan failure in `unicodeobject.c:find_first_nonascii` (GH-127566)

11 months agogh-101100: amend references starting with `!~` in gh-127054 (#127684)
Yuki Kobayashi [Fri, 6 Dec 2024 14:09:20 +0000 (23:09 +0900)] 
gh-101100: amend references starting with `!~` in gh-127054 (#127684)

11 months agoGH-126491: Lower heap size limit with faster marking (GH-127519)
Mark Shannon [Fri, 6 Dec 2024 10:46:59 +0000 (10:46 +0000)] 
GH-126491: Lower heap size limit with faster marking (GH-127519)

* Faster marking of reachable objects

* Changes calculation of work to do and work done.

* Merges transitive closure calculations

11 months agogh-120010: Fix invalid (nan+nanj) results in _Py_c_prod() (GH-120287)
Sergey B Kirpichev [Fri, 6 Dec 2024 10:28:32 +0000 (13:28 +0300)] 
gh-120010: Fix invalid (nan+nanj) results in _Py_c_prod() (GH-120287)

In some cases, previously computed as (nan+nanj), we could recover
meaningful component values in the result, see e.g. the C11, Annex
G.5.1, routine _Cmultd():

>>> z = 1e300+1j
>>> z*(nan+infj)  # was (nan+nanj)
(-inf+infj)

That also fix some complex powers for small integer exponents, computed
with optimized algorithm (by squaring):

>>> z**5  # was (nan+nanj)
Traceback (most recent call last):
  File "<python-input-1>", line 1, in <module>
    z**5
    ~^^~
OverflowError: complex exponentiation

11 months agogh-127655: Ensure `_SelectorSocketTransport.writelines` pauses the protocol if needed...
J. Nick Koston [Fri, 6 Dec 2024 04:33:03 +0000 (22:33 -0600)] 
gh-127655: Ensure `_SelectorSocketTransport.writelines` pauses the protocol if needed (#127656)

Ensure `_SelectorSocketTransport.writelines` pauses the protocol if it reaches the high water mark as needed.

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
11 months agogh-127627: Add `posix._emscripten_debugger` function (#127628)
Hood Chatham [Fri, 6 Dec 2024 02:47:51 +0000 (03:47 +0100)] 
gh-127627: Add `posix._emscripten_debugger` function (#127628)

Add a posix._emscripten_debugger function to add an emscripten breakpoint.

11 months agoGH-125413: Revert addition of `pathlib.Path.scandir()` method (#127377)
Barney Gale [Thu, 5 Dec 2024 21:39:43 +0000 (21:39 +0000)] 
GH-125413: Revert addition of `pathlib.Path.scandir()` method (#127377)

Remove documentation for `pathlib.Path.scandir()`, and rename the method to
`_scandir()`. In the private pathlib ABCs, make `iterdir()` abstract and
call it from `_scandir()`.

It's not worthwhile to add this method at the moment - see discussion:
https://discuss.python.org/t/ergonomics-of-new-pathlib-path-scandir/71721

Co-authored-by: Steve Dower <steve.dower@microsoft.com>
11 months agogh-127582: Make object resurrection thread-safe for free threading. (GH-127612)
Sam Gross [Thu, 5 Dec 2024 21:07:31 +0000 (21:07 +0000)] 
gh-127582: Make object resurrection thread-safe for free threading. (GH-127612)

Objects may be temporarily "resurrected" in destructors when calling
finalizers or watcher callbacks. We previously undid the resurrection
by decrementing the reference count using `Py_SET_REFCNT`. This was not
thread-safe because other threads might be accessing the object
(modifying its reference count) if it was exposed by the finalizer,
watcher callback, or temporarily accessed by a racy dictionary or list
access.

This adds internal-only thread-safe functions for temporary object
resurrection during destructors.

11 months ago[Docs] GDB howto: Fix block type of a cast example (#127621)
Maciej Olko [Thu, 5 Dec 2024 20:52:58 +0000 (21:52 +0100)] 
[Docs] GDB howto: Fix block type of a cast example (#127621)

11 months agogh-127221: Add colour to unittest output (#127223)
Hugo van Kemenade [Thu, 5 Dec 2024 19:10:46 +0000 (21:10 +0200)] 
gh-127221: Add colour to unittest output (#127223)

Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
11 months agoGH-126727: Fix test_era_nl_langinfo with Japanese ERAs on Solaris (GH-127327)
Jakub Kulík [Thu, 5 Dec 2024 18:43:19 +0000 (19:43 +0100)] 
GH-126727: Fix test_era_nl_langinfo with Japanese ERAs on Solaris (GH-127327)

Fix test_era_nl_langinfo with Japanese ERAs on Solaris

11 months agogh-122431: Disallow negative values in `readline.append_history_file` (#122469)
Peter Bierma [Thu, 5 Dec 2024 16:07:38 +0000 (11:07 -0500)] 
gh-122431: Disallow negative values in `readline.append_history_file` (#122469)

Co-authored-by: Victor Stinner <vstinner@python.org>
11 months agogh-127413: allow to show specialized bytecode via `dis` CLI (#127414)
Bénédikt Tran [Thu, 5 Dec 2024 15:01:59 +0000 (16:01 +0100)] 
gh-127413: allow to show specialized bytecode via `dis` CLI (#127414)

11 months agogh-93312: Include <sys/pidfd.h> to get PIDFD_NONBLOCK (#127593)
Victor Stinner [Thu, 5 Dec 2024 09:39:44 +0000 (10:39 +0100)] 
gh-93312: Include <sys/pidfd.h> to get PIDFD_NONBLOCK (#127593)

11 months agogh-119182: Complete PyUnicodeWriter documentation (#127607)
Victor Stinner [Thu, 5 Dec 2024 09:37:14 +0000 (10:37 +0100)] 
gh-119182: Complete PyUnicodeWriter documentation (#127607)

11 months agogh-127434: Fix iOS `xcrun --sdk` clang/ar scripts to allow arguments with spaces...
Feodor Fitsner [Thu, 5 Dec 2024 03:00:20 +0000 (19:00 -0800)] 
gh-127434: Fix iOS `xcrun --sdk` clang/ar scripts to allow arguments with spaces (#127575)

Added shell escaping to ensure iOS compiler shims can accept arguments with spaces.

11 months agogh-127503: Emscripten make Python.sh function as proper Python CLI (#127506)
Hood Chatham [Thu, 5 Dec 2024 00:44:50 +0000 (01:44 +0100)] 
gh-127503: Emscripten make Python.sh function as proper Python CLI (#127506)

Modifies the python.sh script to work on macOS, and adapt to recent emscripten changes.

11 months agogh-127146: Emscripten: Skip segfaults in test suite (#127151)
Hood Chatham [Thu, 5 Dec 2024 00:26:25 +0000 (01:26 +0100)] 
gh-127146: Emscripten: Skip segfaults in test suite (#127151)

Added skips for tests known to cause problems when running on Emscripten.
These mostly relate to the limited stack depth on Emscripten.

11 months agogh-127111: Apply prettier formatter to Emscripten web example (#127551)
Hood Chatham [Thu, 5 Dec 2024 00:25:06 +0000 (01:25 +0100)] 
gh-127111: Apply prettier formatter to Emscripten web example (#127551)

Cleaned up formatting (and a stray closing tag) of the web example HTML and JS.

11 months agoGH-126795: Increase the JIT side-exit threshold from 64 to 4096 (GH-127155)
Brandt Bucher [Wed, 4 Dec 2024 23:01:28 +0000 (15:01 -0800)] 
GH-126795: Increase the JIT side-exit threshold from 64 to 4096 (GH-127155)

11 months agoEnable native AArch64 Ubuntu CI jobs (#127584)
Diego Russo [Wed, 4 Dec 2024 22:12:06 +0000 (22:12 +0000)] 
Enable native AArch64 Ubuntu CI jobs (#127584)

Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
11 months agogh-127536: Add missing locks in listobject.c (GH-127580)
Sam Gross [Wed, 4 Dec 2024 19:12:15 +0000 (19:12 +0000)] 
gh-127536: Add missing locks in listobject.c (GH-127580)

We were missing locks around some list operations in the free threading
build.

11 months agogh-127552: Remove comment questioning 4-digit restriction for ‘Y’ in datetime.strptim...
Beomsoo Kim [Wed, 4 Dec 2024 18:30:51 +0000 (03:30 +0900)] 
gh-127552: Remove comment questioning 4-digit restriction for ‘Y’ in datetime.strptime patterns (#127590)

The code has required 4 digits for the year since its inclusion in the stdlib in 2002 (over 22 years ago as of this commit).

11 months agogh-127481: Add `EPOLLWAKEUP` to the `select` module (GH-127482)
RUANG (James Roy) [Wed, 4 Dec 2024 13:30:38 +0000 (21:30 +0800)] 
gh-127481: Add `EPOLLWAKEUP` to the `select` module (GH-127482)

11 months agogh-123378: Ensure results of `PyUnicode*Error_Get{Start,End}` are clamped (GH-123380)
Bénédikt Tran [Wed, 4 Dec 2024 13:13:52 +0000 (14:13 +0100)] 
gh-123378: Ensure results of `PyUnicode*Error_Get{Start,End}` are clamped (GH-123380)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
11 months agogh-126524: Run `regen-unicodedata` as a part of our CI (#126682)
sobolevn [Wed, 4 Dec 2024 10:01:46 +0000 (13:01 +0300)] 
gh-126524: Run `regen-unicodedata` as a part of our CI (#126682)

11 months agogh-127572: Fix `test_structmembers` initialization (GH-127577)
Sam Gross [Wed, 4 Dec 2024 08:58:22 +0000 (08:58 +0000)] 
gh-127572: Fix `test_structmembers` initialization (GH-127577)

gh-127572: Fix `test_structmembers` initialization.

The 'C' format code expects an `int` as a destination (not a `char`).
This led to test failures on big-endian platforms like s390x. Use the
'c' format code, which expects a `char` as the destination (but requires
a Python byte objects instead of a str).

11 months agoItertool recipe additions (gh-127483)
Raymond Hettinger [Wed, 4 Dec 2024 00:20:01 +0000 (18:20 -0600)] 
Itertool recipe additions (gh-127483)

11 months agogh-127146: Resolve some minor problems in Emscripten tests (#127565)
Hood Chatham [Wed, 4 Dec 2024 00:06:20 +0000 (01:06 +0100)] 
gh-127146: Resolve some minor problems in Emscripten tests (#127565)

Adjusts some Emscripten test exclusions regarding strftime, fma, and stack depth.

11 months agogh-112192: Increase the trace module coverage precision to one decimal (#126972)
RUANG (James Roy) [Tue, 3 Dec 2024 22:33:13 +0000 (06:33 +0800)] 
gh-112192: Increase the trace module coverage precision to one decimal (#126972)

11 months agogh-115999: Enable specialization of `CALL` instructions in free-threaded builds ...
mpage [Tue, 3 Dec 2024 19:20:20 +0000 (11:20 -0800)] 
gh-115999: Enable specialization of `CALL` instructions in free-threaded builds (#127123)

The CALL family of instructions were mostly thread-safe already and only required a small number of changes, which are documented below.

A few changes were needed to make CALL_ALLOC_AND_ENTER_INIT thread-safe:

Added _PyType_LookupRefAndVersion, which returns the type version corresponding to the returned ref.

Added _PyType_CacheInitForSpecialization, which takes an init method and the corresponding type version and only populates the specialization cache if the current type version matches the supplied version. This prevents potentially caching a stale value in free-threaded builds if we race with an update to __init__.

Only cache __init__ functions that are deferred in free-threaded builds. This ensures that the reference to __init__ that is stored in the specialization cache is valid if the type version guard in _CHECK_AND_ALLOCATE_OBJECT passes.
Fix a bug in _CREATE_INIT_FRAME where the frame is pushed to the stack on failure.

A few other miscellaneous changes were also needed:

Use {LOCK,UNLOCK}_OBJECT in LIST_APPEND. This ensures that the list's per-object lock is held while we are appending to it.

Add missing co_tlbc for _Py_InitCleanup.

Stop/start the world around setting the eval frame hook. This allows us to read interp->eval_frame non-atomically and preserves the behavior of _CHECK_PEP_523 documented below.

11 months agogh-127271: Replace use of PyCell_GET/SET (gh-127272)
Neil Schemenauer [Tue, 3 Dec 2024 18:33:06 +0000 (10:33 -0800)] 
gh-127271: Replace use of PyCell_GET/SET (gh-127272)

* Replace uses of `PyCell_GET` and `PyCell_SET`.  These macros are not
  safe to use in the free-threaded build.  Use `PyCell_GetRef()` and
  `PyCell_SetTakeRef()` instead.

* Since `PyCell_GetRef()` returns a strong rather than borrowed ref, some
  code restructuring was required, e.g. `frame_get_var()` returns a strong
  ref now.

* Add critical sections to `PyCell_GET` and `PyCell_SET`.

* Move critical_section.h earlier in the Python.h file.

* Add `PyCell_GET` to the free-threading howto table of APIs that return
  borrowed refs.

* Add additional unit tests for free-threading.

11 months agogh-115999: Add free-threaded specialization for `SEND` (gh-127426)
Neil Schemenauer [Tue, 3 Dec 2024 18:25:12 +0000 (10:25 -0800)] 
gh-115999: Add free-threaded specialization for `SEND` (gh-127426)

No additional thread safety changes are required.  Note that sending to
a generator that is shared between threads is currently not safe in the
free-threaded build.

11 months agogh-127421: Fix race in test_start_new_thread_failed (#127549)
mpage [Tue, 3 Dec 2024 17:50:58 +0000 (09:50 -0800)] 
gh-127421: Fix race in test_start_new_thread_failed (#127549)

Fix race in test_start_new_thread_failed

When we succeed in starting a new thread, for example if setrlimit
was ineffective, we must wait for the newly spawned thread to exit.
Otherwise, we run the risk that the newly spawned thread will race
with runtime finalization and access memory that has already been
clobbered/freed.

`_thread.start_new_thread()` only spawns daemon threads, which the runtime
does not wait for at shutdown, and does not return a handle. Use
`_thread.start_joinable_thread()` and join the resulting handle when
the thread is started successfully.

11 months agogh-115999: Specialize `LOAD_SUPER_ATTR` in free-threaded builds (gh-127128)
Neil Schemenauer [Tue, 3 Dec 2024 17:32:26 +0000 (09:32 -0800)] 
gh-115999: Specialize `LOAD_SUPER_ATTR` in free-threaded builds (gh-127128)

Use existing helpers to atomically modify the bytecode.  Add unit tests
to ensure specializing is happening as expected.  Add test_specialize.py
that can be used with ThreadSanitizer to detect data races.
Fix thread safety issue with cell_set_contents().

11 months agogh-127347: Document `traceback.print_list` (#127348)
Tomas R. [Tue, 3 Dec 2024 16:08:39 +0000 (17:08 +0100)] 
gh-127347: Document `traceback.print_list` (#127348)

Previously, `traceback.print_list` didn't have a documentation entry and was not exposed in `traceback.__all__`. Now it has a documentation entry and is exposed in `__all__`.

11 months agogh-127255: Make `CopyComPointer` public and add to `ctypes` doc. (GH-127275)
Jun Komoda [Tue, 3 Dec 2024 15:35:08 +0000 (00:35 +0900)] 
gh-127255: Make `CopyComPointer` public and add to `ctypes` doc. (GH-127275)