]> git.ipfire.org Git - thirdparty/Python/cpython.git/log
thirdparty/Python/cpython.git
19 months agogh-117187: Fix XML tests for vanilla Expat <2.6.0 (GH-117203)
Sebastian Pipping [Tue, 26 Mar 2024 01:48:27 +0000 (02:48 +0100)] 
gh-117187: Fix XML tests for vanilla Expat <2.6.0 (GH-117203)

This fixes XML unittest fallout from the https://github.com/python/cpython/issues/115398 security fix.  When configured using `--with-system-expat` on systems with older pre 2.6.0 versions of libexpat, our unittests were failing.

* sax|etree: Simplify Expat version guard where simplifiable

Idea by Matěj Cepl

* sax|etree: Fix reparse deferral tests for vanilla Expat <2.6.0

This *does not fix* the case of distros with an older version of libexpat with the 2.6.0 feature backported as a security fix.  (Ubuntu is a known example of this with its libexpat1 2.5.0-2ubunutu0.1 package)

19 months agogh-99108: Refresh HACL*; update modules accordingly; fix namespacing (GH-117237)
Jonathan Protzenko [Tue, 26 Mar 2024 00:35:26 +0000 (17:35 -0700)] 
gh-99108: Refresh HACL*; update modules accordingly; fix namespacing (GH-117237)

Pulls in a new update from https://github.com/hacl-star/hacl-star and fixes our C "namespacing" done by `Modules/_hacl/refresh.sh`.

19 months agogh-109870: Dataclasses: batch up exec calls (gh-110851)
Eric V. Smith [Mon, 25 Mar 2024 23:59:14 +0000 (19:59 -0400)] 
gh-109870: Dataclasses: batch up exec calls (gh-110851)

Instead of calling `exec()` once for each function added to a dataclass, only call `exec()` once per dataclass. This can lead to speed improvements of up to 20%.

19 months agoSync main docs and docstring for median_grouped(). (gh-117214)
Raymond Hettinger [Mon, 25 Mar 2024 23:49:44 +0000 (18:49 -0500)] 
Sync main docs and docstring for median_grouped(). (gh-117214)

19 months agogh-117114: Make os.path.isdevdrive available on all platforms (GH-117115)
Nice Zombies [Mon, 25 Mar 2024 22:55:11 +0000 (23:55 +0100)] 
gh-117114: Make os.path.isdevdrive available on all platforms (GH-117115)

19 months agoAdd information about negative indexes to sequence datamodel doc (#110903)
Adorilson Bezerra [Mon, 25 Mar 2024 22:34:20 +0000 (22:34 +0000)] 
Add information about negative  indexes to sequence datamodel doc (#110903)

Co-authored by Terry Jan Reedy

19 months agoA few minor tweaks to get stats working and compiling cleanly. (#117219)
Mark Shannon [Mon, 25 Mar 2024 20:43:51 +0000 (20:43 +0000)] 
A few minor tweaks to get stats working and compiling cleanly. (#117219)

Fixes a compilation error when configured with `--enable-pystats`,
an array size issue, and an unused variable.

19 months agogh-116936: Add PyType_GetModuleByDef() to the limited C API (#116937)
Victor Stinner [Mon, 25 Mar 2024 16:32:20 +0000 (17:32 +0100)] 
gh-116936: Add PyType_GetModuleByDef() to the limited C API (#116937)

19 months agogh-87193: Support bytes objects with refcount > 1 in _PyBytes_Resize() (GH-117160)
Serhiy Storchaka [Mon, 25 Mar 2024 15:32:11 +0000 (17:32 +0200)] 
gh-87193: Support bytes objects with refcount > 1 in _PyBytes_Resize() (GH-117160)

Create a new bytes object and destroy the old one if it has refcount > 1.

19 months agogh-112948: Make pdb completion similar to repl completion (#112950)
Tian Gao [Mon, 25 Mar 2024 15:18:09 +0000 (08:18 -0700)] 
gh-112948: Make pdb completion similar to repl completion (#112950)

19 months agoMinor markup and grammar fixes in the statistics docs (gh-117216)
Raymond Hettinger [Mon, 25 Mar 2024 14:26:42 +0000 (09:26 -0500)] 
Minor markup and grammar fixes in the statistics docs (gh-117216)

19 months agogh-117176: Fix compiler warning in Python/optimizer_bytecodes.c (GH-117199)
Kirill Podoprigora [Sun, 24 Mar 2024 18:34:55 +0000 (20:34 +0200)] 
gh-117176: Fix compiler warning in Python/optimizer_bytecodes.c (GH-117199)

19 months agogh-112571: Move fish venv activation script into the common folder (GH-117169)
Totally a booplicate [Sun, 24 Mar 2024 15:48:40 +0000 (18:48 +0300)] 
gh-112571: Move fish venv activation script into the common folder (GH-117169)

pythongh-112571: allow using fish venv activation script on windows

The fish shell can be used on windows under cygwin or msys2.
This change moves the script to the common folder
so the venv module will install it on both posix and nt systems (like the bash script).

19 months agogh-117194: Properly format 'base64' header in What's New (#117198)
Terry Jan Reedy [Sun, 24 Mar 2024 15:38:34 +0000 (11:38 -0400)] 
gh-117194: Properly format 'base64' header in What's New (#117198)

It needs 6, not 3, '-'s.

19 months agoGH-115986 Docs: promote pprint.pp usage as a default (#116614)
Kerim Kabirov [Sun, 24 Mar 2024 13:59:14 +0000 (14:59 +0100)] 
GH-115986 Docs: promote pprint.pp usage as a default (#116614)

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
19 months agogh-101760: Improve the imaplib.IMAP4 example (#101764)
LilKS [Sun, 24 Mar 2024 10:01:07 +0000 (11:01 +0100)] 
gh-101760: Improve the imaplib.IMAP4 example (#101764)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
19 months agoAdd cumulative option for the new statistics.kde() function. (#117033)
Raymond Hettinger [Sun, 24 Mar 2024 09:35:58 +0000 (11:35 +0200)] 
Add cumulative option for the new statistics.kde() function. (#117033)

19 months agogh-112383: teach dis how to interpret ENTER_EXECUTOR (#117171)
Irit Katriel [Sat, 23 Mar 2024 22:32:33 +0000 (22:32 +0000)] 
gh-112383: teach dis how to interpret ENTER_EXECUTOR (#117171)

19 months agogh-117180: Complete call sequence when trace stack overflow (GH-117184)
Ken Jin [Sat, 23 Mar 2024 22:19:17 +0000 (06:19 +0800)] 
gh-117180: Complete call sequence when trace stack overflow (GH-117184)

---------

Co-authored-by: Peter Lazorchak <lazorchakp@gmail.com>
Co-authored-by: Guido van Rossum <gvanrossum@users.noreply.github.com>
Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
19 months agogh-91227: Ignore ERROR_PORT_UNREACHABLE in proactor recvfrom() (#32011)
Erik Soma [Sat, 23 Mar 2024 15:39:35 +0000 (11:39 -0400)] 
gh-91227: Ignore ERROR_PORT_UNREACHABLE in proactor recvfrom() (#32011)

19 months agogh-117008: Fix functools test_recursive_pickle() (#117009)
Victor Stinner [Sat, 23 Mar 2024 12:01:20 +0000 (13:01 +0100)] 
gh-117008: Fix functools test_recursive_pickle() (#117009)

Use support.infinite_recursion() in test_recursive_pickle() of
test_functools to prevent a stack overflow on "ARM64 Windows
Non-Debug" buildbot.

Lower Py_C_RECURSION_LIMIT to 1,000 frames on Windows ARM64.

19 months agoGH-106747: Document another difference between `glob` and `pathlib`. (#116518)
Barney Gale [Fri, 22 Mar 2024 19:14:09 +0000 (19:14 +0000)] 
GH-106747: Document another difference between `glob` and `pathlib`. (#116518)

Document that `path.glob()` might return *path*, whereas
`glob.glob(root_dir=path)` will never return an empty string corresponding
to *path*.

19 months agoGH-117108: Change the size of the GC increment to about 1% of the total heap size...
Mark Shannon [Fri, 22 Mar 2024 18:43:25 +0000 (18:43 +0000)] 
GH-117108: Change the size of the GC increment to about 1% of the total heap size. (GH-117120)

19 months agogh-113024: C API: Add PyObject_GenericHash() function (GH-113025)
Serhiy Storchaka [Fri, 22 Mar 2024 18:19:10 +0000 (20:19 +0200)] 
gh-113024: C API: Add PyObject_GenericHash() function (GH-113025)

19 months agogh-117084: Fix ZIP file extraction for directory entry names with backslashes on...
Serhiy Storchaka [Fri, 22 Mar 2024 18:08:00 +0000 (20:08 +0200)] 
gh-117084: Fix ZIP file extraction for directory entry names with backslashes on Windows (GH-117129)

19 months agogh-117134: Microoptimize glob() for include_hidden=True (GH-117135)
Serhiy Storchaka [Fri, 22 Mar 2024 18:03:48 +0000 (20:03 +0200)] 
gh-117134: Microoptimize glob() for include_hidden=True (GH-117135)

19 months ago[docs] Fix typo in docstring and add example to logging cookbook. (GH-117157)
Vinay Sajip [Fri, 22 Mar 2024 17:25:51 +0000 (17:25 +0000)] 
[docs] Fix typo in docstring and add example to logging cookbook. (GH-117157)

19 months agoGH-113171: Fix "private" (non-global) IP address ranges (GH-113179)
Jakub Stasiak [Fri, 22 Mar 2024 16:49:56 +0000 (17:49 +0100)] 
GH-113171: Fix "private" (non-global) IP address ranges (GH-113179)

* GH-113171: Fix "private" (really non-global) IP address ranges

The _private_networks variables, used by various is_private
implementations, were missing some ranges and at the same time had
overly strict ranges (where there are more specific ranges considered
globally reachable by the IANA registries).

This patch updates the ranges with what was missing or otherwise
incorrect.

I left 100.64.0.0/10 alone, for now, as it's been made special in [1]
and I'm not sure if we want to undo that as I don't quite understand the
motivation behind it.

The _address_exclude_many() call returns 8 networks for IPv4, 121
networks for IPv6.

[1] https://github.com/python/cpython/issues/61602

19 months agoFix get_packagefamilyname helper function on Windows 32-bit (GH-117153)
Steve Dower [Fri, 22 Mar 2024 15:00:50 +0000 (15:00 +0000)] 
Fix get_packagefamilyname helper function on Windows 32-bit (GH-117153)

19 months agogh-117068: Remove useless code in bytesio.c:resize_buffer() (GH-117069)
NGRsoftlab [Fri, 22 Mar 2024 11:25:38 +0000 (14:25 +0300)] 
gh-117068: Remove useless code in bytesio.c:resize_buffer() (GH-117069)

Co-authored-by: i.khabibulin <i.khabibulin@ngrsoftlab.ru>
19 months agogh-117127: glob tests: Reopen dir_fd to pick up directory changes (GH-117128)
Petr Viktorin [Fri, 22 Mar 2024 09:42:18 +0000 (10:42 +0100)] 
gh-117127: glob tests: Reopen dir_fd to pick up directory changes (GH-117128)

19 months agoGH-116939: Rewrite binarysort() (#116940)
Tim Peters [Fri, 22 Mar 2024 03:27:25 +0000 (22:27 -0500)] 
GH-116939: Rewrite binarysort() (#116940)

Rewrote binarysort() for clarity.

Also changed the signature to be more coherent (it was mixing sortslice with raw pointers).

No change in method or functionality. However, I left some experiments in, disabled for now
via `#if` tricks. Since this code was first written, some kinds of comparisons have gotten
enormously faster (like for lists of floats), which changes the tradeoffs.

For example, plain insertion sort's simpler innermost loop and highly predictable branches
leave it very competitive (even beating, by a bit) binary insertion when comparisons are
very cheap, despite that it can do many more compares. And it wins big on runs that
are already sorted (moving the next one in takes only 1 compare then).

So I left code for a plain insertion sort, to make future experimenting easier.

Also made the maximum value of minrun a `#define` (``MAX_MINRUN`) to make
experimenting with that easier too.

And another bit of `#if``-disabled code rewrites binary insertion's innermost loop to
remove its unpredictable branch. Surprisingly, this doesn't really seem to help
overall. I'm unclear on why not. It certainly adds more instructions, but they're very
simple, and it's hard to be believe they cost as much as a branch miss.

19 months agogh-108716:: Remove _PyStaticCode_Init/Fini (#117141)
Guido van Rossum [Fri, 22 Mar 2024 01:27:48 +0000 (18:27 -0700)] 
gh-108716:: Remove _PyStaticCode_Init/Fini (#117141)

More deepfreeze cleanup.

19 months agogh-105716: Fix _PyInterpreterState_IsRunningMain() For Embedders (gh-117140)
Eric Snow [Fri, 22 Mar 2024 00:20:20 +0000 (18:20 -0600)] 
gh-105716: Fix _PyInterpreterState_IsRunningMain() For Embedders (gh-117140)

When I added _PyInterpreterState_IsRunningMain() and friends last year, I tried to accommodate applications that embed Python but don't call _PyInterpreterState_SetRunningMain() (not that they're expected to).  That mostly worked fine until my recent changes in gh-117049, where the subtleties with the fallback code led to failures; the change ended up breaking test_tools.test_freeze, which exercises a basic embedding situation.

The simplest fix is to drop the fallback code I originally added to _PyInterpreterState_IsRunningMain() (and later to _PyThreadState_IsRunningMain()).  I've kept the fallback in the _xxsubinterpreters module though.  I've also updated Py_FrozenMain() to call _PyInterpreterState_SetRunningMain().

19 months agogh-116745: Remove all internal usage of @LIBPYTHON@ (#116746)
Thomas A Caswell [Thu, 21 Mar 2024 23:54:50 +0000 (19:54 -0400)] 
gh-116745: Remove all internal usage of @LIBPYTHON@ (#116746)

Replace with MODULE_LDFLAGS.

19 months agogh-71052: Add Android build script and instructions (#116426)
Malcolm Smith [Thu, 21 Mar 2024 23:52:29 +0000 (23:52 +0000)] 
gh-71052: Add Android build script and instructions (#116426)

19 months agogh-117061: Fix test_posix.test_sched_setaffinity() on RHEL9 (#117126)
Victor Stinner [Thu, 21 Mar 2024 22:17:09 +0000 (23:17 +0100)] 
gh-117061: Fix test_posix.test_sched_setaffinity() on RHEL9 (#117126)

On RHEL9, sched_setaffinity(0, []) does not fail.

19 months agodocs: fix over-linking in dataclasses.rst (#117005)
Ned Batchelder [Thu, 21 Mar 2024 19:47:09 +0000 (15:47 -0400)] 
docs: fix over-linking in dataclasses.rst (#117005)

19 months agogh-117045: Add code object to function version cache (#117028)
Guido van Rossum [Thu, 21 Mar 2024 19:37:41 +0000 (12:37 -0700)] 
gh-117045: Add code object to function version cache (#117028)

Changes to the function version cache:

- In addition to the function object, also store the code object,
  and allow the latter to be retrieved even if the function has been evicted.
- Stop assigning new function versions after a critical attribute (e.g. `__code__`)
  has been modified; the version is permanently reset to zero in this case.
- Changes to `__annotations__` are no longer considered critical. (This fixes gh-109998.)

Changes to the Tier 2 optimization machinery:

- If we cannot map a function version to a function, but it is still mapped to a code object,
  we continue projecting the trace.
  The operand of the `_PUSH_FRAME` and `_POP_FRAME` opcodes can be either NULL,
  a function object, or a code object with the lowest bit set.

This allows us to trace through code that calls an ephemeral function,
i.e., a function that may not be alive when we are constructing the executor,
e.g. a generator expression or certain nested functions.
We will lose globals removal inside such functions,
but we can still do other peephole operations
(and even possibly [call inlining](https://github.com/python/cpython/pull/116290),
if we decide to do it), which only need the code object.
As before, if we cannot retrieve the code object from the cache, we stop projecting.

19 months agogh-116333: Relax error string text expectations in SSL-related tests (GH-116334)
Will Childs-Klein [Thu, 21 Mar 2024 19:16:36 +0000 (14:16 -0500)] 
gh-116333: Relax error string text expectations in SSL-related tests (GH-116334)

* Relax error string text expectations in SSL-related tests

As suggested [here][1], this change relaxes the OpenSSL error string
text expectations in a number of tests. This was specifically done in
support of more easily building CPython [AWS-LC][2], but because AWS-LC
is a fork of [BoringSSL][3], it should increase compatibility with that
library as well.

In addition to the error string relaxations, we also add some guards
around the `tls-unique` channel binding being used with TLSv1.3, as that
feature (described in [RFC 6929][4]) is [not defined][5] for TLSv1.3.

[1]: https://discuss.python.org/t/support-building-ssl-and-hashlib-modules-against-aws-lc/44505/4
[2]: https://github.com/aws/aws-lc
[3]: https://github.com/google/boringssl
[4]: https://datatracker.ietf.org/doc/html/rfc5929#section-3
[5]: https://datatracker.ietf.org/doc/html/rfc8446#appendix-C.5

19 months agogh-116522: Refactor `_PyThreadState_DeleteExcept` (#117131)
Sam Gross [Thu, 21 Mar 2024 18:21:02 +0000 (14:21 -0400)] 
gh-116522: Refactor `_PyThreadState_DeleteExcept` (#117131)

Split `_PyThreadState_DeleteExcept` into two functions:

- `_PyThreadState_RemoveExcept` removes all thread states other than one
  passed as an argument. It returns the removed thread states as a
  linked list.

- `_PyThreadState_DeleteList` deletes those dead thread states. It may
  call destructors, so we want to "start the world" before calling
  `_PyThreadState_DeleteList` to avoid potential deadlocks.

19 months agogh-116996: Add pystats about _Py_uop_analyse_and_optimize (GH-116997)
Michael Droettboom [Thu, 21 Mar 2024 17:27:46 +0000 (13:27 -0400)] 
gh-116996: Add pystats about _Py_uop_analyse_and_optimize (GH-116997)

19 months agogh-76785: Drop PyInterpreterID_Type (gh-117101)
Eric Snow [Thu, 21 Mar 2024 17:15:02 +0000 (11:15 -0600)] 
gh-76785: Drop PyInterpreterID_Type (gh-117101)

I added it quite a while ago as a strategy for managing interpreter lifetimes relative to the PEP 554 (now 734) implementation.  Relatively recently I refactored that implementation to no longer rely on InterpreterID objects.  Thus now I'm removing it.

19 months agogh-85283: Build _testconsole extension with limited C API (#117125)
Victor Stinner [Thu, 21 Mar 2024 16:45:43 +0000 (17:45 +0100)] 
gh-85283: Build _testconsole extension with limited C API (#117125)

19 months agogh-115754: Add Py_GetConstant() function (#116883)
Victor Stinner [Thu, 21 Mar 2024 16:07:00 +0000 (17:07 +0100)] 
gh-115754: Add Py_GetConstant() function (#116883)

Add Py_GetConstant() and Py_GetConstantBorrowed() functions.

In the limited C API version 3.13, getting Py_None, Py_False,
Py_True, Py_Ellipsis and Py_NotImplemented singletons is now
implemented as function calls at the stable ABI level to hide
implementation details. Getting these constants still return borrowed
references.

Add _testlimitedcapi/object.c and test_capi/test_object.py to test
Py_GetConstant() and Py_GetConstantBorrowed() functions.

19 months agogh-105716: Update interp->threads.main After Fork (gh-117049)
Eric Snow [Thu, 21 Mar 2024 16:06:35 +0000 (10:06 -0600)] 
gh-105716: Update interp->threads.main After Fork (gh-117049)

I missed this in gh-109921.

We also update Py_Exit() to call _PyInterpreterState_SetNotRunningMain(), if necessary.

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`.