Skip to content

Commit bb6a5a6

Browse files
authored
Merge branch 'main' into fix-issue-141831
2 parents 6748034 + 0387a8e commit bb6a5a6

38 files changed

+1708
-1497
lines changed

Doc/c-api/intro.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,19 @@ complete listing.
322322
PyDoc_VAR(python_doc) = PyDoc_STR("A genus of constricting snakes in the Pythonidae family native "
323323
"to the tropics and subtropics of the Eastern Hemisphere.");
324324

325+
.. c:macro:: Py_ARRAY_LENGTH(array)
326+
327+
Compute the length of a statically allocated C array at compile time.
328+
329+
The *array* argument must be a C array with a size known at compile time.
330+
Passing an array with an unknown size, such as a heap-allocated array,
331+
will result in a compilation error on some compilers, or otherwise produce
332+
incorrect results.
333+
334+
This is roughly equivalent to::
335+
336+
sizeof(array) / sizeof((array)[0])
337+
325338

326339
.. _api-objects:
327340

Doc/howto/a-conceptual-overview-of-asyncio.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,12 @@ Creating a task automatically schedules it for execution (by adding a
175175
callback to run it in the event loop's to-do list, that is, collection of jobs).
176176
The recommended way to create tasks is via :func:`asyncio.create_task`.
177177

178-
Since there's only one event loop (in each thread), :mod:`!asyncio` takes
179-
care of associating the task with the event loop for you.
180-
As such, there's no need to specify the event loop.
178+
:mod:`!asyncio` automatically associates tasks with the event loop for you.
179+
This automatic association was purposely designed into :mod:`!asyncio` for
180+
the sake of simplicity.
181+
Without it, you'd have to keep track of the event loop object and pass it to
182+
any coroutine function that wants to create tasks, adding redundant clutter
183+
to your code.
181184

182185
::
183186

Doc/howto/unicode.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,8 @@ If you don't include such a comment, the default encoding used will be UTF-8 as
352352
already mentioned. See also :pep:`263` for more information.
353353

354354

355+
.. _unicode-properties:
356+
355357
Unicode Properties
356358
------------------
357359

Doc/library/math.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ Summation and product functions
506506

507507
Roughly equivalent to::
508508

509-
sqrt(sum((px - qx) ** 2.0 for px, qx in zip(p, q)))
509+
sqrt(sum((px - qx) ** 2.0 for px, qx in zip(p, q, strict=True)))
510510

511511
.. versionadded:: 3.8
512512

Doc/library/profile.rst

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -347,81 +347,6 @@ The statistical profiler produces output similar to deterministic profilers but
347347

348348
.. _profile-cli:
349349

350-
:mod:`!profiling.sampling` Module Reference
351-
=======================================================
352-
353-
.. module:: profiling.sampling
354-
:synopsis: Python statistical profiler.
355-
356-
This section documents the programmatic interface for the :mod:`!profiling.sampling` module.
357-
For command-line usage, see :ref:`sampling-profiler-cli`. For conceptual information
358-
about statistical profiling, see :ref:`statistical-profiling`
359-
360-
.. function:: sample(pid, *, sort=2, sample_interval_usec=100, duration_sec=10, filename=None, all_threads=False, limit=None, show_summary=True, output_format="pstats", realtime_stats=False, native=False, gc=True)
361-
362-
Sample a Python process and generate profiling data.
363-
364-
This is the main entry point for statistical profiling. It creates a
365-
:class:`SampleProfiler`, collects stack traces from the target process, and
366-
outputs the results in the specified format.
367-
368-
:param int pid: Process ID of the target Python process
369-
:param int sort: Sort order for pstats output (default: 2 for cumulative time)
370-
:param int sample_interval_usec: Sampling interval in microseconds (default: 100)
371-
:param int duration_sec: Duration to sample in seconds (default: 10)
372-
:param str filename: Output filename (None for stdout/default naming)
373-
:param bool all_threads: Whether to sample all threads (default: False)
374-
:param int limit: Maximum number of functions to display (default: None)
375-
:param bool show_summary: Whether to show summary statistics (default: True)
376-
:param str output_format: Output format - 'pstats' or 'collapsed' (default: 'pstats')
377-
:param bool realtime_stats: Whether to display real-time statistics (default: False)
378-
:param bool native: Whether to include ``<native>`` frames (default: False)
379-
:param bool gc: Whether to include ``<GC>`` frames (default: True)
380-
381-
:raises ValueError: If output_format is not 'pstats' or 'collapsed'
382-
383-
Examples::
384-
385-
# Basic usage - profile process 1234 for 10 seconds
386-
import profiling.sampling
387-
profiling.sampling.sample(1234)
388-
389-
# Profile with custom settings
390-
profiling.sampling.sample(1234, duration_sec=30, sample_interval_usec=50, all_threads=True)
391-
392-
# Generate collapsed stack traces for flamegraph.pl
393-
profiling.sampling.sample(1234, output_format='collapsed', filename='profile.collapsed')
394-
395-
.. class:: SampleProfiler(pid, sample_interval_usec, all_threads)
396-
397-
Low-level API for the statistical profiler.
398-
399-
This profiler uses periodic stack sampling to collect performance data
400-
from running Python processes with minimal overhead. It can attach to
401-
any Python process by PID and collect stack traces at regular intervals.
402-
403-
:param int pid: Process ID of the target Python process
404-
:param int sample_interval_usec: Sampling interval in microseconds
405-
:param bool all_threads: Whether to sample all threads or just the main thread
406-
407-
.. method:: sample(collector, duration_sec=10)
408-
409-
Sample the target process for the specified duration.
410-
411-
Collects stack traces from the target process at regular intervals
412-
and passes them to the provided collector for processing.
413-
414-
:param collector: Object that implements ``collect()`` method to process stack traces
415-
:param int duration_sec: Duration to sample in seconds (default: 10)
416-
417-
The method tracks sampling statistics and can display real-time
418-
information if realtime_stats is enabled.
419-
420-
.. seealso::
421-
422-
:ref:`sampling-profiler-cli`
423-
Command-line interface documentation for the statistical profiler.
424-
425350
Deterministic Profiler Command Line Interface
426351
=============================================
427352

Doc/library/stdtypes.rst

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2057,13 +2057,32 @@ expression support in the :mod:`re` module).
20572057
from the `Alphabetic property defined in the section 4.10 'Letters, Alphabetic, and
20582058
Ideographic' of the Unicode Standard
20592059
<https://www.unicode.org/versions/Unicode17.0.0/core-spec/chapter-4/#G91002>`__.
2060+
For example:
2061+
2062+
.. doctest::
2063+
2064+
>>> 'Letters and spaces'.isalpha()
2065+
False
2066+
>>> 'LettersOnly'.isalpha()
2067+
True
2068+
>>> 'µ'.isalpha() # non-ASCII characters can be considered alphabetical too
2069+
True
2070+
2071+
See :ref:`unicode-properties`.
20602072

20612073

20622074
.. method:: str.isascii()
20632075

20642076
Return ``True`` if the string is empty or all characters in the string are ASCII,
20652077
``False`` otherwise.
2066-
ASCII characters have code points in the range U+0000-U+007F.
2078+
ASCII characters have code points in the range U+0000-U+007F. For example:
2079+
2080+
.. doctest::
2081+
2082+
>>> 'ASCII characters'.isascii()
2083+
True
2084+
>>> 'µ'.isascii()
2085+
False
20672086

20682087
.. versionadded:: 3.7
20692088

@@ -2073,9 +2092,18 @@ expression support in the :mod:`re` module).
20732092
Return ``True`` if all characters in the string are decimal
20742093
characters and there is at least one character, ``False``
20752094
otherwise. Decimal characters are those that can be used to form
2076-
numbers in base 10, e.g. U+0660, ARABIC-INDIC DIGIT
2095+
numbers in base 10, such as U+0660, ARABIC-INDIC DIGIT
20772096
ZERO. Formally a decimal character is a character in the Unicode
2078-
General Category "Nd".
2097+
General Category "Nd". For example:
2098+
2099+
.. doctest::
2100+
2101+
>>> '0123456789'.isdecimal()
2102+
True
2103+
>>> '٠١٢٣٤٥٦٧٨٩'.isdecimal() # Arabic-Indic digits zero to nine
2104+
True
2105+
>>> 'alphabetic'.isdecimal()
2106+
False
20792107

20802108

20812109
.. method:: str.isdigit()

Doc/tools/templates/dummy.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727

2828
In extensions/changes.py:
2929

30-
{% trans %}Deprecated since version {deprecated}, will be removed in version {removed}{% endtrans %}
31-
{% trans %}Deprecated since version {deprecated}, removed in version {removed}{% endtrans %}
30+
{% trans %}Deprecated since version %s, will be removed in version %s{% endtrans %}
31+
{% trans %}Deprecated since version %s, removed in version %s{% endtrans %}
3232

3333
In docsbuild-scripts, when rewriting indexsidebar.html with actual versions:
3434

Include/internal/pycore_import.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,18 @@ PyAPI_FUNC(int) _PyImport_ClearExtension(PyObject *name, PyObject *filename);
128128
// state of the module argument:
129129
// - If module is NULL or a PyModuleObject with md_gil == Py_MOD_GIL_NOT_USED,
130130
// call _PyEval_DisableGIL().
131-
// - Otherwise, call _PyEval_EnableGILPermanent(). If the GIL was not already
132-
// enabled permanently, issue a warning referencing the module's name.
131+
// - Otherwise, call _PyImport_EnableGILAndWarn
133132
//
134133
// This function may raise an exception.
135134
extern int _PyImport_CheckGILForModule(PyObject *module, PyObject *module_name);
135+
// Assuming that the GIL is enabled from a call to
136+
// _PyEval_EnableGILTransient(), call _PyEval_EnableGILPermanent().
137+
// If the GIL was not already enabled permanently, issue a warning referencing
138+
// the module's name.
139+
// Leave a message in verbose mode.
140+
//
141+
// This function may raise an exception.
142+
extern int _PyImport_EnableGILAndWarn(PyThreadState *, PyObject *module_name);
136143
#endif
137144

138145
#ifdef __cplusplus

Lib/_pyrepl/simple_interact.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import sys
3232
import code
3333
import warnings
34-
import errno
3534

3635
from .readline import _get_reader, multiline_input, append_history_file
3736

Lib/asyncio/tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Tools to analyze tasks running in asyncio programs."""
22

3-
from collections import defaultdict, namedtuple
3+
from collections import defaultdict
44
from itertools import count
55
from enum import Enum
66
import sys

0 commit comments

Comments
 (0)