]> git.ipfire.org Git - thirdparty/Python/cpython.git/log
thirdparty/Python/cpython.git
19 months agogh-76785: Clean Up Interpreter ID Conversions (gh-117048)
Eric Snow [Thu, 21 Mar 2024 15:56:12 +0000 (09:56 -0600)] 
gh-76785: Clean Up Interpreter ID Conversions (gh-117048)

Mostly we unify the two different implementations of the conversion code (from PyObject * to int64_t.  We also drop the PyArg_ParseTuple()-style converter function, as well as rename and move PyInterpreterID_LookUp().

19 months agogh-116522: Stop the world before fork() and during shutdown (#116607)
Sam Gross [Thu, 21 Mar 2024 14:01:16 +0000 (10:01 -0400)] 
gh-116522: Stop the world before fork() and during shutdown (#116607)

This changes the free-threaded build to perform a stop-the-world pause
before deleting other thread states when forking and during shutdown.
This fixes some crashes when using multiprocessing and during shutdown
when running with `PYTHON_GIL=0`.

This also changes `PyOS_BeforeFork` to acquire the runtime lock
(i.e., `HEAD_LOCK(&_PyRuntime)`) before forking to ensure that data
protected by the runtime lock (and not just the GIL or stop-the-world)
is in a consistent state before forking.

19 months agogh-71052: Implement `ctypes.util.find_library` on Android (GH-116379)
Malcolm Smith [Thu, 21 Mar 2024 13:20:57 +0000 (13:20 +0000)] 
gh-71052: Implement `ctypes.util.find_library` on Android (GH-116379)

19 months agogh-116987: Support class code objects in inspect.findsource() (GH-117025)
Tian Gao [Thu, 21 Mar 2024 10:30:10 +0000 (03:30 -0700)] 
gh-116987: Support class code objects in inspect.findsource() (GH-117025)

19 months agoGH-109653: Defer import of ``importlib.metadata._adapters`` (#109829)
Adam Turner [Thu, 21 Mar 2024 03:49:10 +0000 (03:49 +0000)] 
GH-109653: Defer import of ``importlib.metadata._adapters`` (#109829)

* adapters

* Add comments for deferred imports with links to rationale.

* Add blurb

---------

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
19 months agogh-117089: Apply changes from importlib_metadata 7.1.0 (#117094)
Jason R. Coombs [Thu, 21 Mar 2024 03:01:24 +0000 (23:01 -0400)] 
gh-117089: Apply changes from importlib_metadata 7.1.0 (#117094)

* Apply changes from importlib_metadata 7.1.0

* Include the data sources in the makefile (even though they're not needed)

19 months agogh-116869: Enable -Werror in test_cext for Free Threading (#117106)
Victor Stinner [Wed, 20 Mar 2024 23:06:24 +0000 (00:06 +0100)] 
gh-116869: Enable -Werror in test_cext for Free Threading (#117106)

Check for warnings, but don't enable the compiler flag
-Werror=declaration-after-statement.

19 months agogh-105927: Limit PyWeakref_GetRef() to limited C API 3.13 (#117091)
Victor Stinner [Wed, 20 Mar 2024 22:52:23 +0000 (23:52 +0100)] 
gh-105927: Limit PyWeakref_GetRef() to limited C API 3.13 (#117091)

19 months agogh-117089: Move importlib.metadata tests to their own package (#117092)
Jason R. Coombs [Wed, 20 Mar 2024 21:11:00 +0000 (17:11 -0400)] 
gh-117089: Move importlib.metadata tests to their own package (#117092)

* Ensure importlib.metadata tests do not leak references in sys.modules.

* Move importlib.metadata tests to their own package for easier syncing with importlib_metadata.

* Update owners and makefile for new directories.

* Add blurb

19 months agoFix sort order for "locale encoding" glossary item (#115794)
Carol Willing [Wed, 20 Mar 2024 21:00:59 +0000 (14:00 -0700)] 
Fix sort order for "locale encoding" glossary item (#115794)

Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
19 months agoGH-117066: Tier 2 optimizer: Don't throw away good traces if we can't optimize them...
Mark Shannon [Wed, 20 Mar 2024 18:24:02 +0000 (18:24 +0000)] 
GH-117066: Tier 2 optimizer: Don't throw away good traces if we can't optimize them perfectly. (GH-117067)

19 months agogh-114314: ctypes: remove stgdict and switch to heap types (GH-116458)
Petr Viktorin [Wed, 20 Mar 2024 16:33:08 +0000 (17:33 +0100)] 
gh-114314: ctypes: remove stgdict and switch to heap types (GH-116458)

Before this change, ctypes classes used a custom dict subclass, `StgDict`,
as their `tp_dict`. This acts like a regular dict but also includes extra information
about the type.

This replaces stgdict by `StgInfo`, a C struct on the type, accessed by
`PyObject_GetTypeData()` (PEP-697).
All usage of `StgDict` (mainly variables named `stgdict`, `dict`, `edict` etc.) is
converted to `StgInfo` (named `stginfo`, `info`, `einfo`, etc.).
Where the dict is actually used for class attributes (as a regular PyDict), it's now
called `attrdict`.

This change -- not overriding `tp_dict` -- is made to make me comfortable with
the next part of this PR: moving the initialization logic from `tp_new` to `tp_init`.

The `StgInfo` is set up in `__init__` of each class, with a guard that prevents
calling `__init__` more than once. Note that abstract classes (like `Array` or
`Structure`) are created using `PyType_FromMetaclass` and do not have
`__init__` called.
Previously, this was done in `__new__`, which also wasn't called for abstract
classes.
Since `__init__` can be called from Python code or skipped, there is a tested
guard to ensure `StgInfo` is initialized exactly once before it's used.

Co-authored-by: neonene <53406459+neonene@users.noreply.github.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
19 months agogh-117058: Update GUI and packaging recommendations for macOS. (#117059)
Russell Keith-Magee [Wed, 20 Mar 2024 15:32:56 +0000 (23:32 +0800)] 
gh-117058: Update GUI and packaging recommendations for macOS. (#117059)

19 months agogh-116908: Only write to `_pending_calls.calls_to_do` with atomic operations (#117044)
Brett Simmers [Wed, 20 Mar 2024 15:18:26 +0000 (08:18 -0700)] 
gh-116908: Only write to `_pending_calls.calls_to_do` with atomic operations (#117044)

These writes to `pending->calls_to_do` need to be atomic, because other threads
can read (atomically) from `calls_to_do` without holding `pending->mutex`.

19 months agogh-116773: Ensure overlapped objects on Windows are not deallocated too early by...
jkriegshauser [Wed, 20 Mar 2024 14:33:28 +0000 (07:33 -0700)] 
gh-116773: Ensure overlapped objects on Windows are not deallocated too early by asyncio (GH-116774)

19 months agogh-117021: Fix integer overflow in PyLong_AsPid() on non-Windows 64-bit platforms...
Serhiy Storchaka [Wed, 20 Mar 2024 13:39:53 +0000 (15:39 +0200)] 
gh-117021: Fix integer overflow in PyLong_AsPid() on non-Windows 64-bit platforms (GH-117064)

19 months agogh-94808: add tests covering `PyFunction_{Get,Set}Closure` (GH-99429)
Nikita Sobolev [Wed, 20 Mar 2024 10:43:20 +0000 (13:43 +0300)] 
gh-94808: add tests covering `PyFunction_{Get,Set}Closure` (GH-99429)

19 months agoGH-108362: Incremental Cycle GC (GH-116206)
Mark Shannon [Wed, 20 Mar 2024 08:54:42 +0000 (08:54 +0000)] 
GH-108362: Incremental Cycle GC (GH-116206)

19 months agogh-116869: Fix test_cext for Free Threading (#117043)
Victor Stinner [Tue, 19 Mar 2024 22:23:17 +0000 (23:23 +0100)] 
gh-116869: Fix test_cext for Free Threading (#117043)

Don't check for warnings on Free Threading.

19 months agogh-116869: Fix test_cext on RHEL7 (#117010)
Victor Stinner [Tue, 19 Mar 2024 21:58:13 +0000 (22:58 +0100)] 
gh-116869: Fix test_cext on RHEL7 (#117010)

Remove -std option from CC command line.

Skip C++14 test for now on non-Windows platforms (like RHEL7).

19 months agogh-117041: Add "-X gil" in the Python CLI help (GH-117042)
Serhiy Storchaka [Tue, 19 Mar 2024 21:30:25 +0000 (23:30 +0200)] 
gh-117041: Add "-X gil" in the Python CLI help (GH-117042)

19 months agodocs: announce venv creation before installing packages (#117036)
Ned Batchelder [Tue, 19 Mar 2024 19:55:20 +0000 (15:55 -0400)] 
docs: announce venv creation before installing packages (#117036)

19 months agogh-101100: Fix Sphinx warnings in `library/pydoc.rst` (#116913)
Hugo van Kemenade [Tue, 19 Mar 2024 19:48:08 +0000 (21:48 +0200)] 
gh-101100: Fix Sphinx warnings in `library/pydoc.rst` (#116913)

19 months agogh-116886: Temporarily disable CIfuzz (memory) (#117018)
Łukasz Langa [Tue, 19 Mar 2024 19:06:06 +0000 (19:06 +0000)] 
gh-116886: Temporarily disable CIfuzz (memory) (#117018)

19 months agogh-113964: Don't prevent new threads until all non-daemon threads exit (#116677)
Sam Gross [Tue, 19 Mar 2024 18:40:20 +0000 (14:40 -0400)] 
gh-113964: Don't prevent new threads until all non-daemon threads exit (#116677)

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.

19 months agogh-56374: Clarify documentation of nonlocal (#116942)
Terry Jan Reedy [Tue, 19 Mar 2024 17:55:21 +0000 (13:55 -0400)] 
gh-56374: Clarify documentation of nonlocal (#116942)

Define 'nonlocal scopes' in a way that excludes class scopes.
Rearrange the rest of the doc.  Add "Programmer's note".

19 months agogh-90300: Improve the Python CLI help output (GH-115853)
Serhiy Storchaka [Tue, 19 Mar 2024 17:26:32 +0000 (19:26 +0200)] 
gh-90300: Improve the Python CLI help output (GH-115853)

* document equivalent command-line options for all environment variables
* document equivalent environment variables for all command-line options
* reduce the size of variable and option descriptions to minimum
* remove the ending period in single-sentence descriptions

Co-authored-by: Éric <merwok@netwok.org>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
19 months agogh-116417: Move limited C API complex.c tests to _testlimitedcapi (#117014)
Victor Stinner [Tue, 19 Mar 2024 16:23:12 +0000 (17:23 +0100)] 
gh-116417: Move limited C API complex.c tests to _testlimitedcapi (#117014)

Split complex.c tests of _testcapi into two parts: limited C API
tests in _testlimitedcapi and non-limited C API tests in _testcapi.

19 months agogh-107607: Update comment about utf-8 BOM being ignored (#107858)
Sunghyun Kim [Tue, 19 Mar 2024 15:51:12 +0000 (11:51 -0400)] 
gh-107607: Update comment about utf-8 BOM being ignored (#107858)

---------
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
19 months agoGH-116017: Put JIT code and data on the same page (GH-116845)
Brandt Bucher [Tue, 19 Mar 2024 15:47:28 +0000 (08:47 -0700)] 
GH-116017: Put JIT code and data on the same page (GH-116845)

19 months agogh-116417: Move limited C API dict.c tests to _testlimitedcapi (#117006)
Victor Stinner [Tue, 19 Mar 2024 15:06:20 +0000 (16:06 +0100)] 
gh-116417: Move limited C API dict.c tests to _testlimitedcapi (#117006)

Split dict.c tests of _testcapi into two parts: limited C API tests
in _testlimitedcapi and non-limited C API tests in _testcapi.

19 months agogh-116647: Fix recursive child in dataclasses (#116790)
et-repositories [Tue, 19 Mar 2024 14:58:40 +0000 (22:58 +0800)] 
gh-116647: Fix recursive child in dataclasses (#116790)

19 months agogh-116417: Move limited C API long.c tests to _testlimitedcapi (#117001)
Victor Stinner [Tue, 19 Mar 2024 14:04:23 +0000 (15:04 +0100)] 
gh-116417: Move limited C API long.c tests to _testlimitedcapi (#117001)

* Split long.c tests of _testcapi into two parts: limited C API tests
  in _testlimitedcapi and non-limited C API tests in _testcapi.
* Move testcapi_long.h from Modules/_testcapi/ to
  Modules/_testlimitedcapi/.
* Add MODULE__TESTLIMITEDCAPI_DEPS to Makefile.pre.in.

19 months agogh-92906: Enable test_cext and test_cppext on Windows (#117000)
Victor Stinner [Tue, 19 Mar 2024 14:03:27 +0000 (15:03 +0100)] 
gh-92906: Enable test_cext and test_cppext on Windows (#117000)

On Windows in release mode, the test_cext and test_cppext can now
build C and C++ extensions.

* test_cext now also builds the C extension without options.
* test_cppext now also builds the C++ extension without options.
* Add C++14 test to test_cppext; C++11 is not supported by MSVC.
* Make setup_venv_with_pip_setuptools_wheel() quiet when
  support.verbose is false. Only show stdout and stderr on failure.

19 months agogh-90872: Fix subprocess.Popen.wait() for negative timeout (#116989)
Victor Stinner [Tue, 19 Mar 2024 13:42:44 +0000 (14:42 +0100)] 
gh-90872: Fix subprocess.Popen.wait() for negative timeout (#116989)

On Windows, subprocess.Popen.wait() no longer calls
WaitForSingleObject() with a negative timeout: pass 0 ms if the
timeout is negative.

19 months agogh-114099 - Add iOS framework loading machinery. (GH-116454)
Russell Keith-Magee [Tue, 19 Mar 2024 12:36:19 +0000 (20:36 +0800)] 
gh-114099 - Add iOS framework loading machinery. (GH-116454)

Co-authored-by: Malcolm Smith <smith@chaquo.com>
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
19 months agogh-116417: Move limited C API unicode.c tests to _testlimitedcapi (#116993)
Victor Stinner [Tue, 19 Mar 2024 12:30:39 +0000 (13:30 +0100)] 
gh-116417: Move limited C API unicode.c tests to _testlimitedcapi (#116993)

Split unicode.c tests of _testcapi into two parts: limited C API
tests in _testlimitedcapi and non-limited C API tests in _testcapi.

Update test_codecs.

19 months agogh-116869: Test the limited C API in test_cext (#116995)
Victor Stinner [Tue, 19 Mar 2024 12:19:45 +0000 (13:19 +0100)] 
gh-116869: Test the limited C API in test_cext (#116995)

19 months agogh-116808: Fix optimized trace length histogram (GH-116827)
Michael Droettboom [Tue, 19 Mar 2024 11:06:43 +0000 (07:06 -0400)] 
gh-116808: Fix optimized trace length histogram (GH-116827)

19 months agogh-116869: Build test_cext with -Werror=declaration-after-statement (#116990)
Victor Stinner [Tue, 19 Mar 2024 11:05:22 +0000 (12:05 +0100)] 
gh-116869: Build test_cext with -Werror=declaration-after-statement (#116990)

Make sure that the C API does not emit compiler warnings when built
with -Werror=declaration-after-statement.

19 months agogh-116417: Move limited C API abstract.c tests to _testlimitedcapi (#116986)
Victor Stinner [Tue, 19 Mar 2024 10:44:13 +0000 (11:44 +0100)] 
gh-116417: Move limited C API abstract.c tests to _testlimitedcapi (#116986)

Split abstract.c and float.c tests of _testcapi into two parts:
limited C API tests in _testlimitedcapi and non-limited C API tests
in _testcapi.

Update test_bytes and test_class.

19 months agogh-116957: configparser: Do post-process values after DuplicateOptionError (GH-116958)
David Röthlisberger [Tue, 19 Mar 2024 09:59:08 +0000 (09:59 +0000)] 
gh-116957: configparser: Do post-process values after DuplicateOptionError (GH-116958)

If you catch DuplicateOptionError / DuplicateSectionError when reading a
config file (the intention is to skip invalid config files) and then
attempt to use the ConfigParser instance, any values it *had* read
successfully so far, were stored as a list instead of string! Later
`get` calls would raise "AttributeError: 'list' object has no attribute
'find'" from somewhere deep in the interpolation code.

19 months agogh-115756: make PyCode_GetFirstFree an unstable API (GH-115781)
Bogdan Romanyuk [Tue, 19 Mar 2024 09:20:38 +0000 (12:20 +0300)] 
gh-115756: make PyCode_GetFirstFree an unstable API (GH-115781)

19 months agogh-116621: Specialize list.extend for dict items (gh-116888)
Donghee Na [Tue, 19 Mar 2024 03:18:07 +0000 (12:18 +0900)] 
gh-116621: Specialize list.extend for dict items (gh-116888)

19 months agogh-105866: fix dataclass with slots=True, weakref_slot=True (#105870)
Aviel Boag [Tue, 19 Mar 2024 00:53:14 +0000 (02:53 +0200)] 
gh-105866: fix dataclass with slots=True, weakref_slot=True (#105870)

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
Co-authored-by: Carl Meyer <carl@oddbird.net>
19 months agogh-116869: Enable test_cext and test_cppext on Free Threading build (#116973)
Victor Stinner [Mon, 18 Mar 2024 23:14:29 +0000 (00:14 +0100)] 
gh-116869: Enable test_cext and test_cppext on Free Threading build (#116973)

Remove the "if Py_GIL_DISABLED" skip and move all "skip" decorators
to the class. Use support.check_sanitizer()

19 months agogh-116417: Fix WASI build of _testlimitedcapi (#116974)
Victor Stinner [Mon, 18 Mar 2024 22:06:52 +0000 (23:06 +0100)] 
gh-116417: Fix WASI build of _testlimitedcapi (#116974)

Use different function names between _testcapi and _testlimitedcapi
to not confuse the WASI linker.

19 months agogh-116941: Fix pyatomic_std.h syntax errors (#116967)
Sam Gross [Mon, 18 Mar 2024 21:05:43 +0000 (17:05 -0400)] 
gh-116941: Fix pyatomic_std.h syntax errors (#116967)

19 months ago gh-116417: Move limited C API list.c tests to _testlimitedcapi (#116602)
Victor Stinner [Mon, 18 Mar 2024 21:03:55 +0000 (22:03 +0100)] 
  gh-116417: Move limited C API list.c tests to _testlimitedcapi (#116602)

Split list.c and set.c tests of _testcapi into two parts: limited C
API tests in _testlimitedcapi and non-limited C API tests in
_testcapi.

19 months agogh-113538: Add asycio.Server.{close,abort}_clients (redo) (#116784)
Pierre Ossman (ThinLinc team) [Mon, 18 Mar 2024 20:15:53 +0000 (21:15 +0100)] 
gh-113538: Add asycio.Server.{close,abort}_clients (redo) (#116784)

These give applications the option of more forcefully terminating client
connections for asyncio servers. Useful when terminating a service and
there is limited time to wait for clients to finish up their work.

This is a do-over with a test fix for gh-114432, which was reverted.

19 months agogh-116869: Make C API compatible with ISO C90 (#116950)
Victor Stinner [Mon, 18 Mar 2024 19:16:58 +0000 (20:16 +0100)] 
gh-116869: Make C API compatible with ISO C90 (#116950)

Make the C API compatible with -Werror=declaration-after-statement
compiler flag again.

19 months agogh-116869: Add test_cext test: build a C extension (#116954)
Victor Stinner [Mon, 18 Mar 2024 19:15:20 +0000 (20:15 +0100)] 
gh-116869: Add test_cext test: build a C extension (#116954)

19 months agogh-108716: Cleanup remaining deepfreeze infrastructure (#116919)
Guido van Rossum [Mon, 18 Mar 2024 18:13:11 +0000 (11:13 -0700)] 
gh-108716: Cleanup remaining deepfreeze infrastructure (#116919)

Keep Tools/build/deepfreeze.py around (we may repurpose it for deepfreezing non-code objects),
and keep basic "clean" targets that remove the output of former deep-freeze activities,
to keep the build directories of current devs clean.

19 months agogh-116916: Remove separate next_func_version counter (#116918)
Guido van Rossum [Mon, 18 Mar 2024 18:11:10 +0000 (11:11 -0700)] 
gh-116916: Remove separate next_func_version counter (#116918)

Somehow we ended up with two separate counter variables tracking "the next function version".
Most likely this was a historical accident where an old branch was updated incorrectly.
This PR merges the two counters into a single one: `interp->func_state.next_version`.

19 months agoCleanup tier2 debug output (#116920)
Guido van Rossum [Mon, 18 Mar 2024 18:08:43 +0000 (11:08 -0700)] 
Cleanup tier2 debug output (#116920)

Various tweaks, including a slight refactor of the special cases for `_PUSH_FRAME`/`_POP_FRAME` to show the actual operand emitted.

19 months agogh-115119: Switch Windows build to mpdecimal external (GH-115182)
Zachary Ware [Mon, 18 Mar 2024 17:07:25 +0000 (12:07 -0500)] 
gh-115119: Switch Windows build to mpdecimal external (GH-115182)

This includes adding what should be a relatively temporary
`Modules/_decimal/windows/mpdecimal.h` shim to choose between `mpdecimal32vc.h`
or `mpdecimal64vc.h` based on which of `CONFIG_64` or `CONFIG_32` is defined.

19 months agogh-115258: Fix hanging tests for threading queue shutdown (#115940)
Duprat [Mon, 18 Mar 2024 16:15:29 +0000 (17:15 +0100)] 
gh-115258: Fix hanging tests for threading queue shutdown (#115940)

This reinstates `test_shutdown_immediate_all_methods_in_many_threads`
and improves `test_shutdown_all_methods_in_many_threads`.

19 months agogh-116869: Fix redefinition of the _PyOptimizerObject type (#116963)
Victor Stinner [Mon, 18 Mar 2024 16:14:42 +0000 (17:14 +0100)] 
gh-116869: Fix redefinition of the _PyOptimizerObject type (#116963)

Defining a type twice is a C11 feature and so makes the C API
incompatible with C99. Fix the issue by only defining the type once.

Example of warning (treated as an error):

    In file included from Include/Python.h:122:
    Include/cpython/optimizer.h:77:3: error: redefinition of typedef
    '_PyOptimizerObject' is a C11 feature [-Werror,-Wtypedef-redefinition]
    } _PyOptimizerObject;
    ^
    build/Include/cpython/optimizer.h:60:35: note: previous definition is here
    typedef struct _PyOptimizerObject _PyOptimizerObject;
                                    ^

19 months agogh-63207: Use GetSystemTimePreciseAsFileTime() in time.time() (#116822)
Victor Stinner [Mon, 18 Mar 2024 16:13:01 +0000 (17:13 +0100)] 
gh-63207: Use GetSystemTimePreciseAsFileTime() in time.time() (#116822)

19 months agogh-116877: Update `wheel` to version `0.43.0` (#116878)
Sam Gross [Mon, 18 Mar 2024 15:50:32 +0000 (11:50 -0400)] 
gh-116877: Update `wheel` to version `0.43.0` (#116878)

19 months agogh-71765: Fix inspect.getsource() on empty file (GH-20809)
kernc [Mon, 18 Mar 2024 15:13:02 +0000 (16:13 +0100)] 
gh-71765: Fix inspect.getsource() on empty file (GH-20809)

* bpo-27578: Fix inspect.getsource() on empty file

For modules from empty files, `inspect.getsource()` now
returns an empty string, and `inspect.getsourcelines()` returns
a list of one empty string, fixing the expected invariant.

As indicated by `exec('')`, empty strings are valid Python
source code.

Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
19 months agoRevert "gh-96844: Improve error message of list.remove (gh-106455)" (#116956)
Victor Stinner [Mon, 18 Mar 2024 13:54:45 +0000 (14:54 +0100)] 
Revert "gh-96844: Improve error message of list.remove (gh-106455)" (#116956)

This reverts commit 217f47d6e5e56bca78b8556e910cd00890f6f84a.

19 months agoGH-65056: Improve the IP address' is_global/is_private documentation (GH-113186)
Jakub Stasiak [Mon, 18 Mar 2024 12:57:00 +0000 (13:57 +0100)] 
GH-65056: Improve the IP address' is_global/is_private documentation (GH-113186)

* GH-65056: Improve the IP address' is_global/is_private documentation

It wasn't clear what the semantics of is_global/is_private are and, when
one gets to the bottom of it, it's not quite so simple (hence the
exceptions listed).

Co-authored-by: Petr Viktorin <encukou@gmail.com>
19 months agogh-115874: Don't use module state in teedataobject tp_dealloc (#116204)
Erlend E. Aasland [Mon, 18 Mar 2024 12:24:24 +0000 (13:24 +0100)] 
gh-115874: Don't use module state in teedataobject tp_dealloc (#116204)

Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
19 months agogh-115538: Emit warning when use bool as fd in _io.WindowsConsoleIO (GH-116925)
AN Long [Mon, 18 Mar 2024 11:48:50 +0000 (19:48 +0800)] 
gh-115538: Emit warning when use bool as fd in _io.WindowsConsoleIO (GH-116925)

19 months agoCI: Pass environment variables directly to configure in JIT CI (#116156)
Erlend E. Aasland [Mon, 18 Mar 2024 09:49:45 +0000 (10:49 +0100)] 
CI: Pass environment variables directly to configure in JIT CI (#116156)

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
19 months agogh-116664: Ensure thread-safe dict access in _warnings (#116768)
Erlend E. Aasland [Mon, 18 Mar 2024 09:37:48 +0000 (10:37 +0100)] 
gh-116664: Ensure thread-safe dict access in _warnings (#116768)

Replace _PyDict_GetItemWithError() with PyDict_GetItemRef().

19 months agogh-116881: Remove erroneous or redundant grammar NULL (GH-116885)
Terry Jan Reedy [Mon, 18 Mar 2024 09:31:13 +0000 (05:31 -0400)] 
gh-116881: Remove erroneous or redundant grammar NULL (GH-116885)

In Lexical Analysis f-strings section, NULL in the description
of 'literal character' means '\0'.  In the format_spec grammar
production, it is wrong with that meaning and redundant if
instead interpreted as <nothing>.  Remove it there.

19 months agoBump GitHub Actions (#116944)
Hugo van Kemenade [Mon, 18 Mar 2024 08:44:15 +0000 (10:44 +0200)] 
Bump GitHub Actions (#116944)

19 months agogh-116915: Make `_thread._ThreadHandle` support GC (#116934)
mpage [Mon, 18 Mar 2024 08:40:16 +0000 (01:40 -0700)] 
gh-116915: Make `_thread._ThreadHandle` support GC (#116934)

Even though it has no internal references to Python objects it still
has a reference to its type by virtue of being a heap type. We need
to provide a traverse function that visits the type, but we do not
need to provide a clear function.

19 months agogh-85283: Build _statistics extension with the limited C API (#116927)
Victor Stinner [Sun, 17 Mar 2024 17:59:02 +0000 (18:59 +0100)] 
gh-85283: Build _statistics extension with the limited C API (#116927)

Argument Clinic now inlines _PyArg_CheckPositional() for the limited
C API. The generated code should be as fast or even a little bit
faster.

19 months agoGH-116377: Stop raising `ValueError` from `glob.translate()`. (#116378)
Barney Gale [Sun, 17 Mar 2024 17:09:35 +0000 (17:09 +0000)] 
GH-116377: Stop raising `ValueError` from `glob.translate()`. (#116378)

Stop raising `ValueError` from `glob.translate()` when a `**` sub-string
appears in a non-recursive pattern segment. This matches `glob.glob()`
behaviour.

19 months agogh-85283: Build termios extension with the limited C API (#116928)
Victor Stinner [Sun, 17 Mar 2024 15:12:29 +0000 (16:12 +0100)] 
gh-85283: Build termios extension with the limited C API (#116928)

19 months agogh-73468: Add math.fma() function (#116667)
Victor Stinner [Sun, 17 Mar 2024 13:58:26 +0000 (14:58 +0100)] 
gh-73468: Add math.fma() function (#116667)

Added new math.fma() function, wrapping C99's ``fma()`` operation:
fused multiply-add function.

Co-authored-by: Mark Dickinson <mdickinson@enthought.com>
19 months agoGH-112536: Add more TSan tests (#116911)
Antoine Pitrou [Sun, 17 Mar 2024 08:47:14 +0000 (09:47 +0100)] 
GH-112536: Add more TSan tests (#116911)

These may all exercise some non-trivial aspects of thread synchronization.

19 months agogh-85287: Change codecs to raise precise UnicodeEncodeError and UnicodeDecodeError...
John Sloboda [Sun, 17 Mar 2024 04:58:42 +0000 (00:58 -0400)] 
gh-85287: Change codecs to raise precise UnicodeEncodeError and UnicodeDecodeError (#113674)

Co-authored-by: Inada Naoki <songofacandy@gmail.com>
19 months agoUpdate titles and subtitles on landing page template (#116914)
Carol Willing [Sun, 17 Mar 2024 00:01:56 +0000 (17:01 -0700)] 
Update titles and subtitles on landing page template (#116914)

* Update titles and subtitles on landing page template

* address review from gvanrossum

* Edits from hugovk review

* Change word order back. Down the road we should split license and history

19 months agogh-116809: Restore removed _PyErr_ChainExceptions1() function (#116900)
Victor Stinner [Sat, 16 Mar 2024 20:37:11 +0000 (21:37 +0100)] 
gh-116809: Restore removed _PyErr_ChainExceptions1() function (#116900)

19 months agoCI: Process stale issues four times per day (#116857)
Hugo van Kemenade [Sat, 16 Mar 2024 17:59:42 +0000 (19:59 +0200)] 
CI: Process stale issues four times per day (#116857)

19 months agogh-116879: Add new optimizer pystats to tables (GH-116880)
Michael Droettboom [Sat, 16 Mar 2024 15:10:43 +0000 (11:10 -0400)] 
gh-116879: Add new optimizer pystats to tables (GH-116880)

19 months agogh-112536: Add more TSAN tests (#116896)
Donghee Na [Sat, 16 Mar 2024 14:52:44 +0000 (23:52 +0900)] 
gh-112536: Add more TSAN tests (#116896)

---------

Co-authored-by: Antoine Pitrou <antoine@python.org>
19 months agogh-116851: Remove "from ctypes import *" from a ctypes example (GH-116852)
jnchen [Sat, 16 Mar 2024 13:01:45 +0000 (21:01 +0800)] 
gh-116851: Remove "from ctypes import *" from a ctypes example (GH-116852)

It is confusing, because libc is not imported from ctypes,
but defined in previous examples, which already contain the import.

19 months agogh-114271: Fix race in `Thread.join()` (#114839)
mpage [Sat, 16 Mar 2024 12:56:30 +0000 (05:56 -0700)] 
gh-114271: Fix race in `Thread.join()` (#114839)

There is a race between when `Thread._tstate_lock` is released[^1] in `Thread._wait_for_tstate_lock()`
and when `Thread._stop()` asserts[^2] that it is unlocked. Consider the following execution
involving threads A, B, and C:

1. A starts.
2. B joins A, blocking on its `_tstate_lock`.
3. C joins A, blocking on its `_tstate_lock`.
4. A finishes and releases its `_tstate_lock`.
5. B acquires A's `_tstate_lock` in `_wait_for_tstate_lock()`, releases it, but is swapped
   out before calling `_stop()`.
6. C is scheduled, acquires A's `_tstate_lock` in `_wait_for_tstate_lock()` but is swapped
   out before releasing it.
7. B is scheduled, calls `_stop()`, which asserts that A's `_tstate_lock` is not held.
   However, C holds it, so the assertion fails.

The race can be reproduced[^3] by inserting sleeps at the appropriate points in
the threading code. To do so, run the `repro_join_race.py` from the linked repo.

There are two main parts to this PR:

1. `_tstate_lock` is replaced with an event that is attached to `PyThreadState`.
   The event is set by the runtime prior to the thread being cleared (in the same
   place that `_tstate_lock` was released). `Thread.join()` blocks waiting for the
   event to be set.
2. `_PyInterpreterState_WaitForThreads()` provides the ability to wait for all
   non-daemon threads to exit. To do so, an `is_daemon` predicate was added to
   `PyThreadState`. This field is set each time a thread is created. `threading._shutdown()`
   now calls into `_PyInterpreterState_WaitForThreads()` instead of waiting on
   `_tstate_lock`s.

[^1]: https://github.com/python/cpython/blob/441affc9e7f419ef0b68f734505fa2f79fe653c7/Lib/threading.py#L1201
[^2]: https://github.com/python/cpython/blob/441affc9e7f419ef0b68f734505fa2f79fe653c7/Lib/threading.py#L1115
[^3]: https://github.com/mpage/cpython/commit/81946532792f938cd6f6ab4c4ff92a4edf61314f

---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Antoine Pitrou <antoine@python.org>
19 months agogh-112536: Add test_threading to TSAN tests (#116898)
Antoine Pitrou [Sat, 16 Mar 2024 11:55:46 +0000 (12:55 +0100)] 
gh-112536: Add test_threading to TSAN tests (#116898)

19 months agogh-116484: Fix collisions between Checkbutton and ttk.Checkbutton default names ...
Serhiy Storchaka [Sat, 16 Mar 2024 11:31:19 +0000 (13:31 +0200)] 
gh-116484: Fix collisions between Checkbutton and ttk.Checkbutton default names (GH-116495)

Change automatically generated tkinter.Checkbutton widget names to
avoid collisions with automatically generated tkinter.ttk.Checkbutton
widget names within the same parent widget.

19 months agogh-116764: Fix regressions in urllib.parse.parse_qsl() (GH-116801)
Serhiy Storchaka [Sat, 16 Mar 2024 10:36:05 +0000 (12:36 +0200)] 
gh-116764: Fix regressions in urllib.parse.parse_qsl() (GH-116801)

* Restore support of None and other false values.
* Raise TypeError for non-zero integers and non-empty sequences.

The regressions were introduced in gh-74668
(bdba8ef42b15e651dc23374a08143cc2b4c4657d).

19 months agogh-90535: Fix support of interval>1 in logging.TimedRotatingFileHandler (GH-116220)
Serhiy Storchaka [Sat, 16 Mar 2024 10:29:42 +0000 (12:29 +0200)] 
gh-90535: Fix support of interval>1 in logging.TimedRotatingFileHandler (GH-116220)

Fix support of interval values > 1 in logging.TimedRotatingFileHandler
for when='MIDNIGHT' and when='Wx'.

19 months agogh-112536: Add TSAN builds on Github Actions (#116872)
Donghee Na [Sat, 16 Mar 2024 10:10:37 +0000 (19:10 +0900)] 
gh-112536: Add TSAN builds on Github Actions (#116872)

19 months agogh-116858: Add `@cpython_only` to several tests in `test_cmd_line` (#116859)
Nikita Sobolev [Sat, 16 Mar 2024 08:54:42 +0000 (11:54 +0300)] 
gh-116858: Add `@cpython_only` to several tests in `test_cmd_line` (#116859)

19 months agoMinor kde() docstring nit: make presentation order match the function signature ...
Raymond Hettinger [Fri, 15 Mar 2024 19:02:10 +0000 (14:02 -0500)] 
Minor kde() docstring nit: make presentation order match the function signature (#116876)

19 months agoGH-115802: Reduce the size of _INIT_CALL_PY_EXACT_ARGS. (GH-116856)
Mark Shannon [Fri, 15 Mar 2024 17:16:30 +0000 (17:16 +0000)] 
GH-115802: Reduce the size of _INIT_CALL_PY_EXACT_ARGS. (GH-116856)

19 months agogh-116868: Avoid locking in PyType_IsSubtype (#116829)
Dino Viehland [Fri, 15 Mar 2024 16:35:29 +0000 (12:35 -0400)] 
gh-116868: Avoid locking in PyType_IsSubtype (#116829)

Make PyType_IsSubType not acquire lock

19 months agogh-112536: Add --tsan test for reasonable TSAN execution times. (gh-116601)
Donghee Na [Fri, 15 Mar 2024 16:07:16 +0000 (01:07 +0900)] 
gh-112536: Add --tsan test for reasonable TSAN execution times. (gh-116601)

19 months agogh-116782: Mention `__type_params__` in `inspect.getmembers` docs (#116783)
Nikita Sobolev [Fri, 15 Mar 2024 15:47:46 +0000 (18:47 +0300)] 
gh-116782: Mention `__type_params__` in `inspect.getmembers` docs (#116783)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
19 months agogh-116621: Specialize list.extend for dict keys/values (gh-116816)
Donghee Na [Fri, 15 Mar 2024 14:48:34 +0000 (23:48 +0900)] 
gh-116621: Specialize list.extend for dict keys/values (gh-116816)

19 months agogh-116735: Use `MISSING` for `CALL` event if argument is absent (GH-116737)
Tian Gao [Fri, 15 Mar 2024 14:46:18 +0000 (07:46 -0700)] 
gh-116735: Use `MISSING` for `CALL` event if argument is absent (GH-116737)

19 months agogh-63283: IDNA prefix should be case insensitive (GH-17726)
Zackery Spytz [Fri, 15 Mar 2024 14:38:13 +0000 (07:38 -0700)] 
gh-63283: IDNA prefix should be case insensitive (GH-17726)

Any capitalization of "xn--" should be acceptable for the ACE prefix
(see https://tools.ietf.org/html/rfc3490#section-5).

Co-authored-by: Pepijn de Vos <pepijndevos@gmail.com>
Co-authored-by: Erlend E. Aasland <erlend@python.org>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
19 months agogh-111926: Simplify proxy creation logic (#116844)
mpage [Fri, 15 Mar 2024 13:58:40 +0000 (06:58 -0700)] 
gh-111926: Simplify proxy creation logic (#116844)

Since 3.12, allocating a GC-able object cannot trigger GC. This allows
us to simplify the logic for creating the canonical callback-less
proxy object.

19 months agogh-111926: Simplify weakref creation logic (#116843)
mpage [Fri, 15 Mar 2024 13:56:13 +0000 (06:56 -0700)] 
gh-111926: Simplify weakref creation logic (#116843)

Since 3.12, allocating a GC object cannot immediately trigger GC. This
allows us to simplify the logic for creating the canonical callback-less
weakref.

19 months agoGH-116422: Modify a few uops so that they can be supported by tier 2 with hot/cold...
Mark Shannon [Fri, 15 Mar 2024 10:48:00 +0000 (10:48 +0000)] 
GH-116422: Modify a few uops so that they can be supported by tier 2 with hot/cold splitting (GH-116832)