]> git.ipfire.org Git - thirdparty/Python/cpython.git/log
thirdparty/Python/cpython.git
21 months agoGH-113858: GitHub Actions config: Only save ccache on pushes (GH-113859)
Petr Viktorin [Wed, 10 Jan 2024 08:49:18 +0000 (09:49 +0100)] 
GH-113858: GitHub Actions config: Only save ccache on pushes (GH-113859)

21 months agogh-112182: Replace StopIteration with RuntimeError for future (#113220)
Jamie Phan [Wed, 10 Jan 2024 05:21:00 +0000 (16:21 +1100)] 
gh-112182: Replace StopIteration with RuntimeError for future (#113220)

When an `StopIteration` raises into `asyncio.Future`, this will cause
a thread to hang. This commit address this by not raising an exception
and silently transforming the `StopIteration` with a `RuntimeError`,
which the caller can reconstruct from `fut.exception().__cause__`

21 months agopathlib ABCs: Require one or more initialiser arguments (#113885)
Barney Gale [Wed, 10 Jan 2024 01:12:58 +0000 (01:12 +0000)] 
pathlib ABCs: Require one or more initialiser arguments (#113885)

Refuse to guess what a user means when they initialise a pathlib ABC
without any positional arguments. In mainline pathlib it's normalised to
`.`, but in the ABCs this guess isn't appropriate; for example, the path
type may not represent the current directory as `.`, or may have no concept
of a "current directory" at all.

21 months agoGH-113528: Deoptimise `pathlib._abc.PurePathBase` (#113559)
Barney Gale [Tue, 9 Jan 2024 23:52:15 +0000 (23:52 +0000)] 
GH-113528: Deoptimise `pathlib._abc.PurePathBase` (#113559)

Apply pathlib's normalization and performance tuning in `pathlib.PurePath`, but not `pathlib._abc.PurePathBase`.

With this change, the pathlib ABCs do not normalize away alternate path separators, empty segments, or dot segments. A single string given to the initialiser will round-trip by default, i.e. `str(PurePathBase(my_string)) == my_string`. Implementors can set their own path domain-specific normalization scheme by overriding `__str__()`

Eliminating path normalization makes maintaining and caching the path's parts and string representation both optional and not very useful, so this commit moves the `_drv`, `_root`, `_tail_cached` and `_str` slots from `PurePathBase` to `PurePath`. Only `_raw_paths` and `_resolving` slots remain in `PurePathBase`. This frees the ABCs from the burden of some of pathlib's hardest-to-understand code.

21 months agogh-111968: Introduce _PyFreeListState and _PyFreeListState_GET API (gh-113584)
Donghee Na [Tue, 9 Jan 2024 23:04:41 +0000 (08:04 +0900)] 
gh-111968: Introduce _PyFreeListState and _PyFreeListState_GET API (gh-113584)

21 months agoGH-113528: Deoptimise `pathlib._abc.PurePathBase.relative_to()` (again) (#113882)
Barney Gale [Tue, 9 Jan 2024 23:04:14 +0000 (23:04 +0000)] 
GH-113528: Deoptimise `pathlib._abc.PurePathBase.relative_to()` (again) (#113882)

Restore full battle-tested implementations of `PurePath.[is_]relative_to()`. These were recently split up in 3375dfe and a15a773.

In `PurePathBase`, add entirely new implementations based on `_stack`, which itself calls `pathmod.split()` repeatedly to disassemble a path. These new implementations preserve features like trailing slashes where possible, while still observing that a `..` segment cannot be added to traverse an empty or `.` segment in *walk_up* mode. They do not rely on `parents` nor `__eq__()`, nor do they spin up temporary path objects.

Unfortunately calling `pathmod.relpath()` isn't an option, as it calls `abspath()` and in turn `os.getcwd()`, which is impure.

21 months agoGH-113528: Deoptimise `pathlib._abc.PurePathBase.parts` (#113883)
Barney Gale [Tue, 9 Jan 2024 22:46:50 +0000 (22:46 +0000)] 
GH-113528: Deoptimise `pathlib._abc.PurePathBase.parts` (#113883)

Implement `parts` using `_stack`, which itself calls `pathmod.split()`
repeatedly. This avoids use of `_tail`, which will be moved to `PurePath`
shortly.

21 months agogh-66060: Use actual class name in _io type's __repr__ (#30824)
AN Long [Tue, 9 Jan 2024 20:39:36 +0000 (04:39 +0800)] 
gh-66060: Use actual class name in _io type's __repr__ (#30824)

Use the object's actual class name in the following _io type's __repr__:
- FileIO
- TextIOWrapper
- _WindowsConsoleIO

21 months agoGH-113528: Deoptimise `pathlib._abc.PathBase.resolve()` (#113782)
Barney Gale [Tue, 9 Jan 2024 19:50:23 +0000 (19:50 +0000)] 
GH-113528: Deoptimise `pathlib._abc.PathBase.resolve()` (#113782)

Replace use of `_from_parsed_parts()` with `with_segments()` in
`resolve()`.

No effect on `Path.resolve()`, which uses `os.path.realpath()`.

21 months agoGH-113661: unittest runner: Don't exit 5 if tests were skipped (#113856)
Stefano Rivera [Tue, 9 Jan 2024 19:50:01 +0000 (11:50 -0800)] 
GH-113661: unittest runner: Don't exit 5 if tests were skipped (#113856)

The intention of exiting 5 was to detect issues where the test suite
wasn't discovered at all. If we skipped tests, it was correctly
discovered.

21 months agogh-113781: Silence AttributeError in warning module during Python finalization (GH...
Serhiy Storchaka [Tue, 9 Jan 2024 19:44:05 +0000 (21:44 +0200)] 
gh-113781: Silence AttributeError in warning module during Python finalization (GH-113813)

The tracemalloc module can already be cleared.

21 months agogh-113848: Handle CancelledError subclasses in asyncio TaskGroup() and timeout()...
Serhiy Storchaka [Tue, 9 Jan 2024 19:41:31 +0000 (21:41 +0200)] 
gh-113848: Handle CancelledError subclasses in asyncio TaskGroup() and timeout() (GH-113850)

21 months agogh-113848: Use PyErr_GivenExceptionMatches() for check for CancelledError (GH-113849)
Serhiy Storchaka [Tue, 9 Jan 2024 19:41:02 +0000 (21:41 +0200)] 
gh-113848: Use PyErr_GivenExceptionMatches() for check for CancelledError (GH-113849)

21 months agoGH-113528: Deoptimise `pathlib._abc.PathBase._make_child_relpath()` (#113532)
Barney Gale [Tue, 9 Jan 2024 19:11:17 +0000 (19:11 +0000)] 
GH-113528: Deoptimise `pathlib._abc.PathBase._make_child_relpath()` (#113532)

Call straight through to `joinpath()` in `PathBase._make_child_relpath()`.
Move optimised/caching code to `pathlib.Path._make_child_relpath()`

21 months agoSimplify binomial approximation example with random.binomialvariate() (gh-113871)
Raymond Hettinger [Tue, 9 Jan 2024 19:02:07 +0000 (13:02 -0600)] 
Simplify binomial approximation example with random.binomialvariate() (gh-113871)

21 months agoFix opcode name printing in debug mode (#113870)
Guido van Rossum [Tue, 9 Jan 2024 18:18:11 +0000 (10:18 -0800)] 
Fix opcode name printing in debug mode (#113870)

Fix a few places where the lltrace debug output printed ``(null)`` instead of an opcode name, because it was calling ``_PyUOpName()`` on a Tier-1 opcode.

21 months agogh-113650: Add workaround option for MSVC ARM64 bug affecting string encoding (GH...
Steve Dower [Tue, 9 Jan 2024 17:32:22 +0000 (17:32 +0000)] 
gh-113650: Add workaround option for MSVC ARM64 bug affecting string encoding (GH-113836)

21 months agogh-103092: Test _ctypes type hierarchy and features (#113727)
AN Long [Tue, 9 Jan 2024 17:28:43 +0000 (01:28 +0800)] 
gh-103092: Test _ctypes type hierarchy and features (#113727)

Test the following features for _ctypes types:
- disallow instantiation
- inheritance (MRO)
- immutability
- type name

The following _ctypes types are tested:
- Array
- CField
- COMError
- PyCArrayType
- PyCFuncPtrType
- PyCPointerType
- PyCSimpleType
- PyCStructType
- Structure
- Union
- UnionType
- _CFuncPtr
- _Pointer
- _SimpleCData

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
21 months agogh-87868: Sort and remove duplicates in getenvironment() (GH-102731)
AN Long [Tue, 9 Jan 2024 15:58:26 +0000 (23:58 +0800)] 
gh-87868: Sort and remove duplicates in getenvironment() (GH-102731)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
21 months agogh-113842: Add missing error check for PyIter_Next() in Python/symtable.c (GH-113843)
Yan Yanchii [Tue, 9 Jan 2024 10:43:58 +0000 (11:43 +0100)] 
gh-113842: Add missing error check for PyIter_Next() in Python/symtable.c (GH-113843)

21 months agogh-101100: Fix Sphinx warnings for 2.6 port-specific deprecations (#113752)
Hugo van Kemenade [Tue, 9 Jan 2024 08:18:15 +0000 (10:18 +0200)] 
gh-101100: Fix Sphinx warnings for 2.6 port-specific deprecations (#113752)

21 months agogh-113692: skip a test if multiprocessing isn't available. (GH-113704)
Vinay Sajip [Tue, 9 Jan 2024 07:47:42 +0000 (07:47 +0000)] 
gh-113692: skip a test if multiprocessing isn't available. (GH-113704)

22 months agoDocs: Link tokens in the format string grammars (#108184)
William Andrea [Tue, 9 Jan 2024 02:47:59 +0000 (21:47 -0500)] 
Docs: Link tokens in the format string grammars (#108184)

Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
22 months agogh-112087: Update list.{pop,clear,reverse,remove} to use CS (gh-113764)
Donghee Na [Tue, 9 Jan 2024 00:00:55 +0000 (09:00 +0900)] 
gh-112087: Update list.{pop,clear,reverse,remove} to use CS (gh-113764)

22 months agogh-112808: Fix mimalloc build on Solaris (#112809)
Jakub Kulík [Mon, 8 Jan 2024 23:50:56 +0000 (00:50 +0100)] 
gh-112808: Fix mimalloc build on Solaris (#112809)

22 months agogh-112806: Remove unused function warnings during mimalloc build on Solaris (#112807)
Jakub Kulík [Mon, 8 Jan 2024 23:49:33 +0000 (00:49 +0100)] 
gh-112806: Remove unused function warnings during mimalloc build on Solaris (#112807)

22 months agoreadme: fix displaying issue of command (#113719)
mara004 [Mon, 8 Jan 2024 23:42:56 +0000 (00:42 +0100)] 
readme: fix displaying issue of command (#113719)

Avoid line break in command as this causes displaying issues on GH.

22 months agogh-113027: Fix test_variable_tzname in test_email (#113821)
Serhiy Storchaka [Mon, 8 Jan 2024 22:33:53 +0000 (00:33 +0200)] 
gh-113027: Fix test_variable_tzname in test_email (#113821)

Determine the support of the Kyiv timezone by checking the result of
astimezone() which uses the system tz database and not the one
populated by zoneinfo.

22 months agogh-113827: Move Windows frozen modules directory to allow PGO builds (GH-113828)
Steve Dower [Mon, 8 Jan 2024 21:51:39 +0000 (21:51 +0000)] 
gh-113827: Move Windows frozen modules directory to allow PGO builds (GH-113828)

22 months agoGH-111693: Propagate correct asyncio.CancelledError instance out of asyncio.Condition...
Kristján Valur Jónsson [Mon, 8 Jan 2024 19:57:48 +0000 (19:57 +0000)] 
GH-111693: Propagate correct asyncio.CancelledError instance out of asyncio.Condition.wait() (#111694)

Also fix a race condition in `asyncio.Semaphore.acquire()` when cancelled.

22 months agogh-113791: Expose CLOCK_MONOTONIC_RAW_APPROX and CLOCK_UPTIME_RAW_APROX on macOS...
Ronald Oussoren [Mon, 8 Jan 2024 19:44:00 +0000 (20:44 +0100)] 
gh-113791: Expose CLOCK_MONOTONIC_RAW_APPROX and CLOCK_UPTIME_RAW_APROX on macOS in the time module (#113792)

22 months agoGH-113528: Speed up pathlib ABC tests. (#113788)
Barney Gale [Mon, 8 Jan 2024 19:31:52 +0000 (19:31 +0000)] 
GH-113528: Speed up pathlib ABC tests. (#113788)

- Add `__slots__` to dummy path classes.
- Return namedtuple rather than `os.stat_result` from `DummyPath.stat()`.
- Reduce maximum symlink count in `DummyPathWithSymlinks.resolve()`.

22 months agogh-113688: fix dtrace build on Solaris (#113814)
Jakub Kulík [Mon, 8 Jan 2024 19:28:09 +0000 (20:28 +0100)] 
gh-113688: fix dtrace build on Solaris (#113814)

(the gcmodule -> gc refactoring broke it)

22 months agoGH-113528: Move a few misplaced pathlib tests (#113527)
Barney Gale [Mon, 8 Jan 2024 19:17:18 +0000 (19:17 +0000)] 
GH-113528: Move a few misplaced pathlib tests (#113527)

`PurePathBase` does not define `__eq__()`, and so we have no business checking path equality in `test_eq_common` and `test_equivalences`. The tests only pass at the moment because we define the test class's `__eq__()` for use elsewhere.

Also move `test_parse_path_common` into the main pathlib test suite. It exercises a private `_parse_path()` method that will be moved to `PurePath` soon.

Lastly move a couple more tests concerned with optimisations and path normalisation.

22 months agoMinor algebraic simplification for the totient() recipe (gh-113822)
Raymond Hettinger [Mon, 8 Jan 2024 19:16:22 +0000 (13:16 -0600)] 
Minor algebraic simplification for the totient() recipe (gh-113822)

22 months agogh-113755: Fully adapt gcmodule.c to Argument Clinic (#113756)
Erlend E. Aasland [Mon, 8 Jan 2024 17:32:34 +0000 (18:32 +0100)] 
gh-113755: Fully adapt gcmodule.c to Argument Clinic (#113756)

Adapt the following functions to Argument Clinic:

- gc.set_threshold
- gc.get_referrers
- gc.get_referents

22 months agogh-113787: Fix refleaks in test_capi (gh-113816)
neonene [Mon, 8 Jan 2024 16:34:51 +0000 (01:34 +0900)] 
gh-113787: Fix refleaks in test_capi (gh-113816)

Fix refleaks and a typo.

22 months agogh-113391: fix outdated PyObject_HasAttr docs (#113420)
Sergey B Kirpichev [Mon, 8 Jan 2024 15:23:43 +0000 (18:23 +0300)] 
gh-113391: fix outdated PyObject_HasAttr docs (#113420)

After #53875: PyObject_HasAttr is not an equivalent of hasattr.
PyObject_HasAttrWithError is; it already has the note.

22 months agogh-110721: Remove unused code from suggestions.c after moving PyErr_Display to use...
Pablo Galindo Salgado [Mon, 8 Jan 2024 15:10:45 +0000 (15:10 +0000)] 
gh-110721: Remove unused code from suggestions.c after moving PyErr_Display to use the traceback module (#113712)

22 months agogh-74678: Increase base64 test coverage (GH-21913)
Zackery Spytz [Mon, 8 Jan 2024 11:01:31 +0000 (03:01 -0800)] 
gh-74678: Increase base64 test coverage (GH-21913)

Ensure the character y is disallowed within an Ascii85 5-tuple.

Co-authored-by: Lee Cannon <leecannon@leecannon.xyz>
22 months agogh-80109: Fix io.TextIOWrapper dropping the internal buffer during write() (GH-22535)
Zackery Spytz [Mon, 8 Jan 2024 10:33:34 +0000 (02:33 -0800)] 
gh-80109: Fix io.TextIOWrapper dropping the internal buffer during write() (GH-22535)

io.TextIOWrapper was dropping the internal decoding buffer
during read() and write() calls.

22 months agogh-73965: Move PYTHON_HISTORY into the correct usage section (#113798)
Hugo van Kemenade [Mon, 8 Jan 2024 09:58:58 +0000 (11:58 +0200)] 
gh-73965: Move PYTHON_HISTORY into the correct usage section (#113798)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
22 months agogh-73965: New environment variable PYTHON_HISTORY (#13208)
Zackery Spytz [Sun, 7 Jan 2024 06:30:12 +0000 (22:30 -0800)] 
gh-73965: New environment variable PYTHON_HISTORY (#13208)

It can be used to set the location of a .python_history file

---------

Co-authored-by: Levi Sabah <0xl3vi@gmail.com>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
22 months agogh-112795: Allow `/` folder in a zipfile (#112932)
AN Long [Sun, 7 Jan 2024 01:14:18 +0000 (09:14 +0800)] 
gh-112795: Allow `/` folder in a zipfile (#112932)

Allow extraction (no-op) of a "/" folder in a zipfile, they are commonly added by some archive creation tools.

Co-authored-by: Erlend E. Aasland <erlend@python.org>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
22 months agogh-89532: Remove LibreSSL workarounds (#28728)
Rami [Sat, 6 Jan 2024 23:25:58 +0000 (01:25 +0200)] 
gh-89532: Remove LibreSSL workarounds (#28728)

Remove LibreSSL specific workaround ifdefs from `_ssl.c` and delete the non-version-specific `_ssl_data.h` file (relevant for OpenSSL < 1.1.1, which we no longer support per PEP 644).

Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
22 months agoGH-113528: Deoptimise `pathlib._abc.PurePathBase.relative_to()` (#113529)
Barney Gale [Sat, 6 Jan 2024 21:37:38 +0000 (21:37 +0000)] 
GH-113528: Deoptimise `pathlib._abc.PurePathBase.relative_to()` (#113529)

Replace use of `_from_parsed_parts()` with `with_segments()` in
`PurePathBase.relative_to()`, and move the assignment of `_drv`, `_root`
and `_tail_cached` slots into `PurePath.relative_to()`.

22 months agoGH-113528: Deoptimise `pathlib._abc.PurePathBase.parent` (#113530)
Barney Gale [Sat, 6 Jan 2024 21:17:51 +0000 (21:17 +0000)] 
GH-113528: Deoptimise `pathlib._abc.PurePathBase.parent` (#113530)

Replace use of `_from_parsed_parts()` with `with_segments()`, and move
assignments to `_drv`, `_root`, _tail_cached` and `_str` slots into
`PurePath`.

22 months agoGH-113528: Deoptimise `pathlib._abc.PurePathBase.name` (#113531)
Barney Gale [Sat, 6 Jan 2024 20:50:25 +0000 (20:50 +0000)] 
GH-113528: Deoptimise `pathlib._abc.PurePathBase.name` (#113531)

Replace usage of `_from_parsed_parts()` with `with_segments()` in
`with_name()`, and take a similar approach in `name` for consistency's
sake.

22 months agoGH-113528: Slightly improve `pathlib.Path.glob()` tests for symlink loop handling...
Barney Gale [Sat, 6 Jan 2024 17:03:39 +0000 (17:03 +0000)] 
GH-113528: Slightly improve `pathlib.Path.glob()` tests for symlink loop handling (#113763)

Slightly improve `pathlib.Path.glob()` tests for symlink loop handling

When filtering results, ignore paths with more than one `linkD/` segment,
rather than all paths below the first `linkD/` segment. This allows us
to test that other paths under `linkD/` are correctly returned.

22 months agoGH-113528: Split up pathlib tests for invalid basenames. (#113776)
Barney Gale [Sat, 6 Jan 2024 17:03:07 +0000 (17:03 +0000)] 
GH-113528: Split up pathlib tests for invalid basenames. (#113776)

Split test cases for invalid names into dedicated test methods. This will
make it easier to refactor tests for invalid name handling in ABCs later.

No change of coverage, just a change of test suite organisation.

22 months agoGH-113528: pathlib ABC tests: add repr to dummy path classes. (#113777)
Barney Gale [Sat, 6 Jan 2024 17:02:36 +0000 (17:02 +0000)] 
GH-113528: pathlib ABC tests: add repr to dummy path classes. (#113777)

The `DummyPurePath` and `DummyPath` test classes are simple subclasses of
`PurePathBase` and `PathBase`. This commit adds `__repr__()` methods to the
dummy classes, which makes debugging test failures less painful.

22 months agogh-107901: synthetic jumps which are not at end of loop no longer check the eval...
Irit Katriel [Sat, 6 Jan 2024 14:20:08 +0000 (14:20 +0000)] 
gh-107901: synthetic jumps which are not at end of loop no longer check the eval breaker (#113721)

22 months agogh-111488: Changed error message in case of no 'in' keyword after 'for' in cmp (...
Grigoriev Semyon [Sat, 6 Jan 2024 10:27:49 +0000 (13:27 +0300)] 
gh-111488: Changed error message in case of no 'in' keyword after 'for' in cmp (#113656)

22 months agogh-113537: support loads str in plistlib.loads (#113582)
AN Long [Sat, 6 Jan 2024 09:26:59 +0000 (17:26 +0800)] 
gh-113537: support loads str in plistlib.loads (#113582)

Add support for loading XML plists from a string value instead of a only bytes value.

22 months agogh-113729: Fix IDLE's Help -> "IDLE Help" menu bug in 3.12.1 and 3.11.7 (#113731)
Ronald Oussoren [Sat, 6 Jan 2024 06:23:26 +0000 (07:23 +0100)] 
gh-113729: Fix IDLE's Help -> "IDLE Help" menu bug in 3.12.1 and 3.11.7 (#113731)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
22 months agogh-113750: Fix object resurrection in free-threaded builds (gh-113751)
Sam Gross [Sat, 6 Jan 2024 03:12:26 +0000 (22:12 -0500)] 
gh-113750: Fix object resurrection in free-threaded builds (gh-113751)

gh-113750: Fix object resurrection on free-threaded builds

This avoids the undesired re-initializing of fields like `ob_gc_bits`,
`ob_mutex`, and `ob_tid` when an object is resurrected due to its
finalizer being called.

This change has no effect on the default (with GIL) build.

22 months agoGH-113568: Stop raising deprecation warnings from pathlib ABCs (#113757)
Barney Gale [Fri, 5 Jan 2024 22:56:04 +0000 (22:56 +0000)] 
GH-113568: Stop raising deprecation warnings from pathlib ABCs (#113757)

22 months agogh-113360: Fix the documentation of module's attribute __test__ (GH-113393)
Serhiy Storchaka [Fri, 5 Jan 2024 22:23:16 +0000 (00:23 +0200)] 
gh-113360: Fix the documentation of module's attribute __test__ (GH-113393)

It can only be a dict since Python 2.4.

22 months agogh-85567: Fix resouce warnings in pickle and pickletools CLIs (GH-113618)
Serhiy Storchaka [Fri, 5 Jan 2024 22:12:34 +0000 (00:12 +0200)] 
gh-85567: Fix resouce warnings in pickle and pickletools CLIs (GH-113618)

Explicitly open and close files instead of using FileType.

22 months agoGH-113568: Stop raising auditing events from pathlib ABCs (#113571)
Barney Gale [Fri, 5 Jan 2024 21:41:19 +0000 (21:41 +0000)] 
GH-113568: Stop raising auditing events from pathlib ABCs (#113571)

Raise auditing events in `pathlib.Path.glob()`, `rglob()` and `walk()`,
but not in `pathlib._abc.PathBase` methods. Also move generation of a
deprecation warning into `pathlib.Path` so it gets the right stack level.

22 months agogh-113688: Split up gcmodule.c (gh-113715)
Sam Gross [Fri, 5 Jan 2024 20:17:16 +0000 (15:17 -0500)] 
gh-113688: Split up gcmodule.c (gh-113715)

This splits part of Modules/gcmodule.c of into Python/gc.c, which
now contains the core garbage collection implementation. The Python
module remain in the Modules/gcmodule.c file.

22 months agogh-112532: Tag mimalloc heaps and pages (#113742)
Sam Gross [Fri, 5 Jan 2024 20:08:50 +0000 (15:08 -0500)] 
gh-112532: Tag mimalloc heaps and pages (#113742)

* gh-112532: Tag mimalloc heaps and pages

Mimalloc pages are data structures that contain contiguous allocations
of the same block size. Note that they are distinct from operating
system pages. Mimalloc pages are contained in segments.

When a thread exits, it abandons any segments and contained pages that
have live allocations. These segments and pages may be later reclaimed
by another thread. To support GC and certain thread-safety guarantees in
free-threaded builds, we want pages to only be reclaimed by the
corresponding heap in the claimant thread. For example, we want pages
containing GC objects to only be claimed by GC heaps.

This allows heaps and pages to be tagged with an integer tag that is
used to ensure that abandoned pages are only claimed by heaps with the
same tag. Heaps can be initialized with a tag (0-15); any page allocated
by that heap copies the corresponding tag.

* Fix conversion warning

22 months agogh-101100: Fix Sphinx warnings in `library/pyclbr.rst` (#113739)
Hugo van Kemenade [Fri, 5 Jan 2024 19:15:07 +0000 (21:15 +0200)] 
gh-101100: Fix Sphinx warnings in `library/pyclbr.rst` (#113739)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
22 months agogh-80532: Do not set ipv6type when cross-compiling (#17956)
Zackery Spytz [Fri, 5 Jan 2024 15:34:25 +0000 (07:34 -0800)] 
gh-80532: Do not set ipv6type when cross-compiling (#17956)

Co-authored-by: Xavier de Gaye <xdegaye@gmail.com>
22 months agogh-101100: Fix Sphinx warnings for 2.6 deprecations and removals (#113725)
Hugo van Kemenade [Fri, 5 Jan 2024 13:31:28 +0000 (15:31 +0200)] 
gh-101100: Fix Sphinx warnings for 2.6 deprecations and removals (#113725)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
22 months agogh-113703: Correctly identify incomplete f-strings in the codeop module (#113709)
Pablo Galindo Salgado [Fri, 5 Jan 2024 12:16:46 +0000 (12:16 +0000)] 
gh-113703: Correctly identify incomplete f-strings in the codeop module (#113709)

22 months agoGH-113486: Do not emit spurious PY_UNWIND events for optimized calls to classes....
Mark Shannon [Fri, 5 Jan 2024 09:45:22 +0000 (09:45 +0000)] 
GH-113486: Do not emit spurious PY_UNWIND events for optimized calls to classes. (GH-113680)

22 months agogh-113320: Reduce the number of dangerous `getattr()` calls when constructing protoco...
Alex Waygood [Fri, 5 Jan 2024 01:01:48 +0000 (01:01 +0000)] 
gh-113320: Reduce the number of dangerous `getattr()` calls when constructing protocol classes (#113401)

- Only attempt to figure out whether protocol members are "method members" or not if the class is marked as a runtime protocol. This information is irrelevant for non-runtime protocols; we can safely skip the risky introspection for them.
- Only do the risky getattr() calls in one place (the runtime_checkable class decorator), rather than in three places (_ProtocolMeta.__init__, _ProtocolMeta.__instancecheck__ and _ProtocolMeta.__subclasscheck__). This reduces the number of locations in typing.py where the risky introspection could go wrong.
- For runtime protocols, if determining whether a protocol member is callable or not fails, give a better error message. I think it's reasonable for us to reject runtime protocols that have members which raise strange exceptions when you try to access them. PEP-544 clearly states that all protocol member must be callable for issubclass() calls against the protocol to be valid -- and if a member raises when we try to access it, there's no way for us to figure out whether it's a callable member or not!

22 months agogh-112532: Isolate abandoned segments by interpreter (#113717)
Sam Gross [Thu, 4 Jan 2024 22:21:40 +0000 (17:21 -0500)] 
gh-112532: Isolate abandoned segments by interpreter (#113717)

* gh-112532: Isolate abandoned segments by interpreter

Mimalloc segments are data structures that contain memory allocations along
with metadata. Each segment is "owned" by a thread. When a thread exits,
it abandons its segments to a global pool to be later reclaimed by other
threads. This changes the pool to be per-interpreter instead of process-wide.

This will be important for when we use mimalloc to find GC objects in the
`--disable-gil` builds. We want heaps to only store Python objects from a
single interpreter. Absent this change, the abandoning and reclaiming process
could break this isolation.

* Add missing '&_mi_abandoned_default' to 'tld_empty'

22 months agoGH-113225: Speed up `pathlib.Path.glob()` (#113226)
Barney Gale [Thu, 4 Jan 2024 20:48:26 +0000 (20:48 +0000)] 
GH-113225: Speed up `pathlib.Path.glob()` (#113226)

Use `os.DirEntry.path` as the string representation of child paths, unless
the parent path is empty, in which case we use the entry `name`.

22 months agogh-113538: Don't error in stream reader protocol callback when task is cancelled...
Guido van Rossum [Thu, 4 Jan 2024 20:20:21 +0000 (12:20 -0800)] 
gh-113538: Don't error in stream reader protocol callback when task is cancelled (#113690)

22 months agogh-113569: Display calls in Mock.assert_has_calls failure when empty (GH-113573)
wookie184 [Thu, 4 Jan 2024 19:11:34 +0000 (19:11 +0000)] 
gh-113569: Display calls in Mock.assert_has_calls failure when empty (GH-113573)

22 months agogh-113696: Docs: Annotate PyObject_CallOneArg and PyObject_CallNoArgs as returning...
Jamie Phan [Thu, 4 Jan 2024 14:05:31 +0000 (01:05 +1100)] 
gh-113696: Docs: Annotate PyObject_CallOneArg and PyObject_CallNoArgs as returning a strong reference (#113697)

22 months agoGH-113689: Fix broken handling of invalid executors (GH-113694)
Brandt Bucher [Thu, 4 Jan 2024 11:14:15 +0000 (03:14 -0800)] 
GH-113689: Fix broken handling of invalid executors (GH-113694)

22 months agogh-52161: Enhance Cmd support for docstrings (#110987)
Filip Łapkiewicz [Wed, 3 Jan 2024 19:37:34 +0000 (20:37 +0100)] 
gh-52161: Enhance Cmd support for docstrings (#110987)

In `cmd.Cmd.do_help` call `inspect.cleandoc()`,
to clean indentation and remove leading/trailing empty
lines from a dosctring before printing.

22 months agoDocument the `co_lines` method on code objects (#113682)
Alex Waygood [Wed, 3 Jan 2024 19:29:24 +0000 (19:29 +0000)] 
Document the `co_lines` method on code objects (#113682)

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
22 months agogh-113258: Write frozen modules to the build tree on Windows (GH-113303)
Itamar Oren [Wed, 3 Jan 2024 17:30:20 +0000 (09:30 -0800)] 
gh-113258: Write frozen modules to the build tree on Windows (GH-113303)

This ensures the source directory is not modified at build time, and different builds (e.g. different versions or GIL vs no-GIL) do not have conflicts.

22 months agogh-113603: Compiler no longer tries to maintain the no-empty-block invariant (#113636)
Irit Katriel [Wed, 3 Jan 2024 16:57:48 +0000 (16:57 +0000)] 
gh-113603: Compiler no longer tries to maintain the no-empty-block invariant (#113636)

22 months agogh-111926: Set up basic sementics of weakref API for freethreading (gh-113621)
Donghee Na [Wed, 3 Jan 2024 13:25:27 +0000 (22:25 +0900)] 
gh-111926: Set up basic sementics of weakref API for freethreading (gh-113621)

---------

Co-authored-by: Sam Gross <colesbury@gmail.com>
22 months agogh-101100: Fix Sphinx warnings for removed dead batteries (#113669)
Hugo van Kemenade [Wed, 3 Jan 2024 13:04:26 +0000 (15:04 +0200)] 
gh-101100: Fix Sphinx warnings for removed dead batteries (#113669)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
22 months ago`functools.partial` docs: Use the more common spelling for "referenceable" (#113675)
Rodrigo Girão Serrão [Wed, 3 Jan 2024 12:50:44 +0000 (12:50 +0000)] 
`functools.partial` docs: Use the more common spelling for "referenceable" (#113675)

22 months agogh-113637: Let c_annotations.py to handle the spacing of Limited/Unstable API & Stabl...
Ege Akman [Wed, 3 Jan 2024 11:22:38 +0000 (14:22 +0300)] 
gh-113637: Let c_annotations.py to handle the spacing of Limited/Unstable API & Stable ABI translation strings (#113638)

22 months agoGH-113595: Don't enter invalid executor (GH-113596)
Mark Shannon [Wed, 3 Jan 2024 11:01:13 +0000 (11:01 +0000)] 
GH-113595: Don't enter invalid executor (GH-113596)

22 months agogh-113628: Fix test_site test with long stdlib paths (#113640)
Itamar Oren [Wed, 3 Jan 2024 00:30:53 +0000 (16:30 -0800)] 
gh-113628: Fix test_site test with long stdlib paths (#113640)

22 months agoGH-113657: Add back missing _SET_IP uops in tier two (GH-113662)
Brandt Bucher [Tue, 2 Jan 2024 22:09:57 +0000 (14:09 -0800)] 
GH-113657: Add back missing _SET_IP uops in tier two (GH-113662)

22 months agogh-110824 Temporarily skip test_sysconfig.test_library on macOS framework builds...
Skip Montanaro [Tue, 2 Jan 2024 21:29:08 +0000 (15:29 -0600)] 
gh-110824 Temporarily skip test_sysconfig.test_library on macOS framework builds. (GH-113298)

Co-authored-by: Ned Deily <nad@python.org>
22 months agogh-53502: Fix plistlib.dump() for naive datetime with aware_datetime option (GH-113645)
Serhiy Storchaka [Tue, 2 Jan 2024 19:45:36 +0000 (21:45 +0200)] 
gh-53502: Fix plistlib.dump() for naive datetime with aware_datetime option (GH-113645)

22 months agobuild(deps): bump actions/upload-artifact from 3 to 4 (#113614)
dependabot[bot] [Tue, 2 Jan 2024 16:20:17 +0000 (18:20 +0200)] 
build(deps): bump actions/upload-artifact from 3 to 4 (#113614)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
22 months agobuild(deps): bump actions/stale from 8 to 9 (#113611)
dependabot[bot] [Tue, 2 Jan 2024 16:19:01 +0000 (18:19 +0200)] 
build(deps): bump actions/stale from 8 to 9 (#113611)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
22 months agogh-111178: Avoid calling functions from incompatible pointer types in _tkinter.c...
Christopher Chavez [Tue, 2 Jan 2024 14:51:32 +0000 (08:51 -0600)] 
gh-111178: Avoid calling functions from incompatible pointer types in _tkinter.c (GH-112893)

Fix undefined behavior warnings (UBSan  -fsanitize=function).

22 months agogh-111178: Avoid calling functions from incompatible pointer types in dictobject...
Christopher Chavez [Tue, 2 Jan 2024 14:32:37 +0000 (08:32 -0600)] 
gh-111178: Avoid calling functions from incompatible pointer types in dictobject.c (#112892)

Fix undefined behavior warnings (UBSan  -fsanitize=function).

22 months agogh-111178: Avoid calling functions from incompatible pointer types in descrobject...
Christopher Chavez [Tue, 2 Jan 2024 14:03:39 +0000 (08:03 -0600)] 
gh-111178: Avoid calling functions from incompatible pointer types in descrobject.c (GH-112861)

Fix undefined behavior warnings (UBSan  -fsanitize=function), for example:

Python/generated_cases.c.h:3315:13: runtime error: call to function mappingproxy_dealloc through pointer to incorrect function type 'void (*)(struct _object *)'
descrobject.c:1160: note: mappingproxy_dealloc defined here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Python/generated_cases.c.h:3315:13 in

22 months agogh-111178: Avoid calling functions from incompatible pointer types in listobject...
Christopher Chavez [Tue, 2 Jan 2024 13:41:32 +0000 (07:41 -0600)] 
gh-111178: Avoid calling functions from incompatible pointer types in listobject.c (GH-112820)

Fix undefined behavior warnings (UBSan  -fsanitize=function), for example:

Objects/object.c:674:11: runtime error: call to function list_repr through pointer to incorrect function type 'struct _object *(*)(struct _object *)'
listobject.c:382: note: list_repr defined here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/object.c:674:11 in

22 months agogh-113602: Bail out when the parser tries to override existing errors (#113607)
Pablo Galindo Salgado [Tue, 2 Jan 2024 13:00:52 +0000 (13:00 +0000)] 
gh-113602: Bail out when the parser tries to override existing errors (#113607)

Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
22 months agogh-81094: Refer to PEP 318 in compound_statements.rst (#113588)
John D. McDonald [Tue, 2 Jan 2024 08:40:14 +0000 (02:40 -0600)] 
gh-81094: Refer to PEP 318 in compound_statements.rst (#113588)

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
22 months agogh-101100: Fix Sphinx warnings from removed `~!` references (#113629)
Hugo van Kemenade [Tue, 2 Jan 2024 07:37:37 +0000 (09:37 +0200)] 
gh-101100: Fix Sphinx warnings from removed `~!` references (#113629)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
22 months agono-issue: Use the official term "free-threading" for GitHub Action (gh-113622)
Donghee Na [Tue, 2 Jan 2024 00:16:53 +0000 (09:16 +0900)] 
no-issue: Use the official term "free-threading" for GitHub Action (gh-113622)

22 months agoGH-113633: Use module state structure for _testcapi. (GH-113634)
Neil Schemenauer [Mon, 1 Jan 2024 23:04:09 +0000 (15:04 -0800)] 
GH-113633: Use module state structure for _testcapi. (GH-113634)

Use module state structure for _testcapi.

22 months agogh-53502: Fixes for tests in gh-113363 (#113627)
Ronald Oussoren [Mon, 1 Jan 2024 20:31:43 +0000 (21:31 +0100)] 
gh-53502: Fixes for tests in gh-113363 (#113627)

* gh-53502: Fixes for tests in gh-113363

* Use 32-bit compatible date in test_dump_naive_datetime_with_aware_datetime_option

* Saving non-aware datetimes will use the old behaviour regardless of the aware_datimetime setting

22 months agogh-53502: add a new option aware_datetime in plistlib to loads or dumps aware datetim...
AN Long [Mon, 1 Jan 2024 18:51:24 +0000 (02:51 +0800)] 
gh-53502: add a new option aware_datetime in plistlib to loads or dumps aware datetime. (#113363)

* add options to loads and dumps aware datetime in plistlib