-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
gh-77714: Provide an async iterator version of as_completed #22491
gh-77714: Provide an async iterator version of as_completed #22491
Conversation
Replaced the commit to conform the new async iterator to the format originally suggested in bpo-33533, where yielded objects are awaitables (including any of the original Futures passed in). I also added Docs adjustments, What's New, and NEWS.d. |
* 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
Follows the revisions made based on @hniksic's feedback.
The issue that motivated this PR is almost 3 years old now and it really is something I wish had been merged already. Can we still hope to have it in for 3.10? |
Is there anything that members of the python community can do to get this issue higher on the priority list of reviewers? |
Probably nothing more than upvoting this PR (which I just did). |
Hi, could you re-target for 3.12 (WhatsNew 3.10), please? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Sorry, I still need to review the tests. I'll do that after I've received your response on this partial review.)
Doc/library/asyncio-task.rst
Outdated
Run :ref:`awaitable objects <asyncio-awaitables>` in the *aws* | ||
iterable concurrently. Return an iterator of coroutines. | ||
Each coroutine returned can be awaited to get the earliest next | ||
result from the iterable of the remaining awaitables. | ||
Run :ref:`awaitable objects <asyncio-awaitables>` in the *aws* iterable | ||
concurrently. Returns an :term:`asynchronous iterator` of the next-completed | ||
Tasks or Futures. If Tasks or Futures are supplied, those same objects are | ||
yielded on completion. Other awaitables are scheduled and their implicitly | ||
created Tasks are yielded instead. | ||
|
||
Raises :exc:`TimeoutError` if the timeout occurs before | ||
all Futures are done. | ||
|
||
Example:: | ||
|
||
for coro in as_completed(aws): | ||
earliest_result = await coro | ||
async for task in as_completed(aws): | ||
earliest_result = await task | ||
# ... | ||
|
||
For backwards compatibility, the object returned by ``as_completed()`` | ||
can be iterated as a plain iterator, yielding new coroutines that return | ||
the results or raise the errors of the passed in awaitables as their tasks | ||
finish.:: | ||
|
||
for aw in as_completed(aws): | ||
earliest_result = await aw | ||
# ... | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I object against the change to emphasize the async iterator API over the synchronous iterator. Since the two examples are identical except for the added keyword await
in the former, it makes more sense to describe both variants as equivalent, and explain the difference carefully. The advantage of using the async version should be clear to those who need it. The disadvantage (no support in 3.12 or before) should also be clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll do that. This was biased towards deprecating the older format, knowing it could mean replacing this hybrid class with a simpler and faster async generator down the line.
Doc/library/asyncio-task.rst
Outdated
result from the iterable of the remaining awaitables. | ||
Run :ref:`awaitable objects <asyncio-awaitables>` in the *aws* iterable | ||
concurrently. Returns an :term:`asynchronous iterator` of the next-completed | ||
Tasks or Futures. If Tasks or Futures are supplied, those same objects are |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend against capitalizing Tasks and Futures -- depending on what loop.create_future()
and loop.create_task()
, they may or may not return an actual instance or a duck type equivalent. If you really mean the specific classes they should at least be put in code font, and probably cross-linked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. We use is_future
to decide, which duck-types on presence of ._asyncio_future_blocking
. Will lower-case these.
Doc/library/asyncio-task.rst
Outdated
for coro in as_completed(aws): | ||
earliest_result = await coro | ||
async for task in as_completed(aws): | ||
earliest_result = await task | ||
# ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can expand the example to include a meaningful result (e.g. some data read from a URL?), so there is even more clarity about how to obtain it? Then update the second example too. Or, even better (but more code) show an example where we actually need a table mapping tasks to results (which can't be done using the synchronous iterator).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've finished the other requested doc changes, but still thinking about this one. I tried to come up with a toy example originally, but they always ended up overly verbose. With URLs, we could invent an example with aiohttp or httpx. If we want to stick to standard libraries, we could instead do something DNS-related (e.g. happy eyeballs IPv4 vs IPv6 race). Open to ideas.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sleep sort.
from asyncio import as_completed, sleep, run
import random
async def sleep_and_return(x):
await sleep(x)
return x
async def sleep_sort(data):
for coro in as_completed(sleep_and_return(x) for x in data):
res = await coro
print(res)
run(sleep_sort([random.random() for i in range(10)]))
The same can be used also with asynchronous iteration, but the variant that requires keeping identity of futures:
from asyncio import as_completed, sleep, ensure_future, run
import random
def sleeping_future(x):
fut = ensure_future(sleep(x))
fut.x = x
return fut
async def sleep_sort(data):
async for fut in as_completed(sleeping_future(x) for x in data):
await fut
print(fut.x)
run(sleep_sort([random.random() for i in range(10)]))
Doc/whatsnew/3.13.rst
Outdated
@@ -163,6 +163,15 @@ asyncio | |||
the Unix socket when the server is closed. | |||
(Contributed by Pierre Ossman in :gh:`111246`.) | |||
|
|||
* :func:`asyncio.as_completed` now returns an :term:`asynchronous iterator` of | |||
awaitables. | |||
The yielded awaitables include Task or Future objects that were passed in, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, don't capitalize task or future.
Lib/asyncio/tasks.py
Outdated
"""Doubles as an async iterator of as-completed tasks and futures | ||
from a supplied set of awaitables and a plain iterator of | ||
coroutines that resolve to results from the supplied awaitables as | ||
their underlying tasks or futures complete. | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer docstrings that start with a brief one-line summary followed blank line, then you can put what you have here.
Also, this sentence is very long. Try rewriting as several shorter sentences.
Lib/asyncio/tasks.py
Outdated
their underlying tasks or futures complete. | ||
""" | ||
def __init__(self, aws, timeout): | ||
from .queues import Queue # Import here to avoid circular import problem. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this still a problem? I don't see how asyncio/queues.py would import asyncio/tasks.py. The original code that had this is a decade old, likely the problem was solved in another way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still recommend moving this to the top level imports.
Lib/asyncio/tasks.py
Outdated
"""Waits for the next future to be done and returns it unless resolve | ||
is set, in which case it returns either the result of the future or | ||
raises an exception.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this should be a comment, not a docstring? (Also the use of present tense "Waits ..." makes me queasy -- IIRC we have some kind of guideline against it, preferring the imperative mood instead?)
(Also if you remove the resolve
argument as I suggested above this becomes much simpler.)
Lib/asyncio/tasks.py
Outdated
"""Return an async iterator that yields tasks from the given awaitables | ||
in the order they finish as they finish. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer a single-line summary here as well. And probably more equal treatment of both forms, as I recommended in the docs.
:func:`asyncio.as_completed` now returns an asynchronous iterator. Patch by | ||
Justin Arthur. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe clarify that the iterator is ambidextrous (or polymorphic or whatever :-).
Thank you very much for taking a look at this one, @serhiy-storchaka and @gvanrossum; it's great to see activity from leads. I'll take a look at the sync-up code changes and review comments this weekend unless someone else wants to jump in earlier. This code was from 3 years ago, so I'll have to re-immerse myself. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JustinTArthur thanks! I have a few nits on the docs and I still think that import should be moved. Otherwise LGTM, but I hope @serhiy-storchaka @serhiy-storchaka will also review this one more time. This is an important thing to get right!
Doc/library/asyncio-task.rst
Outdated
ipv4_connect = create_task( | ||
open_connection("127.0.0.1", 80) | ||
) | ||
ipv6_connect = create_task( | ||
open_connection("::1", 80) | ||
) | ||
tasks = [ipv4_connect, ipv6_connect] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be written more compactly:
ipv4_connect = create_task( | |
open_connection("127.0.0.1", 80) | |
) | |
ipv6_connect = create_task( | |
open_connection("::1", 80) | |
) | |
tasks = [ipv4_connect, ipv6_connect] | |
tasks = [ | |
create_task(open_connection("127.0.0.1", 80)), | |
create_task(open_connection("::1", 80)), | |
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need the ipv6_connect
variable for use in the identity check below.
Doc/library/asyncio-task.rst
Outdated
for coro in as_completed(aws): | ||
earliest_result = await coro | ||
# ... | ||
for coro in as_completed(aws): | ||
earliest_result = await coro | ||
# ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice if this example used the same variable names as the full example above, to emphasize how similar they are (async for
-> for
).
for earliest_connect in as_completed(tasks):
reader, writer = await earliest_connect
# ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be misleading to name the synchronous for
variable earliest_connect
, because it is not one of ipv4_connect
or ipv6_connect
. If you expand # ...
to the same code as in the asynchronous iteration example, it will not fail, but work incorrectly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And yet, these two are completely equivalent:
async for result in as_completed([ipv4_connect, ipv6_connect]):
r, w = await result
and
for result in as_completed([ipv4_connect, ipv6_connect]):
r, w = await result
It's true that result
represents something different, but in most cases you just want to await it, and then it's the same.
Maybe we need two examples -- one showing that if you just await the result, there's no difference; another showing that only async for
can identify the task that first completed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. And note that in the asynchronous iteration example it could not necessary be await
, it could be a synchronous operation, like result()
or result.get()
. await
is only used to mimic the old code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, the result is already 'done' in that case? I had not realized that subtlety. Worth pointing out in the docs then!
Lib/asyncio/tasks.py
Outdated
during asynchronous iteration. plain iterator of | ||
coroutines that resolve to results from the supplied awaitables as | ||
their underlying tasks or futures complete. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The latter sentence seems to be missing something (at least a verb)?
Lib/asyncio/tasks.py
Outdated
their underlying tasks or futures complete. | ||
""" | ||
def __init__(self, aws, timeout): | ||
from .queues import Queue # Import here to avoid circular import problem. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still recommend moving this to the top level imports.
Lib/asyncio/tasks.py
Outdated
ipv4_connect = create_task( | ||
open_connection("127.0.0.1", 80) | ||
) | ||
ipv6_connect = create_task( | ||
open_connection("::1", 80) | ||
) | ||
tasks = [ipv4_connect, ipv6_connect] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I suggested in the full docs.
Lib/asyncio/tasks.py
Outdated
for coro in as_completed(aws): | ||
earliest_result = await coro | ||
# ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
Also please resolve the merge conflict (should be simple, something else was added to the asyncio section in what's new). |
Doc/library/asyncio-task.rst
Outdated
ipv4_connect = create_task( | ||
open_connection("127.0.0.1", 80) | ||
) | ||
ipv6_connect = create_task( | ||
open_connection("::1", 80) | ||
) | ||
tasks = [ipv4_connect, ipv6_connect] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need the ipv6_connect
variable for use in the identity check below.
Doc/library/asyncio-task.rst
Outdated
for coro in as_completed(aws): | ||
earliest_result = await coro | ||
# ... | ||
for coro in as_completed(aws): | ||
earliest_result = await coro | ||
# ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be misleading to name the synchronous for
variable earliest_connect
, because it is not one of ipv4_connect
or ipv6_connect
. If you expand # ...
to the same code as in the asynchronous iteration example, it will not fail, but work incorrectly.
Co-authored-by: Guido van Rossum <[email protected]> Co-authored-by: Serhiy Storchaka <[email protected]>
# Conflicts: # Doc/whatsnew/3.13.rst
Thanks, all. I don't mind the nits. Synced with HEAD of main and resolved the conflict. I'm definitely OK with us reverting the late import. Were you having issues with the module-level import after your initial sync with main, @serhiy-storchaka? Also let me know if you'd like me to try resolving it. @gvanrossum and @serhiy-storchaka are you OK with the "tasks or futures" terminology used throughout? It could be simplified as just "futures", though I expect tasks to be the more common in practice working with other high-level operations. I've updated the examples in the doc and docstring to use the IPv4+IPv6 connection scenario for both async and plain iteration. Let me know if this too verbose. We could consider truncating the task setup from the second example if needed. The doc and function docstring are now pretty similar to eachother. Let me know if one needs to be trimmed down. |
I checked several times (months ago and yesterday), and have not found any issues with moving the Queue import at the module level. It does not create a reference loop and does not add any heavy import. Actually, it does not change the import graph, because |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
The changes since my last review are documentation-only changes, and I can miss some errors, but I like these changes, they clarify some details very well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, let's merge.
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)
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)
…thonGH-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]>
as_completed
returns an object that is bothtest_as_completed_reverse_wait
was left alone because it specifically tests for quirks with the older style where multiple awaitables can be yielded prior to awaiting them, but each returned awaitable always represents the next-completed task regardless of the order in which it was returned.test_as_completed_resume_iterator
test added to ensure iterator can be resumed in both styles.test_as_completed_same_tasks_in_as_out
test added to ensure tasks passed to the new style are yielded back as-is.Example:
This is similar to #10251, but that PR's implementation does not have
as_completed
return an iterator, so the object's iteration could not be resumed with subsequentfor
statements or calls tonext()
. I don't know how widely this is done, but I wanted to ensure backwards compatibility.https://bugs.python.org/issue33533
#77714