Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert _ctypes static types (and the "meta class") to heap types #114314

Closed
Tracked by #103092
vstinner opened this issue Jan 19, 2024 · 19 comments
Closed
Tracked by #103092

Convert _ctypes static types (and the "meta class") to heap types #114314

vstinner opened this issue Jan 19, 2024 · 19 comments
Labels
extension-modules C modules in the Modules dir topic-C-API type-feature A feature request or enhancement

Comments

@vstinner
Copy link
Member

vstinner commented Jan 19, 2024

Feature or enhancement

The _ctypes extension implements types as static types. They should be converted to heap types: see issue gh-103092 for the rationale.

Problem: the PyCStgDict type is kind of special, it's a "metaclass" which creates a new class and then replaces the class namespace (type dict) with a custom "stgdict". See the PyCStructType_new() function.

Previous attempts to convert _ctypes types to heap types:

Linked PRs

@vstinner
Copy link
Member Author

Example with _ctypes.Structure:

$ ./python
>>> import _ctypes
>>> type(_ctypes.Structure)
<class '_ctypes.PyCStructType'>
>>> _ctypes.Structure.__bases__
(<class '_ctypes._CData'>,)
>>> _ctypes.Structure.__base__
<class '_ctypes._CData'>

In Python, such type would be defined with a syntax like:

class Structure(_CData, metaclass=PyCStructType):
    ...

When a subclass is created, PyCStructType_new() is called. Example of subclass:

class MyStruct(_ctypes.Structure):
   ...

In C, PyCStructType_Type can be retrieved from global_state.PyCStructType_Type global variable.

(gdb) p global_state.PyCStructType_Type.tp_new
$12 = (newfunc) 0x7fffea18739f <PyCStructType_new>

(gdb) p global_state.PyCStructType_Type.tp_init
$13 = (initproc) 0x59321c <type_init>

(gdb) p global_state.PyCStructType_Type.tp_name
$14 = 0x7fffea57a230 "_ctypes.PyCStructType"

Main steps of PyCStructType_new():

  • Create a new type by calling PyType_Type.tp_new(type, args, kwds) where type is PyCStructType_Type.

  • Type members are initialized to:

    • tp_name = "MyStruct"
    • tp_new = GenericPyCData_new() -- inherited from _ctypes.Structure.tp_new
    • tp_init = Struct_init() -- inherited from _ctypes.Structure.tp_init
  • Override tp_dict with an instance of ctypes PyCStgDict_Type (which inherits from dict).

Example showing that tp_dict type is PyCStgDict_Type instead of dict:

>>> import _ctypes
>>> import _testcapi
>>> class MyStruct(_ctypes.Structure): pass
... 
>>> d=_testcapi.type_get_tp_dict(MyStruct)  # I added this function locally just for this example
>>> type(d)
<class 'StgDict'>

@erlend-aasland erlend-aasland added the extension-modules C modules in the Modules dir label Jan 19, 2024
vstinner added a commit to vstinner/cpython that referenced this issue Jan 19, 2024
Move types to the ctypes_state structure:

* PyCArray_Type
* PyCData_Type
* PyCFuncPtr_Type
* PyCPointer_Type
* Simple_Type

The following macros get an additional state parameter:

* ArrayObject_Check()
* CDataObject_Check()
* CDataObject_CheckExact()
* PointerObject_Check()
* PyCFuncPtrObject_Check()

The following function gets an additional state parameter:

* _PyCData_set()

Co-Authored-By: neonene <[email protected]>
@vstinner
Copy link
Member Author

vstinner commented Jan 22, 2024

First step: merged PR #113857

@vstinner
Copy link
Member Author

vstinner commented Jan 22, 2024

See merged PR #113620.

@encukou
Copy link
Member

encukou commented Jan 23, 2024

It seems that stgdict is a workaround for the issue PEP-697 is designed to solve: have additional C data on a type.
If no one else is interested in this, I can try my hand at replacing the extra stgdict fields by PyObject_GetTypeData(o, _ctypes.PyCStructType).

@erlend-aasland
Copy link
Contributor

It seems that stgdict is a workaround for the issue PEP-697 is designed to solve: have additional C data on a type. If no one else is interested in this, I can try my hand at replacing the extra stgdict fields by PyObject_GetTypeData(o, _ctypes.PyCStructType).

I agree; I already mentioned this in one of my (now closed) PRs. I think PEP-697 would be perfect for this.

@neonene
Copy link
Contributor

neonene commented Jan 30, 2024

replacing the extra stgdict fields by PyObject_GetTypeData(o, _ctypes.PyCStructType).

@encukou Could you be more specific, please? I posted a PR #114740, which seems to have become a different attempt.

@neonene
Copy link
Contributor

neonene commented Jan 30, 2024

@vstinner "PyCStgDict" words in the title and description are typos?

PyCStgDict is a dictionary subclass rather than a metaclass, I think.

@vstinner vstinner changed the title Convert _ctypes PyCStgDict meta static type to a meta heap type Convert _ctypes static types (and the "meta class") to heap types Jan 31, 2024
@vstinner
Copy link
Member Author

I changed the title to make it more generic.

@encukou
Copy link
Member

encukou commented Jan 31, 2024

Could you be more specific, please?

I am now getting familiar with _ctypes (by implementing a proof of concept of my proposal).
I'll give you something more specific next week.

@encukou
Copy link
Member

encukou commented Feb 9, 2024

Unfortunately, while I did put in some time, I don't have a concrete PR just yet. _ctypes is big :(

The approach I'm trying is to put the extra (non-dict) stuff from StgDict in in the types, using the PEP-697 mechanism (relative basicsize & PyObject_GetTypeData). The tp_dict can then remain as a regular dict.
So far I haven't hit any unsurmountable obstacle, but I also haven't been able to align all the moving parts to make it work. I'll return to it next week.

@encukou
Copy link
Member

encukou commented Feb 23, 2024

Since the last comment, it took 2 weeks (not full-time of course), but I have a rough proof of concept. Bad news is that it's big (9 files changed, 1358 insertions(+), 1365 deletions(-)), and leaky as I ignored some details for the PoC (test_ctypes leaked [17495, 17467, 17489, 17479] references, sum=69930).
The PoC is here: main...encukou:cpython:ctypes-no-stgdict

What this does:

  • Instead of using StgDict, a dict subclass with additional info that gets substituted as tp_dict of the classes, the data is stored in the type instance itself, in StgInfo. The metaclass, PyCType_Type, is defined with basicsize = -sizeof(StgInfo) (i.e. “reserve extra space for StgInfo), and the info is accessed by a helper that calls PyObject_GetTypeData(type, state->PyCType_Type).
  • To fit this info in while the types weren't yet converted (and so didn't honor the metaclass's basicsize), I temporarily defined them not as PyTypeObject, but as:
    typedef struct {
        PyHeapTypeObject ht;
        StgInfo info;
    } _HackyHeapType;
    This hack is removed as soon as the class becomes a heap type.
  • Now that the metaclass tp_new doesn't override tp_dict of its class, I feel comfortable moving the initialization logic to tp_init. (There should be guards against calling __init__ twice or not at all -- my PoC doesn't do this yet.)

To keep everything straight during the transition, I renamed all the StgDict variables (stgdict, dict, edict etc.) as I moved to StgInfo (so, stginfo, info, einfo, etc.). Where the dict is actually used for class attributes (as a regular PyDict), I named it attrdict.
This made things much more straightforward, but it also results in a big diff. I wonder if it's worth minimizing the diff.

The next steps would be:

  • Guard against calling __init__ twice or not at all, and test this
  • Remove the refleak :)

But I see the end of the tunnel; I'm rather confident it's possible!

Does this still look like a reasonable approach? Would anyone want to review the big PR, once it's done?

@erlend-aasland
Copy link
Contributor

This is good news, @encukou! Looking forward to review it :)

@neonene
Copy link
Contributor

neonene commented Feb 25, 2024

I agree with this dict type conversion.

  • Guard against calling __init__ twice or not at all,

I saw __init_subclass__ defined in typevarobject.c:

static PyMethodDef generic_methods[] = {
    {"__init_subclass__", (PyCFunction)(void (*)(void))generic_init_subclass,
     METH_VARARGS | METH_KEYWORDS | METH_CLASS, ...

I like the tight sequence between __new__ and __init_subclass__. Then __init__ can follow if there is no error. If acceptable, PyCSimpleType_init (and CreateSwappedType) function might be safer to be invoked at __init_subclass__ phase.

The disadvantage is that __init_subclass__ receives no namespace argument, so the __build_class__ related names, including the __classcell__ and __classdictcell__ entries, need to be gathered from __dict__ and elsewhere.

@neonene
Copy link
Contributor

neonene commented Feb 25, 2024

test_ctypes leaked [17495, 17467, 17489, 17479] references, sum=69930

Not fully confirmed with a crash, but it seems like CType_Type_dealloc() prefers type_dealloc(), which sub metatypes inherit:

CType_Type_dealloc(PyObject *self)
{
    ...
    PyTypeObject *tp = Py_TYPE(self);
    PyObject_GC_UnTrack(self);
    (void)CType_Type_clear(self);
-   tp->tp_free(self);
+   PyObject_GC_Track(self);
+   PyType_Type.tp_dealloc(self);
    Py_DECREF(tp);
}

@encukou
Copy link
Member

encukou commented Feb 26, 2024

Guard against calling __init__ twice or not at all

The main issue here is that __init__ can be called at any time by Python code. And so can __init_subclass__.
Another is that __init__ can be skipped by calling __new__ directly. (Most likely __init_subclass__ can too.)

So, there at least needs to be a C flag that prevents using unintialized data, and re-initializing data. So if you do the wrong thing in Python code, you get an exception, not a crash.
Possibly, we could instead initialize “lazily”, at first access, and skip initialization if things are already set up. But that's not always possible.

The ideal would be for the VM to do this for you -- e.g. we add a new tp_cinit slot. But I'm sticking to existing API here for now: I don't think I've seen enough use cases yet to generalize them into a good general API.

@neonene
Copy link
Contributor

neonene commented Feb 26, 2024

@encukou I confirmed on Windows that the given PoC can pass ctypes tests with any heap type. The other refleaks came from PyType_GetDict(), which returns a new reference. And Windows-specific crashes could be fixed by a few changes like:

  • callbacks.c
TryAddRef(PyObject *cnv, CDataObject *obj)
{
    IUnknown *punk;
+   PyObject *attrdict = _PyType_GetDict((PyTypeObject *)cnv);
+   if (!attrdict) {
+       return;
+   }
+   int r = PyDict_Contains(attrdict, &_Py_ID(_needs_com_addref_));
-   int r = PyObject_GetAttrString((PyObject *)cnv, "_needs_com_addref_");
  • callproc.c
ffi_type *_ctypes_get_ffi_type(PyObject *obj)
{
+   if (obj == NULL) {
+      return &ffi_type_sint;
+   }

encukou added a commit that referenced this issue Mar 20, 2024
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 <[email protected]>
Co-authored-by: Erlend E. Aasland <[email protected]>
@encukou
Copy link
Member

encukou commented Mar 20, 2024

Thanks for all the encouragement and reviews!

I've merged the PR, and will watch the buildbots (and bug reports) for any unexpected issues.
I guess isolation of _ctypes module state should continue in #103092. It might take a few PRs, so maybe it could use a new issue.

@encukou encukou closed this as completed Mar 20, 2024
@erlend-aasland
Copy link
Contributor

I guess isolation of _ctypes module state should continue in #103092. It might take a few PRs, so maybe it could use a new issue.

I think it would be beneficial with a dedicated issue. It will not be straight-forward, I suspect.

adorilson pushed a commit to adorilson/cpython that referenced this issue Mar 25, 2024
…honGH-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 <[email protected]>
Co-authored-by: Erlend E. Aasland <[email protected]>
NGRsoftlab pushed a commit to NGRsoftlab/cpython that referenced this issue Apr 2, 2024
commit 9dae05ee59eeba0e67af2a46f2a2907c9f8d7e4a
Author: Moshe Kaplan <[email protected]>
Date:   Mon Apr 1 15:53:00 2024 -0400

    Docs: specify XML document name in xml.etree.elementtree example (#24223)

commit fc2071687b708598264a3403b7f9104667c1092f
Author: Matthew Davis <[email protected]>
Date:   Mon Apr 1 21:49:14 2024 +0200

    Docs: add more links to PIPE in subprocess docs (#25416)

commit fc8007ee3635db6ab73e132ebff987c910b6d538
Author: Barney Gale <[email protected]>
Date:   Mon Apr 1 20:37:41 2024 +0100

    GH-117337: Deprecate `glob.glob0()` and `glob.glob1()`. (#117371)

    These undocumented functions are no longer used by `msilib`, so there's no
    reason to keep them around.

commit c741ad3537193c63fe697a8f0316aecd45eeb9ba
Author: Justin Turner Arthur <[email protected]>
Date:   Mon Apr 1 12:07:29 2024 -0500

    gh-77714: Provide an async iterator version of as_completed (GH-22491)

    * as_completed returns object that is both iterator and async iterator
    * Existing tests adjusted to test both the old and new style
    * New test to ensure iterator can be resumed
    * New test to ensure async iterator yields any passed-in Futures as-is

    Co-authored-by: Serhiy Storchaka <[email protected]>
    Co-authored-by: Guido van Rossum <[email protected]>

commit ddf814db744006e0f42328aa15ace97c9d8ad681
Author: Guido van Rossum <[email protected]>
Date:   Mon Apr 1 09:13:38 2024 -0700

    Silence compiler warnings in gc.c (#117422)

commit 179869af922252a0c1cef65fd2923856895e7d1b
Author: Petr Viktorin <[email protected]>
Date:   Mon Apr 1 17:01:22 2024 +0200

    gh-94808: Fix refcounting in PyObject_Print tests (GH-117421)

commit dd44ab994b7262f0704d64996e0a1bc37b233407
Author: neonene <[email protected]>
Date:   Mon Apr 1 22:28:14 2024 +0900

    gh-117142: ctypes: Unify meta tp slot functions (GH-117143)

    Integrates the following ctypes meta tp slot functions:
    * `CDataType_traverse()` into `CType_Type_traverse()`.
    * `CDataType_clear()` into `CType_Type_clear()`.
    * `CDataType_dealloc()` into `CType_Type_dealloc()`.
    * `CDataType_repeat()` into `CType_Type_repeat()`.

commit 3de09cadde788065a4f2d45117e789c9353bbd12
Author: Steve (Gadget) Barnes <[email protected]>
Date:   Mon Apr 1 14:02:07 2024 +0100

    gh-91565: Replace bugs.python.org links with Devguide/GitHub ones  (GH-91568)

    Co-authored-by: Hugo van Kemenade <[email protected]>
    Co-authored-by: Oleg Iarygin <[email protected]>
    Co-authored-by: Petr Viktorin <[email protected]>
    Co-authored-by: Ezio Melotti <[email protected]>

commit 90c3c68a658db6951b77a5be50088ec2f6adc8eb
Author: MonadChains <[email protected]>
Date:   Mon Apr 1 13:52:25 2024 +0100

    gh-94808:Improve coverage of PyObject_Print (GH-98749)

commit 348cf6e0078eae156c503e8f61ef5e27ae28e57b
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Mon Apr 1 11:14:37 2024 +0000

    Bump mypy from 1.8.0 to 1.9.0 in /Tools (#117418)

    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Co-authored-by: Alex Waygood <[email protected]>

commit 9b403fb559bfce93a478937e0ef7e539a9a95283
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Mon Apr 1 11:05:14 2024 +0000

    build(deps-dev): bump types-psutil from 5.9.5.20240205 to 5.9.5.20240316 in /Tools (#117417)

    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Co-authored-by: Alex Waygood <[email protected]>

commit 93c7d9d17b571b6a181af7c02830d29819535c35
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Mon Apr 1 11:38:38 2024 +0100

    build(deps-dev): bump types-setuptools from 69.1.0.20240301 to 69.2.0.20240317 in /Tools (#117419)

    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit 3bb12e407c183946471272f8aee098e54e62a333
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Mon Apr 1 09:54:33 2024 +0000

    build(deps): bump actions/add-to-project from 0.6.0 to 1.0.0 (#117415)

    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit 56e99307c49adcc6df355f8070229371c97d654f
Author: Adorilson Bezerra <[email protected]>
Date:   Sun Mar 31 23:34:54 2024 +0100

    Doc: printf-style library/stdtype improvements (#16741)

commit 18e12641a61a88f7d08b2114ebe965892c6661c5
Author: Raymond Hettinger <[email protected]>
Date:   Sun Mar 31 16:09:22 2024 -0500

    gh-117387 Remove hash mark from introductory text (#117409)

commit a32d6939486d7f90ee57e215077f6116e19de24d
Author: Deborah <[email protected]>
Date:   Sun Mar 31 22:11:48 2024 +0200

    gh-102190: Add additional zipfile `pwd=` arg docstrings (gh-102195)

    This just documents the parameter that already exists.

    ---------

    Co-authored-by: Gregory P. Smith <[email protected]>
    Co-authored-by: Erlend E. Aasland <[email protected]>

commit 262445358e21c56d7c68e3ee76c13e469d2ea348
Author: Shantanu <[email protected]>
Date:   Sun Mar 31 12:02:48 2024 -0700

    Link to the Python type system specification (#117400)

commit 752e18389ed03087b51b38eac9769ef8dfd167b7
Author: Barney Gale <[email protected]>
Date:   Sun Mar 31 19:14:48 2024 +0100

    GH-114575: Rename `PurePath.pathmod` to `PurePath.parser` (#116513)

    And rename the private base class from `PathModuleBase` to `ParserBase`.

commit bfc57d43d8766120ba0c8f3f6d7b2ac681a81d8a
Author: Sam Gross <[email protected]>
Date:   Fri Mar 29 18:58:08 2024 -0400

    gh-117303: Don't detach in `PyThreadState_DeleteCurrent()` (#117304)

    This fixes a crash in `test_threading.test_reinit_tls_after_fork()` when
    running with the GIL disabled. We already properly handle the case where
    the thread state is `_Py_THREAD_ATTACHED` in `tstate_delete_common()` --
    we just need to remove an assertion.

    Keeping the thread attached means that a stop-the-world pause, such as
    for a `fork()`, won't commence until we remove our thread state from the
    interpreter's linked list. This prevents a crash when the child process
    tries to clean up the dead thread states.

commit 05e0b67a43c5c1778dc2643c8b7c12864e135999
Author: Erlend E. Aasland <[email protected]>
Date:   Fri Mar 29 21:23:28 2024 +0100

    gh-116664: In _warnings.c, make filters_version access thread-safe (#117374)

    - assert that the lock is held in already_warned()
    - protect 'filters_version' increment in warnings_filters_mutated_impl()

commit 019143fecbfc26e69800d28d2a9e3392a051780b
Author: Jason R. Coombs <[email protected]>
Date:   Fri Mar 29 16:06:09 2024 -0400

    gh-117348: Refactored RawConfigParser._read for similicity and comprehensibility (#117372)

    * Extract method for _read_inner, reducing complexity and indentation by 1.

    * Extract method for _raise_all and yield ParseErrors from _read_inner.

    Reduces complexity by 1 and reduces touch points for handling errors in _read_inner.

    * Prefer iterators to splat expansion and literal indexing.

    * Extract method for _strip_comments. Reduces complexity by 7.

    * Model the file lines in a class to encapsulate the comment status and cleaned value.

    * Encapsulate the read state as a dataclass

    * Extract _handle_continuation_line and _handle_rest methods. Reduces complexity by 8.

    * Reindent

    * At least for now, collect errors in the ReadState

    * Check for missing section header separately.

    * Extract methods for _handle_header and _handle_option. Reduces complexity by 6.

    * Remove unreachable code. Reduces complexity by 4.

    * Remove unreachable branch

    * Handle error condition early. Reduces complexity by 1.

    * Add blurb

    * Move _raise_all to ParsingError, as its behavior is most closely related to the exception class and not the reader.

    * Split _strip* into separate methods.

    * Refactor _strip_full to compute the strip just once and use 'not any' to determine the factor.

    * Replace use of 'sys.maxsize' with direct computation of the stripped value.

    * Extract has_comments as a dynamic property.

    * Implement clean as a cached property.

    * Model comment prefixes in the RawConfigParser within a prefixes namespace.

    * Use a regular expression to search for the first match.

    Avoids mutating variables and tricky logic and over-computing all of the starts when only the first is relevant.

commit 01bd74eadbc4ff839d39762fae6366f50c1e116e
Author: Sam Gross <[email protected]>
Date:   Fri Mar 29 15:33:06 2024 -0400

    gh-117300: Use stop the world to make `sys._current_frames` and `sys._current_exceptions` thread-safe. (#117301)

    This adds a stop the world pause to make the two functions thread-safe
    when the GIL is disabled in the free-threaded build.

    Additionally, the main test thread may call `sys._current_exceptions()` as
    soon as `g_raised.set()` is called. The background thread may not yet reach
    the `leave_g.wait()` line.

commit 94c97423a9c4969f8ddd4a3aa4aacb99c4d5263d
Author: Guido van Rossum <[email protected]>
Date:   Fri Mar 29 11:31:09 2024 -0700

    Fix broken format in error for bad input in summarize_stats.py (#117375)

    When you pass the script a non-existent input file, you get a TypeError instead of the intended ValueError.

commit 5d21d884b6ffa45dac50a5f9a07c41356a8478b4
Author: mpage <[email protected]>
Date:   Fri Mar 29 10:42:02 2024 -0700

    gh-111926: Avoid locking in PyType_IsSubtype (#117275)

    Read the MRO in a thread-unsafe way in `PyType_IsSubtype` to avoid locking. Fixing this is tracked in #117306.

    The motivation for this change is in support of making weakrefs thread-safe in free-threaded builds:

    `WeakValueDictionary` uses a special dictionary function, `_PyDict_DelItemIf`
    to remove dead weakrefs from the dictionary. `_PyDict_DelItemIf` removes a key
    if a user supplied predicate evaluates to true for the value associated with
    the key. Crucially for the `WeakValueDictionary` use case, the predicate
    evaluation + deletion sequence is atomic, provided that the predicate doesn’t
    suspend. The predicate used by `WeakValueDictionary` includes a subtype check,
    which we must ensure doesn't suspend in free-threaded builds.

commit 19c1dd60c5b53fb0533610ad139ef591294f26e8
Author: Sam Gross <[email protected]>
Date:   Fri Mar 29 13:35:43 2024 -0400

    gh-117323: Make `cell` thread-safe in free-threaded builds (#117330)

    Use critical sections to lock around accesses to cell contents. The critical sections are no-ops in the default (with GIL) build.

commit 397d88db5e9ab2a43de3fdf5f8b973a949edc405
Author: Sam Gross <[email protected]>
Date:   Fri Mar 29 13:34:04 2024 -0400

    gh-117344: Skip flaky tests in free-threaded build (#117355)

    The tests are not reliable with the GIL disabled. In theory, they can
    fail with the GIL enabled too, but the failures are much more likely
    with the GIL disabled.

commit f05fb2e65c2dffdfae940f2707765c4994925205
Author: Sam Gross <[email protected]>
Date:   Fri Mar 29 13:33:04 2024 -0400

    gh-112529: Don't untrack tuples or dicts with zero refcount (#117370)

    The free-threaded GC sometimes sees objects with zero refcount. This can
    happen due to the delay in merging biased reference counting fields,
    and, in the future, due to deferred reference counting. We should not
    untrack these objects or they will never be collected.

    This fixes the refleaks in the free-threaded build.

commit ddf95b5f16031cdbd0d728e55eb06dff002a8678
Author: Erlend E. Aasland <[email protected]>
Date:   Fri Mar 29 18:26:06 2024 +0100

    gh-116664: Fix unused var warnings in _warnings.c in non-free-threaded builds (#117373)

    The warnings were introduced by commit c1712ef06.

commit 0fa571dbcdf19b541276cb00bb929381930467b2
Author: Tian Gao <[email protected]>
Date:   Fri Mar 29 09:02:01 2024 -0700

    Refactor pdb executable targets (#112570)

    Co-authored-by: Jason R. Coombs <[email protected]>

commit 54f7e14500471d1c46fb553adb3ca24cd1fef084
Author: Pedro Lacerda <[email protected]>
Date:   Fri Mar 29 12:05:00 2024 -0300

    gh-66449: configparser: Add support for unnamed sections (#117273)

    Co-authored-by: Jason R. Coombs <[email protected]>

commit d9cfe7e565a6e2dc15747a904736264e31a10be4
Author: Nikita Sobolev <[email protected]>
Date:   Fri Mar 29 14:14:25 2024 +0300

    gh-117166: Ignore empty and temporary dirs in `test_makefile` (#117190)

commit 35b6c4a4da201a947b2ceb96ae4c0d83d4d2df4f
Author: Victor Stinner <[email protected]>
Date:   Fri Mar 29 11:25:17 2024 +0100

    gh-117347: Fix test_clinic side effects (#117363)

    Save/restore converters in ClinicWholeFileTest and
    ClinicExternalTest.

commit 7e2fef865899837c47e91ef0180fa59eb03e840b
Author: neonene <[email protected]>
Date:   Fri Mar 29 18:40:48 2024 +0900

    gh-117142: ctypes: Migrate global vars to module state (GH-117189)

commit 2e9be80c99f635c2f7761e8356b0260922d6e7a6
Author: Gregory P. Smith <[email protected]>
Date:   Thu Mar 28 17:58:37 2024 -0700

    Fix reversed assertRegex checks in test_ssl. (#117351)

commit 8eec7ed714e65d616573b7331780b0aa43c6ed6a
Author: 傅立业(Chris Fu) <[email protected]>
Date:   Fri Mar 29 08:19:20 2024 +0800

    gh-117110: Fix subclasses of typing.Any with custom constructors (#117111)

commit a17f313e3958e825db9a83594c8471a984316536
Author: Christopher Chianelli <[email protected]>
Date:   Thu Mar 28 18:26:56 2024 -0400

    gh-117339: Use NULL instead of None for LOAD_SUPER_ATTR in dis docs (GH-117343)

commit 26d328b2ba26374fb8d9ffe8215ecef7c5e3f7a2
Author: Michael Droettboom <[email protected]>
Date:   Thu Mar 28 18:23:08 2024 -0400

    GH-117121: Add pystats to JIT builds (GH-117346)

commit 14f1ca7d5363386163839b31ce987423daecc3de
Author: Nice Zombies <[email protected]>
Date:   Thu Mar 28 22:20:08 2024 +0100

    gh-117335: Handle non-iterables for `ntpath.commonpath` (GH-117336)

commit 18cf239e39e25e6cef50ecbb7f197a82f8920ff5
Author: Brandt Bucher <[email protected]>
Date:   Thu Mar 28 14:02:34 2024 -0700

    Increase the JIT CI timeouts to 75 minutes (GH-117342)

commit 29829b58a8328a7c2ccacaa74c1d7d120a5e5ca5
Author: Malcolm Smith <[email protected]>
Date:   Thu Mar 28 19:59:12 2024 +0000

    gh-117294: Report DocTestCase as skipped if all examples in the doctest are skipped (GH-117297)

commit efcc96844e7c66fcd6c23ac2d557ca141614ce9a
Author: Tian Gao <[email protected]>
Date:   Thu Mar 28 11:23:29 2024 -0700

    gh-69201: Separate stdout and stderr stream in test_pdb (#117308)

commit 6702d2bf6edcd5b5415e17837383623b9d76a5b8
Author: Victor Stinner <[email protected]>
Date:   Thu Mar 28 17:40:58 2024 +0100

    gh-114331: Skip decimal test_maxcontext_exact_arith on s390x (#117326)

commit c1712ef066321c01bf09cba3f22fc474b5b8dfa7
Author: Erlend E. Aasland <[email protected]>
Date:   Thu Mar 28 16:05:08 2024 +0100

    gh-116664: Make module state Py_SETREF's in _warnings thread-safe (#116959)

    Mark the swap operations as critical sections.

    Add an internal Py_BEGIN_CRITICAL_SECTION_MUT API that takes a PyMutex
    pointer instead of a PyObject pointer.

commit 9a388b9a64927c372d85f0eaec3de9b7320a6fb5
Author: Joachim Wuttke <[email protected]>
Date:   Thu Mar 28 14:43:07 2024 +0100

    bpo-43848: explain optional argument mtime in gzip.py. (GH-25410)

    Co-authored-by: Jelle Zijlstra <[email protected]>

commit 8dbfdb2957a7baade3a88661517f163ad694c39f
Author: Sam Gross <[email protected]>
Date:   Thu Mar 28 09:28:39 2024 -0400

    gh-110481: Fix biased reference counting queue initialization. (#117271)

    The biased reference counting queue must be initialized from the bound
    (active) thread because it uses `_Py_ThreadId()` as the key in a hash
    table.

commit 9a1e55b8c5723206116f7016921be3937ef2f4e5
Author: Chris Markiewicz <[email protected]>
Date:   Thu Mar 28 06:59:31 2024 -0400

    gh-117178: Recover lazy loading of self-referential modules (#117179)

commit 4c71d51a4b7989fc8754ba512c40e21666f9db0d
Author: Jelle Zijlstra <[email protected]>
Date:   Thu Mar 28 04:30:31 2024 -0600

    gh-117266: Fix crashes on user-created AST subclasses (GH-117276)

    Fix crashes on user-created AST subclasses

commit 8cb7d7ff86a1a2d41195f01ba4f218941dd7308c
Author: Gregory P. Smith <[email protected]>
Date:   Thu Mar 28 03:11:58 2024 -0700

    gh-117310: Remove extra DECREF on "no ciphers" error path in `_ssl._SSLContext` constructor (#117309)

    Remove extra self DECREF on ssl "no ciphers" error path.

    This doesn't come up in practice because nobody links against a broken
    OpenSSL library that provides nothing.

commit 6c8ac8a32fd6de1960526561c44bc5603fab0f3e
Author: Erlend E. Aasland <[email protected]>
Date:   Thu Mar 28 09:40:37 2024 +0100

    gh-116303: Handle disabled test modules in test.support helpers (#116482)

    Make sure test.support helpers skip iso. failing if test extension
    modules are disabled. Also log TEST_MODULES in test.pythoninfo.

commit 0f27672c5002de96c9f1228b12460d5ce3f1d190
Author: Russell Keith-Magee <[email protected]>
Date:   Thu Mar 28 16:13:13 2024 +0800

    gh-114099: Add documentation for iOS platform (GH-117057)

    Co-authored-by: Hugo van Kemenade <[email protected]>
    Co-authored-by: Jacob Coffee <[email protected]>
    Co-authored-by: Malcolm Smith <[email protected]>
    Co-authored-by: Ned Deily <[email protected]>

commit f006338017cfbf846e8f7391b9ee5f69df8dc620
Author: Russell Keith-Magee <[email protected]>
Date:   Thu Mar 28 15:59:33 2024 +0800

    gh-114099: Additions to standard library to support iOS (GH-117052)

    Co-authored-by: Hugo van Kemenade <[email protected]>
    Co-authored-by: Malcolm Smith <[email protected]>
    Co-authored-by: Ned Deily <[email protected]>

commit b44898299a2ed97045c270f6474785da2ff07ced
Author: Tim Hatch <[email protected]>
Date:   Wed Mar 27 23:54:51 2024 -0700

    gh-89739: gh-77140: Support zip64 in zipimport (GH-94146)

    * Reads zip64 files as produced by the zipfile module
    * Include tests (somewhat slow, however, because of the need to create "large" zips)
    * About the same amount of strictness reading invalid zip files as zipfile has
    * Still works on files with prepended data (like pex)

    There are a lot more test cases at https://github.com/thatch/zipimport64/ that give me confidence that this works for real-world files.

    Fixes #89739 and #77140.

    ---------

    Co-authored-by: Itamar Ostricher <[email protected]>
    Reviewed-by: Gregory P. Smith <[email protected]>

commit 2cedd25c14d3acfdcb5e8ee55132ce3e334ab8fe
Author: Illia Volochii <[email protected]>
Date:   Thu Mar 28 08:46:01 2024 +0200

    Revert "gh-116886: Temporarily disable CIfuzz (memory) (GH-117018)" (GH-117289)

    This reverts commit 1ab0d0b1167d78bf19661a3b5e533a2b68a57604.

    This reverts #117018.

    I expect the issue to be fixed based on https://github.com/google/oss-fuzz/pull/11708#issuecomment-2006442396 and https://github.com/actions/runner-images/issues/9491.

commit eefff682f09394fe4f18b7d7c6ac4c635caadd02
Author: Malcolm Smith <[email protected]>
Date:   Wed Mar 27 22:11:44 2024 +0000

    gh-108277: Make test_os tolerate 10 ms diff for timerfd on Android emulators (#117223)

commit 7aa89bc43e0bcf49eee5a39b5a7ba8f996f20d00
Author: Victor Stinner <[email protected]>
Date:   Wed Mar 27 23:10:14 2024 +0100

    gh-113317: Change how Argument Clinic lists converters (#116853)

    * Add a new create_parser_namespace() function for
      PythonParser to pass objects to executed code.
    * In run_clinic(), list converters using 'converters' and
      'return_converters' dictionarties.
    * test_clinic: add 'object()' return converter.
    * Use also create_parser_namespace() in eval_ast_expr().

    Co-authored-by: Erlend E. Aasland <[email protected]>

commit 669ef49c7d42f35da6f7ee280102353b9b37f83e
Author: Seth Michael Larson <[email protected]>
Date:   Wed Mar 27 16:56:14 2024 -0500

    gh-99108: Update and check HACL* version information (GH-117295)

    * Update and check HACL* version information

commit 262fb911ab7df8e890ebd0efb0773c3e0b5a757f
Author: Irit Katriel <[email protected]>
Date:   Wed Mar 27 17:38:19 2024 +0000

    gh-117288: Allocate fewer label IDs in _PyCfg_ToInstructionSequence (#117290)

commit 74c8568d07719529b874897598d8b3bc25ff0434
Author: Malcolm Smith <[email protected]>
Date:   Wed Mar 27 16:53:27 2024 +0000

    gh-71042: Add `platform.android_ver` (#116674)

commit ce00de4c8cd39816f992e749c1074487d93abe9d
Author: Hugo van Kemenade <[email protected]>
Date:   Wed Mar 27 16:46:35 2024 +0200

    gh-117225: doctest: only print "and X failed" when non-zero, don't pluralise "1 items" (#117228)

commit 92397d5ead38dde4154e70d00f24973bcf2a925a
Author: Raymond Hettinger <[email protected]>
Date:   Wed Mar 27 09:04:32 2024 -0500

    Add statistics recipe for sampling from an estimated probability density distribution (#117221)

commit b3e8c78ed7aa9bbd1084375587b99200c687cec9
Author: Tian Gao <[email protected]>
Date:   Tue Mar 26 18:20:12 2024 -0700

    gh-113548: Allow CLI arguments to `pdb -m` (#113557)

commit 48c0b05cf0dd2db275bd4653f84aa36c22bddcd2
Author: Adorilson Bezerra <[email protected]>
Date:   Tue Mar 26 19:08:08 2024 +0000

    Change links on the index page (#117230)

commit af1b0e94400d1bf732466d675054df8cf7dfb62d
Author: AN Long <[email protected]>
Date:   Wed Mar 27 02:26:48 2024 +0800

    gh-104242: Enable test_is_char_device_true in pathlib test on all platform (GH-116983)

commit 79be75735c9d77972112cecc8d7e1af28c176ed0
Author: Irit Katriel <[email protected]>
Date:   Tue Mar 26 15:18:17 2024 +0000

    gh-115775: Compiler adds __static_attributes__ field to classes (#115913)

commit 70969d53a77a8a190c40a30419e772bc874a4f62
Author: Antonio <[email protected]>
Date:   Tue Mar 26 15:10:29 2024 +0100

    gh-97901 add missing text/rtf to mimetypes (GH-97902)

    Co-authored-by: Noam Cohen <[email protected]>

commit 4ec347760f98b156c6a2d42ca397af6b0b6ecc50
Author: AN Long <[email protected]>
Date:   Tue Mar 26 22:09:57 2024 +0800

    gh-115538: Use isolate mode when running venv test_multiprocessing_recursion() (#117116)

    Co-authored-by: Victor Stinner <[email protected]>

commit 743f2c68f478279e1e56577fe95a0ed112b9abc5
Author: Hugo van Kemenade <[email protected]>
Date:   Tue Mar 26 16:09:09 2024 +0200

    pre-commit: add `check-case-conflict` and `check-merge-conflict` (#117259)

commit 4abca7e1e7e2764faf20c7e677ea5c9ea9dbffe2
Author: Paulo Neves <[email protected]>
Date:   Tue Mar 26 13:37:50 2024 +0100

    gh-98966: Handle stdout=subprocess.STDOUT (GH-98967)

    Explicitly handle the case where stdout=STDOUT
    as otherwise the existing error handling gets
    confused and reports hard to understand errors.

    Signed-off-by: Paulo Neves <[email protected]>

commit 9654daf793b534b44a831c80f43505ab9e380f1f
Author: Serhiy Storchaka <[email protected]>
Date:   Tue Mar 26 13:26:45 2024 +0200

    gh-66543: Fix mimetype.guess_type() (GH-117217)

    Fix parsing of the following corner cases:

    * URLs with only a host name
    * URLs containing a fragment
    * URLs containing a query
    * filenames with only a UNC sharepoint on Windows

    Co-authored-by: Dong-hee Na <[email protected]>

commit 8bef34f625e21886b1c64544c060e19ee2e229bf
Author: Mark Shannon <[email protected]>
Date:   Tue Mar 26 11:11:42 2024 +0000

    GH-117108: Set the "old space bit" to "visited" for all young objects  (#117213)

    Change old space bit of young objects from 0 to gcstate->visited_space.
    This ensures that any object created *and* collected during cycle GC has the bit set correctly.

commit bf82f77957a31c3731b4ec470c406f5708ca9ba3
Author: Mark Shannon <[email protected]>
Date:   Tue Mar 26 09:35:11 2024 +0000

    GH-116422: Tier2 hot/cold splitting (GH-116813)

    Splits the "cold" path, deopts and exits, from the "hot" path, reducing the size of most jitted instructions, at the cost of slower exits.

commit 61599a48f52e951d8813877ee311d2a830ba2cd8
Author: Pablo Galindo Salgado <[email protected]>
Date:   Tue Mar 26 09:30:46 2024 +0000

    bpo-24612: Improve syntax error for 'not' after an operator (GH-28170)

    Co-authored-by: Lysandros Nikolaou <[email protected]>

commit 771902c257372e6c4df1ead4e8c46308561db7a7
Author: Hugo van Kemenade <[email protected]>
Date:   Tue Mar 26 11:13:32 2024 +0200

    gh-83845: Add tests for operator module (#115883)

    Co-authored-by: Karthikeyan Singaravelan <[email protected]>

commit ea9a296fce2f786b4cf43c7924e5de01061f27ca
Author: yevgeny hong <[email protected]>
Date:   Tue Mar 26 16:45:43 2024 +0900

    gh-115627: Fix PySSL_SetError handling SSL_ERROR_SYSCALL (GH-115628)

    Python 3.10 changed from using SSL_write() and SSL_read() to SSL_write_ex() and
    SSL_read_ex(), but did not update handling of the return value.

    Change error handling so that the return value is not examined.
    OSError (not EOF) is now returned when retval is 0.

    According to *recent* man pages of all functions for which we call
    PySSL_SetError, (in OpenSSL 3.0 and 1.1.1), their return value should
    be used to determine whether an error happened (i.e. if PySSL_SetError
    should be called), but not what kind of error happened (so,
    PySSL_SetError shouldn't need retval). To get the error,
    we need to use SSL_get_error.

    Co-authored-by: Serhiy Storchaka <[email protected]>
    Co-authored-by: Petr Viktorin <[email protected]>

commit d52bdfb19fadd7614a0e5abaf68525fc7300e841
Author: Victor Stinner <[email protected]>
Date:   Tue Mar 26 08:35:59 2024 +0100

    gh-83434: Disable XML in regrtest when -R option is used (#117232)

commit 9f74e86c78853c101a23e938f8e32ea838d8f62e
Author: Sebastian Pipping <[email protected]>
Date:   Tue Mar 26 02:48:27 2024 +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)

commit 872e212378ef86392069034afd80bb53896fd93d
Author: Jonathan Protzenko <[email protected]>
Date:   Mon Mar 25 17:35:26 2024 -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`.

commit 8945b7ff55b87d11c747af2dad0e3e4d631e62d6
Author: Eric V. Smith <[email protected]>
Date:   Mon Mar 25 19:59:14 2024 -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%.

commit 7ebad77ad65ab4d5d8d0c333256a882262cec189
Author: Raymond Hettinger <[email protected]>
Date:   Mon Mar 25 18:49:44 2024 -0500

    Sync main docs and docstring for median_grouped(). (gh-117214)

commit 0821923aa979a72464c5da8dfa53a719bba5801c
Author: Nice Zombies <[email protected]>
Date:   Mon Mar 25 23:55:11 2024 +0100

    gh-117114: Make os.path.isdevdrive available on all platforms (GH-117115)

commit c2276176d543a2fc2d57709c2787f99850fbb073
Author: Adorilson Bezerra <[email protected]>
Date:   Mon Mar 25 22:34:20 2024 +0000

    Add information about negative  indexes to sequence datamodel doc (#110903)

    Co-authored by Terry Jan Reedy

commit 23e4f80ce2a2bac50acd1785e791316d5b578b8d
Author: Mark Shannon <[email protected]>
Date:   Mon Mar 25 20:43:51 2024 +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.

commit 507896d97dcff2d7999efa264b29d9003c525c49
Author: Victor Stinner <[email protected]>
Date:   Mon Mar 25 17:32:20 2024 +0100

    gh-116936: Add PyType_GetModuleByDef() to the limited C API (#116937)

commit 0c1a42cf9c8cd0d4534d5c1d58f118ce7c5c446e
Author: Serhiy Storchaka <[email protected]>
Date:   Mon Mar 25 17:32:11 2024 +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.

commit 01e7405da400e8997f8964d06cc414045e144681
Author: Tian Gao <[email protected]>
Date:   Mon Mar 25 08:18:09 2024 -0700

    gh-112948: Make pdb completion similar to repl completion (#112950)

commit 9db2a8f914ad59019d448cecc43b6d45f46424a0
Author: Raymond Hettinger <[email protected]>
Date:   Mon Mar 25 09:26:42 2024 -0500

    Minor markup and grammar fixes in the statistics docs (gh-117216)

commit eebea7e515462b503632ada74923ec3246599c9c
Author: Kirill Podoprigora <[email protected]>
Date:   Sun Mar 24 20:34:55 2024 +0200

    gh-117176: Fix compiler warning in Python/optimizer_bytecodes.c (GH-117199)

commit 83485a095363dad6c97b19af2826ca0c34343bfc
Author: Totally a booplicate <[email protected]>
Date:   Sun Mar 24 18:48:40 2024 +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).

commit 78a651fd7fbe7a3d1702e40f4cbfa72d87241ef0
Author: Terry Jan Reedy <[email protected]>
Date:   Sun Mar 24 11:38:34 2024 -0400

    gh-117194: Properly format 'base64' header in What's New (#117198)

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

commit f267d5bf2a99fbeb26a720d1c87c1f0557424b14
Author: Kerim Kabirov <[email protected]>
Date:   Sun Mar 24 14:59:14 2024 +0100

    GH-115986 Docs: promote pprint.pp usage as a default (#116614)

    Co-authored-by: Hugo van Kemenade <[email protected]>

commit 39df7732178c8e8f75b12f069a3dbc1715c99995
Author: LilKS <[email protected]>
Date:   Sun Mar 24 11:01:07 2024 +0100

    gh-101760: Improve the imaplib.IMAP4 example (#101764)

    Co-authored-by: Adam Turner <[email protected]>

commit a1e948edba9ec6ba61365429857f7a087c5edf51
Author: Raymond Hettinger <[email protected]>
Date:   Sun Mar 24 11:35:58 2024 +0200

    Add cumulative option for the new statistics.kde() function. (#117033)

commit d610d821fd210dce63a1132c274ffdf8acc510bc
Author: Irit Katriel <[email protected]>
Date:   Sat Mar 23 22:32:33 2024 +0000

    gh-112383: teach dis how to interpret ENTER_EXECUTOR (#117171)

commit 6c83352bfe78a7d567c8d76257df6eb91d5a7245
Author: Ken Jin <[email protected]>
Date:   Sun Mar 24 06:19:17 2024 +0800

    gh-117180: Complete call sequence when trace stack overflow (GH-117184)

    ---------

    Co-authored-by: Peter Lazorchak <[email protected]>
    Co-authored-by: Guido van Rossum <[email protected]>
    Co-authored-by: Guido van Rossum <[email protected]>

commit f11d0d8be8af28e1368c3c7c116218cf65ddf93e
Author: Erik Soma <[email protected]>
Date:   Sat Mar 23 11:39:35 2024 -0400

    gh-91227: Ignore ERROR_PORT_UNREACHABLE in proactor recvfrom() (#32011)

commit 9967b568edd2e35b0415c14c7242f3ca2c0dc03d
Author: Victor Stinner <[email protected]>
Date:   Sat Mar 23 13:01:20 2024 +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.

commit 72eea512b88f8fd68b7258242c37da963ad87360
Author: Barney Gale <[email protected]>
Date:   Fri Mar 22 19:14:09 2024 +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*.

commit e28477f214276db941e715eebc8cdfb96c1207d9
Author: Mark Shannon <[email protected]>
Date:   Fri Mar 22 18:43:25 2024 +0000

    GH-117108: Change the size of the GC increment to about 1% of the total heap size. (GH-117120)

commit e2e0b4b4b92694ba894e02b4a66fd87c166ed10f
Author: Serhiy Storchaka <[email protected]>
Date:   Fri Mar 22 20:19:10 2024 +0200

    gh-113024: C API: Add PyObject_GenericHash() function (GH-113025)

commit 567ab3bd15398c8c7b791f3e376ae3e3c0bbe079
Author: Serhiy Storchaka <[email protected]>
Date:   Fri Mar 22 20:08:00 2024 +0200

    gh-117084: Fix ZIP file extraction for directory entry names with backslashes on Windows (GH-117129)

commit 5a78f6e798d5c2af1dba2df6c9f1f1e5aac02a86
Author: Serhiy Storchaka <[email protected]>
Date:   Fri Mar 22 20:03:48 2024 +0200

    gh-117134: Microoptimize glob() for include_hidden=True (GH-117135)

commit 00baaa21de229a6db80ff2b84c2fd6ad1999a24c
Author: Vinay Sajip <[email protected]>
Date:   Fri Mar 22 17:25:51 2024 +0000

    [docs] Fix typo in docstring and add example to logging cookbook. (GH-117157)

commit 40d75c2b7f5c67e254d0a025e0f2e2c7ada7f69f
Author: Jakub Stasiak <[email protected]>
Date:   Fri Mar 22 17:49:56 2024 +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

commit 3be9b9d8722696b95555937bb211dc4cda714d56
Author: Steve Dower <[email protected]>
Date:   Fri Mar 22 15:00:50 2024 +0000

    Fix get_packagefamilyname helper function on Windows 32-bit (GH-117153)

commit 63d6f2623ef2aa90f51c6a928b96845b9b380d89
Author: NGRsoftlab <[email protected]>
Date:   Fri Mar 22 14:25:38 2024 +0300

    gh-117068: Remove useless code in bytesio.c:resize_buffer() (GH-117069)

    Co-authored-by: i.khabibulin <[email protected]>

commit 42ae924d278c48a719fb0ab86357f3235a9f7ab9
Author: Petr Viktorin <[email protected]>
Date:   Fri Mar 22 10:42:18 2024 +0100

    gh-117127: glob tests: Reopen dir_fd to pick up directory changes (GH-117128)

commit 8383915031942f441f435a5ae800790116047b80
Author: Tim Peters <[email protected]>
Date:   Thu Mar 21 22:27:25 2024 -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.

commit 97ba910e47ad298114800587979ce7beb0a705a3
Author: Guido van Rossum <[email protected]>
Date:   Thu Mar 21 18:27:48 2024 -0700

    gh-108716:: Remove _PyStaticCode_Init/Fini (#117141)

    More deepfreeze cleanup.

commit b3d25df8d38b79310587da54dbd88b06a16d4904
Author: Eric Snow <[email protected]>
Date:   Thu Mar 21 18:20:20 2024 -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().

commit c4bf58a14f162557038a1535ca22c52b49d81d7b
Author: Thomas A Caswell <[email protected]>
Date:   Thu Mar 21 19:54:50 2024 -0400

    gh-116745: Remove all internal usage of @LIBPYTHON@ (#116746)

    Replace with MODULE_LDFLAGS.

commit 3ec57307e70ee6f42410e844d3399bbd598917ba
Author: Malcolm Smith <[email protected]>
Date:   Thu Mar 21 23:52:29 2024 +0000

    gh-71052: Add Android build script and instructions (#116426)

commit 50f9b0b1e0fb181875751cef951351ed007b6397
Author: Victor Stinner <[email protected]>
Date:   Thu Mar 21 23:17:09 2024 +0100

    gh-117061: Fix test_posix.test_sched_setaffinity() on RHEL9 (#117126)

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

commit 0907871d43bffb613cbd560224e1a9db13d06c06
Author: Ned Batchelder <[email protected]>
Date:   Thu Mar 21 15:47:09 2024 -0400

    docs: fix over-linking in dataclasses.rst (#117005)

commit 570a82d46abfebb9976961113fb0f8bb400ad182
Author: Guido van Rossum <[email protected]>
Date:   Thu Mar 21 12:37:41 2024 -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.

commit c85d84166a84a5cb2d724012726bad34229ad24e
Author: Will Childs-Klein <[email protected]>
Date:   Thu Mar 21 14:16:36 2024 -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

commit 1f72fb5447ef3f8892b4a7a6213522579c618e8e
Author: Sam Gross <[email protected]>
Date:   Thu Mar 21 14:21:02 2024 -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.

commit 50369e6c34d05222e5a0ec9443a9f7b230e83112
Author: Michael Droettboom <[email protected]>
Date:   Thu Mar 21 13:27:46 2024 -0400

    gh-116996: Add pystats about _Py_uop_analyse_and_optimize (GH-116997)

commit 617158e07811edfd6fd552a3d84b0beedd8f1d18
Author: Eric Snow <[email protected]>
Date:   Thu Mar 21 11:15:02 2024 -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.

commit abdd1f938f08e536864532b2071f144515ecc88b
Author: Victor Stinner <[email protected]>
Date:   Thu Mar 21 17:45:43 2024 +0100

    gh-85283: Build _testconsole extension with limited C API (#117125)

commit 8bea6c411d65cd987616b4ecdb86373e4f21f1c6
Author: Victor Stinner <[email protected]>
Date:   Thu Mar 21 17:07:00 2024 +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.

commit 5a76d1be8ef371b75ca65166726923c249b5f615
Author: Eric Snow <[email protected]>
Date:   Thu Mar 21 10:06:35 2024 -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.

commit bbee57fa8c318cb26d6c8651254927a1972c9738
Author: Eric Snow <[email protected]>
Date:   Thu Mar 21 09:56:12 2024 -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().

commit e728303532168efab7694c55c82ea19b18bf8385
Author: Sam Gross <[email protected]>
Date:   Thu Mar 21 10:01:16 2024 -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.

commit 1f8b24ef69896680d6ba6005e75e1cc79a744f9e
Author: Malcolm Smith <[email protected]>
Date:   Thu Mar 21 13:20:57 2024 +0000

    gh-71052: Implement `ctypes.util.find_library` on Android (GH-116379)

commit d16c9d1278164f04778861814ebc87ed087511fc
Author: Tian Gao <[email protected]>
Date:   Thu Mar 21 03:30:10 2024 -0700

    gh-116987: Support class code objects in inspect.findsource() (GH-117025)

commit 6547330f4e896c6748da23704b617e060e6cc68e
Author: Adam Turner <[email protected]>
Date:   Thu Mar 21 03:49:10 2024 +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 <[email protected]>

commit 667294d5b2ee812ebe0c9c1efd58e2006b61f827
Author: Jason R. Coombs <[email protected]>
Date:   Wed Mar 20 23:01:24 2024 -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)

commit f4cc77d494ee0e10ed84ce369f0910c70a2f6d44
Author: Victor Stinner <[email protected]>
Date:   Thu Mar 21 00:06:24 2024 +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.

commit 104602a6078564765b7b8f42888f8eaa37b129b1
Author: Victor Stinner <[email protected]>
Date:   Wed Mar 20 23:52:23 2024 +0100

    gh-105927: Limit PyWeakref_GetRef() to limited C API 3.13 (#117091)

commit 8ad88984200b2ccddc0a08229dd2f4c14d1a71fc
Author: Jason R. Coombs <[email protected]>
Date:   Wed Mar 20 17:11:00 2024 -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

commit 7d446548ef53f6c3de1097c6d44cada6642ddc85
Author: Carol Willing <[email protected]>
Date:   Wed Mar 20 14:00:59 2024 -0700

    Fix sort order for "locale encoding" glossary item (#115794)

    Co-authored-by: C.A.M. Gerlach <[email protected]>

commit 63289b9dfbc7d87e81f1517422ee91b6b6d19531
Author: Mark Shannon <[email protected]>
Date:   Wed Mar 20 18:24:02 2024 +0000

    GH-117066: Tier 2 optimizer: Don't throw away good traces if we can't optimize them perfectly. (GH-117067)

commit dcaf33a41d5d220523d71c9b35bc08f5b8405dac
Author: Petr Viktorin <[email protected]>
Date:   Wed Mar 20 17:33:08 2024 +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 <[email protected]>
    Co-authored-by: Erlend E. Aasland <[email protected]>

commit 44fbab43d8f3f2df07091d237824cf4fa1f6c57c
Author: Russell Keith-Magee <[email protected]>
Date:   Wed Mar 20 23:32:56 2024 +0800

    gh-117058: Update GUI and packaging recommendations for macOS. (#117059)

commit 9221ef2d8cb7f4cf37592eb650d4c8f972033000
Author: Brett Simmers <[email protected]>
Date:   Wed Mar 20 08:18:26 2024 -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`.

commit fc4599800778f9b130d5e336deadbdeb5bd3e5ee
Author: jkriegshauser <[email protected]>
Date:   Wed Mar 20 07:33:28 2024 -0700

    gh-116773: Ensure overlapped objects on Windows are not deallocated too early by asyncio (GH-116774)

commit 519b2ae22b54760475bbf62b9558d453c703f9c6
Author: Serhiy Storchaka <[email protected]>
Date:   Wed Mar 20 15:39:53 2024 +0200

    gh-117021: Fix integer overflow in PyLong_AsPid() on non-Windows 64-bit platforms (GH-117064)
NGRsoftlab pushed a commit to NGRsoftlab/cpython that referenced this issue Apr 2, 2024
commit 9dae05ee59eeba0e67af2a46f2a2907c9f8d7e4a
Author: Moshe Kaplan <[email protected]>
Date:   Mon Apr 1 15:53:00 2024 -0400

    Docs: specify XML document name in xml.etree.elementtree example (#24223)

commit fc2071687b708598264a3403b7f9104667c1092f
Author: Matthew Davis <[email protected]>
Date:   Mon Apr 1 21:49:14 2024 +0200

    Docs: add more links to PIPE in subprocess docs (#25416)

commit fc8007ee3635db6ab73e132ebff987c910b6d538
Author: Barney Gale <[email protected]>
Date:   Mon Apr 1 20:37:41 2024 +0100

    GH-117337: Deprecate `glob.glob0()` and `glob.glob1()`. (#117371)

    These undocumented functions are no longer used by `msilib`, so there's no
    reason to keep them around.

commit c741ad3537193c63fe697a8f0316aecd45eeb9ba
Author: Justin Turner Arthur <[email protected]>
Date:   Mon Apr 1 12:07:29 2024 -0500

    gh-77714: Provide an async iterator version of as_completed (GH-22491)

    * as_completed returns object that is both iterator and async iterator
    * Existing tests adjusted to test both the old and new style
    * New test to ensure iterator can be resumed
    * New test to ensure async iterator yields any passed-in Futures as-is

    Co-authored-by: Serhiy Storchaka <[email protected]>
    Co-authored-by: Guido van Rossum <[email protected]>

commit ddf814db744006e0f42328aa15ace97c9d8ad681
Author: Guido van Rossum <[email protected]>
Date:   Mon Apr 1 09:13:38 2024 -0700

    Silence compiler warnings in gc.c (#117422)

commit 179869af922252a0c1cef65fd2923856895e7d1b
Author: Petr Viktorin <[email protected]>
Date:   Mon Apr 1 17:01:22 2024 +0200

    gh-94808: Fix refcounting in PyObject_Print tests (GH-117421)

commit dd44ab994b7262f0704d64996e0a1bc37b233407
Author: neonene <[email protected]>
Date:   Mon Apr 1 22:28:14 2024 +0900

    gh-117142: ctypes: Unify meta tp slot functions (GH-117143)

    Integrates the following ctypes meta tp slot functions:
    * `CDataType_traverse()` into `CType_Type_traverse()`.
    * `CDataType_clear()` into `CType_Type_clear()`.
    * `CDataType_dealloc()` into `CType_Type_dealloc()`.
    * `CDataType_repeat()` into `CType_Type_repeat()`.

commit 3de09cadde788065a4f2d45117e789c9353bbd12
Author: Steve (Gadget) Barnes <[email protected]>
Date:   Mon Apr 1 14:02:07 2024 +0100

    gh-91565: Replace bugs.python.org links with Devguide/GitHub ones  (GH-91568)

    Co-authored-by: Hugo van Kemenade <[email protected]>
    Co-authored-by: Oleg Iarygin <[email protected]>
    Co-authored-by: Petr Viktorin <[email protected]>
    Co-authored-by: Ezio Melotti <[email protected]>

commit 90c3c68a658db6951b77a5be50088ec2f6adc8eb
Author: MonadChains <[email protected]>
Date:   Mon Apr 1 13:52:25 2024 +0100

    gh-94808:Improve coverage of PyObject_Print (GH-98749)

commit 348cf6e0078eae156c503e8f61ef5e27ae28e57b
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Mon Apr 1 11:14:37 2024 +0000

    Bump mypy from 1.8.0 to 1.9.0 in /Tools (#117418)

    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Co-authored-by: Alex Waygood <[email protected]>

commit 9b403fb559bfce93a478937e0ef7e539a9a95283
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Mon Apr 1 11:05:14 2024 +0000

    build(deps-dev): bump types-psutil from 5.9.5.20240205 to 5.9.5.20240316 in /Tools (#117417)

    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Co-authored-by: Alex Waygood <[email protected]>

commit 93c7d9d17b571b6a181af7c02830d29819535c35
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Mon Apr 1 11:38:38 2024 +0100

    build(deps-dev): bump types-setuptools from 69.1.0.20240301 to 69.2.0.20240317 in /Tools (#117419)

    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit 3bb12e407c183946471272f8aee098e54e62a333
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Mon Apr 1 09:54:33 2024 +0000

    build(deps): bump actions/add-to-project from 0.6.0 to 1.0.0 (#117415)

    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit 56e99307c49adcc6df355f8070229371c97d654f
Author: Adorilson Bezerra <[email protected]>
Date:   Sun Mar 31 23:34:54 2024 +0100

    Doc: printf-style library/stdtype improvements (#16741)

commit 18e12641a61a88f7d08b2114ebe965892c6661c5
Author: Raymond Hettinger <[email protected]>
Date:   Sun Mar 31 16:09:22 2024 -0500

    gh-117387 Remove hash mark from introductory text (#117409)

commit a32d6939486d7f90ee57e215077f6116e19de24d
Author: Deborah <[email protected]>
Date:   Sun Mar 31 22:11:48 2024 +0200

    gh-102190: Add additional zipfile `pwd=` arg docstrings (gh-102195)

    This just documents the parameter that already exists.

    ---------

    Co-authored-by: Gregory P. Smith <[email protected]>
    Co-authored-by: Erlend E. Aasland <[email protected]>

commit 262445358e21c56d7c68e3ee76c13e469d2ea348
Author: Shantanu <[email protected]>
Date:   Sun Mar 31 12:02:48 2024 -0700

    Link to the Python type system specification (#117400)

commit 752e18389ed03087b51b38eac9769ef8dfd167b7
Author: Barney Gale <[email protected]>
Date:   Sun Mar 31 19:14:48 2024 +0100

    GH-114575: Rename `PurePath.pathmod` to `PurePath.parser` (#116513)

    And rename the private base class from `PathModuleBase` to `ParserBase`.

commit bfc57d43d8766120ba0c8f3f6d7b2ac681a81d8a
Author: Sam Gross <[email protected]>
Date:   Fri Mar 29 18:58:08 2024 -0400

    gh-117303: Don't detach in `PyThreadState_DeleteCurrent()` (#117304)

    This fixes a crash in `test_threading.test_reinit_tls_after_fork()` when
    running with the GIL disabled. We already properly handle the case where
    the thread state is `_Py_THREAD_ATTACHED` in `tstate_delete_common()` --
    we just need to remove an assertion.

    Keeping the thread attached means that a stop-the-world pause, such as
    for a `fork()`, won't commence until we remove our thread state from the
    interpreter's linked list. This prevents a crash when the child process
    tries to clean up the dead thread states.

commit 05e0b67a43c5c1778dc2643c8b7c12864e135999
Author: Erlend E. Aasland <[email protected]>
Date:   Fri Mar 29 21:23:28 2024 +0100

    gh-116664: In _warnings.c, make filters_version access thread-safe (#117374)

    - assert that the lock is held in already_warned()
    - protect 'filters_version' increment in warnings_filters_mutated_impl()

commit 019143fecbfc26e69800d28d2a9e3392a051780b
Author: Jason R. Coombs <[email protected]>
Date:   Fri Mar 29 16:06:09 2024 -0400

    gh-117348: Refactored RawConfigParser._read for similicity and comprehensibility (#117372)

    * Extract method for _read_inner, reducing complexity and indentation by 1.

    * Extract method for _raise_all and yield ParseErrors from _read_inner.

    Reduces complexity by 1 and reduces touch points for handling errors in _read_inner.

    * Prefer iterators to splat expansion and literal indexing.

    * Extract method for _strip_comments. Reduces complexity by 7.

    * Model the file lines in a class to encapsulate the comment status and cleaned value.

    * Encapsulate the read state as a dataclass

    * Extract _handle_continuation_line and _handle_rest methods. Reduces complexity by 8.

    * Reindent

    * At least for now, collect errors in the ReadState

    * Check for missing section header separately.

    * Extract methods for _handle_header and _handle_option. Reduces complexity by 6.

    * Remove unreachable code. Reduces complexity by 4.

    * Remove unreachable branch

    * Handle error condition early. Reduces complexity by 1.

    * Add blurb

    * Move _raise_all to ParsingError, as its behavior is most closely related to the exception class and not the reader.

    * Split _strip* into separate methods.

    * Refactor _strip_full to compute the strip just once and use 'not any' to determine the factor.

    * Replace use of 'sys.maxsize' with direct computation of the stripped value.

    * Extract has_comments as a dynamic property.

    * Implement clean as a cached property.

    * Model comment prefixes in the RawConfigParser within a prefixes namespace.

    * Use a regular expression to search for the first match.

    Avoids mutating variables and tricky logic and over-computing all of the starts when only the first is relevant.

commit 01bd74eadbc4ff839d39762fae6366f50c1e116e
Author: Sam Gross <[email protected]>
Date:   Fri Mar 29 15:33:06 2024 -0400

    gh-117300: Use stop the world to make `sys._current_frames` and `sys._current_exceptions` thread-safe. (#117301)

    This adds a stop the world pause to make the two functions thread-safe
    when the GIL is disabled in the free-threaded build.

    Additionally, the main test thread may call `sys._current_exceptions()` as
    soon as `g_raised.set()` is called. The background thread may not yet reach
    the `leave_g.wait()` line.

commit 94c97423a9c4969f8ddd4a3aa4aacb99c4d5263d
Author: Guido van Rossum <[email protected]>
Date:   Fri Mar 29 11:31:09 2024 -0700

    Fix broken format in error for bad input in summarize_stats.py (#117375)

    When you pass the script a non-existent input file, you get a TypeError instead of the intended ValueError.

commit 5d21d884b6ffa45dac50a5f9a07c41356a8478b4
Author: mpage <[email protected]>
Date:   Fri Mar 29 10:42:02 2024 -0700

    gh-111926: Avoid locking in PyType_IsSubtype (#117275)

    Read the MRO in a thread-unsafe way in `PyType_IsSubtype` to avoid locking. Fixing this is tracked in #117306.

    The motivation for this change is in support of making weakrefs thread-safe in free-threaded builds:

    `WeakValueDictionary` uses a special dictionary function, `_PyDict_DelItemIf`
    to remove dead weakrefs from the dictionary. `_PyDict_DelItemIf` removes a key
    if a user supplied predicate evaluates to true for the value associated with
    the key. Crucially for the `WeakValueDictionary` use case, the predicate
    evaluation + deletion sequence is atomic, provided that the predicate doesn’t
    suspend. The predicate used by `WeakValueDictionary` includes a subtype check,
    which we must ensure doesn't suspend in free-threaded builds.

commit 19c1dd60c5b53fb0533610ad139ef591294f26e8
Author: Sam Gross <[email protected]>
Date:   Fri Mar 29 13:35:43 2024 -0400

    gh-117323: Make `cell` thread-safe in free-threaded builds (#117330)

    Use critical sections to lock around accesses to cell contents. The critical sections are no-ops in the default (with GIL) build.

commit 397d88db5e9ab2a43de3fdf5f8b973a949edc405
Author: Sam Gross <[email protected]>
Date:   Fri Mar 29 13:34:04 2024 -0400

    gh-117344: Skip flaky tests in free-threaded build (#117355)

    The tests are not reliable with the GIL disabled. In theory, they can
    fail with the GIL enabled too, but the failures are much more likely
    with the GIL disabled.

commit f05fb2e65c2dffdfae940f2707765c4994925205
Author: Sam Gross <[email protected]>
Date:   Fri Mar 29 13:33:04 2024 -0400

    gh-112529: Don't untrack tuples or dicts with zero refcount (#117370)

    The free-threaded GC sometimes sees objects with zero refcount. This can
    happen due to the delay in merging biased reference counting fields,
    and, in the future, due to deferred reference counting. We should not
    untrack these objects or they will never be collected.

    This fixes the refleaks in the free-threaded build.

commit ddf95b5f16031cdbd0d728e55eb06dff002a8678
Author: Erlend E. Aasland <[email protected]>
Date:   Fri Mar 29 18:26:06 2024 +0100

    gh-116664: Fix unused var warnings in _warnings.c in non-free-threaded builds (#117373)

    The warnings were introduced by commit c1712ef06.

commit 0fa571dbcdf19b541276cb00bb929381930467b2
Author: Tian Gao <[email protected]>
Date:   Fri Mar 29 09:02:01 2024 -0700

    Refactor pdb executable targets (#112570)

    Co-authored-by: Jason R. Coombs <[email protected]>

commit 54f7e14500471d1c46fb553adb3ca24cd1fef084
Author: Pedro Lacerda <[email protected]>
Date:   Fri Mar 29 12:05:00 2024 -0300

    gh-66449: configparser: Add support for unnamed sections (#117273)

    Co-authored-by: Jason R. Coombs <[email protected]>

commit d9cfe7e565a6e2dc15747a904736264e31a10be4
Author: Nikita Sobolev <[email protected]>
Date:   Fri Mar 29 14:14:25 2024 +0300

    gh-117166: Ignore empty and temporary dirs in `test_makefile` (#117190)

commit 35b6c4a4da201a947b2ceb96ae4c0d83d4d2df4f
Author: Victor Stinner <[email protected]>
Date:   Fri Mar 29 11:25:17 2024 +0100

    gh-117347: Fix test_clinic side effects (#117363)

    Save/restore converters in ClinicWholeFileTest and
    ClinicExternalTest.

commit 7e2fef865899837c47e91ef0180fa59eb03e840b
Author: neonene <[email protected]>
Date:   Fri Mar 29 18:40:48 2024 +0900

    gh-117142: ctypes: Migrate global vars to module state (GH-117189)

commit 2e9be80c99f635c2f7761e8356b0260922d6e7a6
Author: Gregory P. Smith <[email protected]>
Date:   Thu Mar 28 17:58:37 2024 -0700

    Fix reversed assertRegex checks in test_ssl. (#117351)

commit 8eec7ed714e65d616573b7331780b0aa43c6ed6a
Author: 傅立业(Chris Fu) <[email protected]>
Date:   Fri Mar 29 08:19:20 2024 +0800

    gh-117110: Fix subclasses of typing.Any with custom constructors (#117111)

commit a17f313e3958e825db9a83594c8471a984316536
Author: Christopher Chianelli <[email protected]>
Date:   Thu Mar 28 18:26:56 2024 -0400

    gh-117339: Use NULL instead of None for LOAD_SUPER_ATTR in dis docs (GH-117343)

commit 26d328b2ba26374fb8d9ffe8215ecef7c5e3f7a2
Author: Michael Droettboom <[email protected]>
Date:   Thu Mar 28 18:23:08 2024 -0400

    GH-117121: Add pystats to JIT builds (GH-117346)

commit 14f1ca7d5363386163839b31ce987423daecc3de
Author: Nice Zombies <[email protected]>
Date:   Thu Mar 28 22:20:08 2024 +0100

    gh-117335: Handle non-iterables for `ntpath.commonpath` (GH-117336)

commit 18cf239e39e25e6cef50ecbb7f197a82f8920ff5
Author: Brandt Bucher <[email protected]>
Date:   Thu Mar 28 14:02:34 2024 -0700

    Increase the JIT CI timeouts to 75 minutes (GH-117342)

commit 29829b58a8328a7c2ccacaa74c1d7d120a5e5ca5
Author: Malcolm Smith <[email protected]>
Date:   Thu Mar 28 19:59:12 2024 +0000

    gh-117294: Report DocTestCase as skipped if all examples in the doctest are skipped (GH-117297)

commit efcc96844e7c66fcd6c23ac2d557ca141614ce9a
Author: Tian Gao <[email protected]>
Date:   Thu Mar 28 11:23:29 2024 -0700

    gh-69201: Separate stdout and stderr stream in test_pdb (#117308)

commit 6702d2bf6edcd5b5415e17837383623b9d76a5b8
Author: Victor Stinner <[email protected]>
Date:   Thu Mar 28 17:40:58 2024 +0100

    gh-114331: Skip decimal test_maxcontext_exact_arith on s390x (#117326)

commit c1712ef066321c01bf09cba3f22fc474b5b8dfa7
Author: Erlend E. Aasland <[email protected]>
Date:   Thu Mar 28 16:05:08 2024 +0100

    gh-116664: Make module state Py_SETREF's in _warnings thread-safe (#116959)

    Mark the swap operations as critical sections.

    Add an internal Py_BEGIN_CRITICAL_SECTION_MUT API that takes a PyMutex
    pointer instead of a PyObject pointer.

commit 9a388b9a64927c372d85f0eaec3de9b7320a6fb5
Author: Joachim Wuttke <[email protected]>
Date:   Thu Mar 28 14:43:07 2024 +0100

    bpo-43848: explain optional argument mtime in gzip.py. (GH-25410)

    Co-authored-by: Jelle Zijlstra <[email protected]>

commit 8dbfdb2957a7baade3a88661517f163ad694c39f
Author: Sam Gross <[email protected]>
Date:   Thu Mar 28 09:28:39 2024 -0400

    gh-110481: Fix biased reference counting queue initialization. (#117271)

    The biased reference counting queue must be initialized from the bound
    (active) thread because it uses `_Py_ThreadId()` as the key in a hash
    table.

commit 9a1e55b8c5723206116f7016921be3937ef2f4e5
Author: Chris Markiewicz <[email protected]>
Date:   Thu Mar 28 06:59:31 2024 -0400

    gh-117178: Recover lazy loading of self-referential modules (#117179)

commit 4c71d51a4b7989fc8754ba512c40e21666f9db0d
Author: Jelle Zijlstra <[email protected]>
Date:   Thu Mar 28 04:30:31 2024 -0600

    gh-117266: Fix crashes on user-created AST subclasses (GH-117276)

    Fix crashes on user-created AST subclasses

commit 8cb7d7ff86a1a2d41195f01ba4f218941dd7308c
Author: Gregory P. Smith <[email protected]>
Date:   Thu Mar 28 03:11:58 2024 -0700

    gh-117310: Remove extra DECREF on "no ciphers" error path in `_ssl._SSLContext` constructor (#117309)

    Remove extra self DECREF on ssl "no ciphers" error path.

    This doesn't come up in practice because nobody links against a broken
    OpenSSL library that provides nothing.

commit 6c8ac8a32fd6de1960526561c44bc5603fab0f3e
Author: Erlend E. Aasland <[email protected]>
Date:   Thu Mar 28 09:40:37 2024 +0100

    gh-116303: Handle disabled test modules in test.support helpers (#116482)

    Make sure test.support helpers skip iso. failing if test extension
    modules are disabled. Also log TEST_MODULES in test.pythoninfo.

commit 0f27672c5002de96c9f1228b12460d5ce3f1d190
Author: Russell Keith-Magee <[email protected]>
Date:   Thu Mar 28 16:13:13 2024 +0800

    gh-114099: Add documentation for iOS platform (GH-117057)

    Co-authored-by: Hugo van Kemenade <[email protected]>
    Co-authored-by: Jacob Coffee <[email protected]>
    Co-authored-by: Malcolm Smith <[email protected]>
    Co-authored-by: Ned Deily <[email protected]>

commit f006338017cfbf846e8f7391b9ee5f69df8dc620
Author: Russell Keith-Magee <[email protected]>
Date:   Thu Mar 28 15:59:33 2024 +0800

    gh-114099: Additions to standard library to support iOS (GH-117052)

    Co-authored-by: Hugo van Kemenade <[email protected]>
    Co-authored-by: Malcolm Smith <[email protected]>
    Co-authored-by: Ned Deily <[email protected]>

commit b44898299a2ed97045c270f6474785da2ff07ced
Author: Tim Hatch <[email protected]>
Date:   Wed Mar 27 23:54:51 2024 -0700

    gh-89739: gh-77140: Support zip64 in zipimport (GH-94146)

    * Reads zip64 files as produced by the zipfile module
    * Include tests (somewhat slow, however, because of the need to create "large" zips)
    * About the same amount of strictness reading invalid zip files as zipfile has
    * Still works on files with prepended data (like pex)

    There are a lot more test cases at https://github.com/thatch/zipimport64/ that give me confidence that this works for real-world files.

    Fixes #89739 and #77140.

    ---------

    Co-authored-by: Itamar Ostricher <[email protected]>
    Reviewed-by: Gregory P. Smith <[email protected]>

commit 2cedd25c14d3acfdcb5e8ee55132ce3e334ab8fe
Author: Illia Volochii <[email protected]>
Date:   Thu Mar 28 08:46:01 2024 +0200

    Revert "gh-116886: Temporarily disable CIfuzz (memory) (GH-117018)" (GH-117289)

    This reverts commit 1ab0d0b1167d78bf19661a3b5e533a2b68a57604.

    This reverts #117018.

    I expect the issue to be fixed based on https://github.com/google/oss-fuzz/pull/11708#issuecomment-2006442396 and https://github.com/actions/runner-images/issues/9491.

commit eefff682f09394fe4f18b7d7c6ac4c635caadd02
Author: Malcolm Smith <[email protected]>
Date:   Wed Mar 27 22:11:44 2024 +0000

    gh-108277: Make test_os tolerate 10 ms diff for timerfd on Android emulators (#117223)

commit 7aa89bc43e0bcf49eee5a39b5a7ba8f996f20d00
Author: Victor Stinner <[email protected]>
Date:   Wed Mar 27 23:10:14 2024 +0100

    gh-113317: Change how Argument Clinic lists converters (#116853)

    * Add a new create_parser_namespace() function for
      PythonParser to pass objects to executed code.
    * In run_clinic(), list converters using 'converters' and
      'return_converters' dictionarties.
    * test_clinic: add 'object()' return converter.
    * Use also create_parser_namespace() in eval_ast_expr().

    Co-authored-by: Erlend E. Aasland <[email protected]>

commit 669ef49c7d42f35da6f7ee280102353b9b37f83e
Author: Seth Michael Larson <[email protected]>
Date:   Wed Mar 27 16:56:14 2024 -0500

    gh-99108: Update and check HACL* version information (GH-117295)

    * Update and check HACL* version information

commit 262fb911ab7df8e890ebd0efb0773c3e0b5a757f
Author: Irit Katriel <[email protected]>
Date:   Wed Mar 27 17:38:19 2024 +0000

    gh-117288: Allocate fewer label IDs in _PyCfg_ToInstructionSequence (#117290)

commit 74c8568d07719529b874897598d8b3bc25ff0434
Author: Malcolm Smith <[email protected]>
Date:   Wed Mar 27 16:53:27 2024 +0000

    gh-71042: Add `platform.android_ver` (#116674)

commit ce00de4c8cd39816f992e749c1074487d93abe9d
Author: Hugo van Kemenade <[email protected]>
Date:   Wed Mar 27 16:46:35 2024 +0200

    gh-117225: doctest: only print "and X failed" when non-zero, don't pluralise "1 items" (#117228)

commit 92397d5ead38dde4154e70d00f24973bcf2a925a
Author: Raymond Hettinger <[email protected]>
Date:   Wed Mar 27 09:04:32 2024 -0500

    Add statistics recipe for sampling from an estimated probability density distribution (#117221)

commit b3e8c78ed7aa9bbd1084375587b99200c687cec9
Author: Tian Gao <[email protected]>
Date:   Tue Mar 26 18:20:12 2024 -0700

    gh-113548: Allow CLI arguments to `pdb -m` (#113557)

commit 48c0b05cf0dd2db275bd4653f84aa36c22bddcd2
Author: Adorilson Bezerra <[email protected]>
Date:   Tue Mar 26 19:08:08 2024 +0000

    Change links on the index page (#117230)

commit af1b0e94400d1bf732466d675054df8cf7dfb62d
Author: AN Long <[email protected]>
Date:   Wed Mar 27 02:26:48 2024 +0800

    gh-104242: Enable test_is_char_device_true in pathlib test on all platform (GH-116983)

commit 79be75735c9d77972112cecc8d7e1af28c176ed0
Author: Irit Katriel <[email protected]>
Date:   Tue Mar 26 15:18:17 2024 +0000

    gh-115775: Compiler adds __static_attributes__ field to classes (#115913)

commit 70969d53a77a8a190c40a30419e772bc874a4f62
Author: Antonio <[email protected]>
Date:   Tue Mar 26 15:10:29 2024 +0100

    gh-97901 add missing text/rtf to mimetypes (GH-97902)

    Co-authored-by: Noam Cohen <[email protected]>

commit 4ec347760f98b156c6a2d42ca397af6b0b6ecc50
Author: AN Long <[email protected]>
Date:   Tue Mar 26 22:09:57 2024 +0800

    gh-115538: Use isolate mode when running venv test_multiprocessing_recursion() (#117116)

    Co-authored-by: Victor Stinner <[email protected]>

commit 743f2c68f478279e1e56577fe95a0ed112b9abc5
Author: Hugo van Kemenade <[email protected]>
Date:   Tue Mar 26 16:09:09 2024 +0200

    pre-commit: add `check-case-conflict` and `check-merge-conflict` (#117259)

commit 4abca7e1e7e2764faf20c7e677ea5c9ea9dbffe2
Author: Paulo Neves <[email protected]>
Date:   Tue Mar 26 13:37:50 2024 +0100

    gh-98966: Handle stdout=subprocess.STDOUT (GH-98967)

    Explicitly handle the case where stdout=STDOUT
    as otherwise the existing error handling gets
    confused and reports hard to understand errors.

    Signed-off-by: Paulo Neves <[email protected]>

commit 9654daf793b534b44a831c80f43505ab9e380f1f
Author: Serhiy Storchaka <[email protected]>
Date:   Tue Mar 26 13:26:45 2024 +0200

    gh-66543: Fix mimetype.guess_type() (GH-117217)

    Fix parsing of the following corner cases:

    * URLs with only a host name
    * URLs containing a fragment
    * URLs containing a query
    * filenames with only a UNC sharepoint on Windows

    Co-authored-by: Dong-hee Na <[email protected]>

commit 8bef34f625e21886b1c64544c060e19ee2e229bf
Author: Mark Shannon <[email protected]>
Date:   Tue Mar 26 11:11:42 2024 +0000

    GH-117108: Set the "old space bit" to "visited" for all young objects  (#117213)

    Change old space bit of young objects from 0 to gcstate->visited_space.
    This ensures that any object created *and* collected during cycle GC has the bit set correctly.

commit bf82f77957a31c3731b4ec470c406f5708ca9ba3
Author: Mark Shannon <[email protected]>
Date:   Tue Mar 26 09:35:11 2024 +0000

    GH-116422: Tier2 hot/cold splitting (GH-116813)

    Splits the "cold" path, deopts and exits, from the "hot" path, reducing the size of most jitted instructions, at the cost of slower exits.

commit 61599a48f52e951d8813877ee311d2a830ba2cd8
Author: Pablo Galindo Salgado <[email protected]>
Date:   Tue Mar 26 09:30:46 2024 +0000

    bpo-24612: Improve syntax error for 'not' after an operator (GH-28170)

    Co-authored-by: Lysandros Nikolaou <[email protected]>

commit 771902c257372e6c4df1ead4e8c46308561db7a7
Author: Hugo van Kemenade <[email protected]>
Date:   Tue Mar 26 11:13:32 2024 +0200

    gh-83845: Add tests for operator module (#115883)

    Co-authored-by: Karthikeyan Singaravelan <[email protected]>

commit ea9a296fce2f786b4cf43c7924e5de01061f27ca
Author: yevgeny hong <[email protected]>
Date:   Tue Mar 26 16:45:43 2024 +0900

    gh-115627: Fix PySSL_SetError handling SSL_ERROR_SYSCALL (GH-115628)

    Python 3.10 changed from using SSL_write() and SSL_read() to SSL_write_ex() and
    SSL_read_ex(), but did not update handling of the return value.

    Change error handling so that the return value is not examined.
    OSError (not EOF) is now returned when retval is 0.

    According to *recent* man pages of all functions for which we call
    PySSL_SetError, (in OpenSSL 3.0 and 1.1.1), their return value should
    be used to determine whether an error happened (i.e. if PySSL_SetError
    should be called), but not what kind of error happened (so,
    PySSL_SetError shouldn't need retval). To get the error,
    we need to use SSL_get_error.

    Co-authored-by: Serhiy Storchaka <[email protected]>
    Co-authored-by: Petr Viktorin <[email protected]>

commit d52bdfb19fadd7614a0e5abaf68525fc7300e841
Author: Victor Stinner <[email protected]>
Date:   Tue Mar 26 08:35:59 2024 +0100

    gh-83434: Disable XML in regrtest when -R option is used (#117232)

commit 9f74e86c78853c101a23e938f8e32ea838d8f62e
Author: Sebastian Pipping <[email protected]>
Date:   Tue Mar 26 02:48:27 2024 +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)

commit 872e212378ef86392069034afd80bb53896fd93d
Author: Jonathan Protzenko <[email protected]>
Date:   Mon Mar 25 17:35:26 2024 -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`.

commit 8945b7ff55b87d11c747af2dad0e3e4d631e62d6
Author: Eric V. Smith <[email protected]>
Date:   Mon Mar 25 19:59:14 2024 -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%.

commit 7ebad77ad65ab4d5d8d0c333256a882262cec189
Author: Raymond Hettinger <[email protected]>
Date:   Mon Mar 25 18:49:44 2024 -0500

    Sync main docs and docstring for median_grouped(). (gh-117214)

commit 0821923aa979a72464c5da8dfa53a719bba5801c
Author: Nice Zombies <[email protected]>
Date:   Mon Mar 25 23:55:11 2024 +0100

    gh-117114: Make os.path.isdevdrive available on all platforms (GH-117115)

commit c2276176d543a2fc2d57709c2787f99850fbb073
Author: Adorilson Bezerra <[email protected]>
Date:   Mon Mar 25 22:34:20 2024 +0000

    Add information about negative  indexes to sequence datamodel doc (#110903)

    Co-authored by Terry Jan Reedy

commit 23e4f80ce2a2bac50acd1785e791316d5b578b8d
Author: Mark Shannon <[email protected]>
Date:   Mon Mar 25 20:43:51 2024 +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.

commit 507896d97dcff2d7999efa264b29d9003c525c49
Author: Victor Stinner <[email protected]>
Date:   Mon Mar 25 17:32:20 2024 +0100

    gh-116936: Add PyType_GetModuleByDef() to the limited C API (#116937)

commit 0c1a42cf9c8cd0d4534d5c1d58f118ce7c5c446e
Author: Serhiy Storchaka <[email protected]>
Date:   Mon Mar 25 17:32:11 2024 +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.

commit 01e7405da400e8997f8964d06cc414045e144681
Author: Tian Gao <[email protected]>
Date:   Mon Mar 25 08:18:09 2024 -0700

    gh-112948: Make pdb completion similar to repl completion (#112950)

commit 9db2a8f914ad59019d448cecc43b6d45f46424a0
Author: Raymond Hettinger <[email protected]>
Date:   Mon Mar 25 09:26:42 2024 -0500

    Minor markup and grammar fixes in the statistics docs (gh-117216)

commit eebea7e515462b503632ada74923ec3246599c9c
Author: Kirill Podoprigora <[email protected]>
Date:   Sun Mar 24 20:34:55 2024 +0200

    gh-117176: Fix compiler warning in Python/optimizer_bytecodes.c (GH-117199)

commit 83485a095363dad6c97b19af2826ca0c34343bfc
Author: Totally a booplicate <[email protected]>
Date:   Sun Mar 24 18:48:40 2024 +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).

commit 78a651fd7fbe7a3d1702e40f4cbfa72d87241ef0
Author: Terry Jan Reedy <[email protected]>
Date:   Sun Mar 24 11:38:34 2024 -0400

    gh-117194: Properly format 'base64' header in What's New (#117198)

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

commit f267d5bf2a99fbeb26a720d1c87c1f0557424b14
Author: Kerim Kabirov <[email protected]>
Date:   Sun Mar 24 14:59:14 2024 +0100

    GH-115986 Docs: promote pprint.pp usage as a default (#116614)

    Co-authored-by: Hugo van Kemenade <[email protected]>

commit 39df7732178c8e8f75b12f069a3dbc1715c99995
Author: LilKS <[email protected]>
Date:   Sun Mar 24 11:01:07 2024 +0100

    gh-101760: Improve the imaplib.IMAP4 example (#101764)

    Co-authored-by: Adam Turner <[email protected]>

commit a1e948edba9ec6ba61365429857f7a087c5edf51
Author: Raymond Hettinger <[email protected]>
Date:   Sun Mar 24 11:35:58 2024 +0200

    Add cumulative option for the new statistics.kde() function. (#117033)

commit d610d821fd210dce63a1132c274ffdf8acc510bc
Author: Irit Katriel <[email protected]>
Date:   Sat Mar 23 22:32:33 2024 +0000

    gh-112383: teach dis how to interpret ENTER_EXECUTOR (#117171)

commit 6c83352bfe78a7d567c8d76257df6eb91d5a7245
Author: Ken Jin <[email protected]>
Date:   Sun Mar 24 06:19:17 2024 +0800

    gh-117180: Complete call sequence when trace stack overflow (GH-117184)

    ---------

    Co-authored-by: Peter Lazorchak <[email protected]>
    Co-authored-by: Guido van Rossum <[email protected]>
    Co-authored-by: Guido van Rossum <[email protected]>

commit f11d0d8be8af28e1368c3c7c116218cf65ddf93e
Author: Erik Soma <[email protected]>
Date:   Sat Mar 23 11:39:35 2024 -0400

    gh-91227: Ignore ERROR_PORT_UNREACHABLE in proactor recvfrom() (#32011)

commit 9967b568edd2e35b0415c14c7242f3ca2c0dc03d
Author: Victor Stinner <[email protected]>
Date:   Sat Mar 23 13:01:20 2024 +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.

commit 72eea512b88f8fd68b7258242c37da963ad87360
Author: Barney Gale <[email protected]>
Date:   Fri Mar 22 19:14:09 2024 +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*.

commit e28477f214276db941e715eebc8cdfb96c1207d9
Author: Mark Shannon <[email protected]>
Date:   Fri Mar 22 18:43:25 2024 +0000

    GH-117108: Change the size of the GC increment to about 1% of the total heap size. (GH-117120)

commit e2e0b4b4b92694ba894e02b4a66fd87c166ed10f
Author: Serhiy Storchaka <[email protected]>
Date:   Fri Mar 22 20:19:10 2024 +0200

    gh-113024: C API: Add PyObject_GenericHash() function (GH-113025)

commit 567ab3bd15398c8c7b791f3e376ae3e3c0bbe079
Author: Serhiy Storchaka <[email protected]>
Date:   Fri Mar 22 20:08:00 2024 +0200

    gh-117084: Fix ZIP file extraction for directory entry names with backslashes on Windows (GH-117129)

commit 5a78f6e798d5c2af1dba2df6c9f1f1e5aac02a86
Author: Serhiy Storchaka <[email protected]>
Date:   Fri Mar 22 20:03:48 2024 +0200

    gh-117134: Microoptimize glob() for include_hidden=True (GH-117135)

commit 00baaa21de229a6db80ff2b84c2fd6ad1999a24c
Author: Vinay Sajip <[email protected]>
Date:   Fri Mar 22 17:25:51 2024 +0000

    [docs] Fix typo in docstring and add example to logging cookbook. (GH-117157)

commit 40d75c2b7f5c67e254d0a025e0f2e2c7ada7f69f
Author: Jakub Stasiak <[email protected]>
Date:   Fri Mar 22 17:49:56 2024 +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

commit 3be9b9d8722696b95555937bb211dc4cda714d56
Author: Steve Dower <[email protected]>
Date:   Fri Mar 22 15:00:50 2024 +0000

    Fix get_packagefamilyname helper function on Windows 32-bit (GH-117153)

commit 63d6f2623ef2aa90f51c6a928b96845b9b380d89
Author: NGRsoftlab <[email protected]>
Date:   Fri Mar 22 14:25:38 2024 +0300

    gh-117068: Remove useless code in bytesio.c:resize_buffer() (GH-117069)

    Co-authored-by: i.khabibulin <[email protected]>

commit 42ae924d278c48a719fb0ab86357f3235a9f7ab9
Author: Petr Viktorin <[email protected]>
Date:   Fri Mar 22 10:42:18 2024 +0100

    gh-117127: glob tests: Reopen dir_fd to pick up directory changes (GH-117128)

commit 8383915031942f441f435a5ae800790116047b80
Author: Tim Peters <[email protected]>
Date:   Thu Mar 21 22:27:25 2024 -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.

commit 97ba910e47ad298114800587979ce7beb0a705a3
Author: Guido van Rossum <[email protected]>
Date:   Thu Mar 21 18:27:48 2024 -0700

    gh-108716:: Remove _PyStaticCode_Init/Fini (#117141)

    More deepfreeze cleanup.

commit b3d25df8d38b79310587da54dbd88b06a16d4904
Author: Eric Snow <[email protected]>
Date:   Thu Mar 21 18:20:20 2024 -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().

commit c4bf58a14f162557038a1535ca22c52b49d81d7b
Author: Thomas A Caswell <[email protected]>
Date:   Thu Mar 21 19:54:50 2024 -0400

    gh-116745: Remove all internal usage of @LIBPYTHON@ (#116746)

    Replace with MODULE_LDFLAGS.

commit 3ec57307e70ee6f42410e844d3399bbd598917ba
Author: Malcolm Smith <[email protected]>
Date:   Thu Mar 21 23:52:29 2024 +0000

    gh-71052: Add Android build script and instructions (#116426)

commit 50f9b0b1e0fb181875751cef951351ed007b6397
Author: Victor Stinner <[email protected]>
Date:   Thu Mar 21 23:17:09 2024 +0100

    gh-117061: Fix test_posix.test_sched_setaffinity() on RHEL9 (#117126)

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

commit 0907871d43bffb613cbd560224e1a9db13d06c06
Author: Ned Batchelder <[email protected]>
Date:   Thu Mar 21 15:47:09 2024 -0400

    docs: fix over-linking in dataclasses.rst (#117005)

commit 570a82d46abfebb9976961113fb0f8bb400ad182
Author: Guido van Rossum <[email protected]>
Date:   Thu Mar 21 12:37:41 2024 -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.

commit c85d84166a84a5cb2d724012726bad34229ad24e
Author: Will Childs-Klein <[email protected]>
Date:   Thu Mar 21 14:16:36 2024 -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

commit 1f72fb5447ef3f8892b4a7a6213522579c618e8e
Author: Sam Gross <[email protected]>
Date:   Thu Mar 21 14:21:02 2024 -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.

commit 50369e6c34d05222e5a0ec9443a9f7b230e83112
Author: Michael Droettboom <[email protected]>
Date:   Thu Mar 21 13:27:46 2024 -0400

    gh-116996: Add pystats about _Py_uop_analyse_and_optimize (GH-116997)

commit 617158e07811edfd6fd552a3d84b0beedd8f1d18
Author: Eric Snow <[email protected]>
Date:   Thu Mar 21 11:15:02 2024 -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.

commit abdd1f938f08e536864532b2071f144515ecc88b
Author: Victor Stinner <[email protected]>
Date:   Thu Mar 21 17:45:43 2024 +0100

    gh-85283: Build _testconsole extension with limited C API (#117125)

commit 8bea6c411d65cd987616b4ecdb86373e4f21f1c6
Author: Victor Stinner <[email protected]>
Date:   Thu Mar 21 17:07:00 2024 +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.

commit 5a76d1be8ef371b75ca65166726923c249b5f615
Author: Eric Snow <[email protected]>
Date:   Thu Mar 21 10:06:35 2024 -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.

commit bbee57fa8c318cb26d6c8651254927a1972c9738
Author: Eric Snow <[email protected]>
Date:   Thu Mar 21 09:56:12 2024 -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().

commit e728303532168efab7694c55c82ea19b18bf8385
Author: Sam Gross <[email protected]>
Date:   Thu Mar 21 10:01:16 2024 -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.

commit 1f8b24ef69896680d6ba6005e75e1cc79a744f9e
Author: Malcolm Smith <[email protected]>
Date:   Thu Mar 21 13:20:57 2024 +0000

    gh-71052: Implement `ctypes.util.find_library` on Android (GH-116379)

commit d16c9d1278164f04778861814ebc87ed087511fc
Author: Tian Gao <[email protected]>
Date:   Thu Mar 21 03:30:10 2024 -0700

    gh-116987: Support class code objects in inspect.findsource() (GH-117025)

commit 6547330f4e896c6748da23704b617e060e6cc68e
Author: Adam Turner <[email protected]>
Date:   Thu Mar 21 03:49:10 2024 +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 <[email protected]>

commit 667294d5b2ee812ebe0c9c1efd58e2006b61f827
Author: Jason R. Coombs <[email protected]>
Date:   Wed Mar 20 23:01:24 2024 -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)

commit f4cc77d494ee0e10ed84ce369f0910c70a2f6d44
Author: Victor Stinner <[email protected]>
Date:   Thu Mar 21 00:06:24 2024 +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.

commit 104602a6078564765b7b8f42888f8eaa37b129b1
Author: Victor Stinner <[email protected]>
Date:   Wed Mar 20 23:52:23 2024 +0100

    gh-105927: Limit PyWeakref_GetRef() to limited C API 3.13 (#117091)

commit 8ad88984200b2ccddc0a08229dd2f4c14d1a71fc
Author: Jason R. Coombs <[email protected]>
Date:   Wed Mar 20 17:11:00 2024 -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

commit 7d446548ef53f6c3de1097c6d44cada6642ddc85
Author: Carol Willing <[email protected]>
Date:   Wed Mar 20 14:00:59 2024 -0700

    Fix sort order for "locale encoding" glossary item (#115794)

    Co-authored-by: C.A.M. Gerlach <[email protected]>

commit 63289b9dfbc7d87e81f1517422ee91b6b6d19531
Author: Mark Shannon <[email protected]>
Date:   Wed Mar 20 18:24:02 2024 +0000

    GH-117066: Tier 2 optimizer: Don't throw away good traces if we can't optimize them perfectly. (GH-117067)

commit dcaf33a41d5d220523d71c9b35bc08f5b8405dac
Author: Petr Viktorin <[email protected]>
Date:   Wed Mar 20 17:33:08 2024 +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 <[email protected]>
    Co-authored-by: Erlend E. Aasland <[email protected]>

commit 44fbab43d8f3f2df07091d237824cf4fa1f6c57c
Author: Russell Keith-Magee <[email protected]>
Date:   Wed Mar 20 23:32:56 2024 +0800

    gh-117058: Update GUI and packaging recommendations for macOS. (#117059)

commit 9221ef2d8cb7f4cf37592eb650d4c8f972033000
Author: Brett Simmers <[email protected]>
Date:   Wed Mar 20 08:18:26 2024 -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`.

commit fc4599800778f9b130d5e336deadbdeb5bd3e5ee
Author: jkriegshauser <[email protected]>
Date:   Wed Mar 20 07:33:28 2024 -0700

    gh-116773: Ensure overlapped objects on Windows are not deallocated too early by asyncio (GH-116774)

commit 519b2ae22b54760475bbf62b9558d453c703f9c6
Author: Serhiy Storchaka <[email protected]>
Date:   Wed Mar 20 15:39:53 2024 +0200

    gh-117021: Fix integer overflow in PyLong_AsPid() on non-Windows 64-bit platforms (GH-117064)
diegorusso pushed a commit to diegorusso/cpython that referenced this issue Apr 17, 2024
…honGH-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 <[email protected]>
Co-authored-by: Erlend E. Aasland <[email protected]>
@benmoran56
Copy link

benmoran56 commented Sep 1, 2024

It looks like this PR is causing a crash in pyglet - specifically our Windows com wrapper. I'm not familiar with the com code, so I haven't yet had time to determine if it's something we're doing wrong, or if we're hitting a edge case bug here.
pyglet/pyglet#1196

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extension-modules C modules in the Modules dir topic-C-API type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

5 participants