Skip to content

Commit 93e170e

Browse files
committed
Merge branch 'main' into revive-138569
2 parents 9ed6b1a + b866a1c commit 93e170e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+3763
-1873
lines changed

Doc/library/argparse.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ upper-cased name. For example::
753753

754754
>>> parser = argparse.ArgumentParser(prog='PROG')
755755
>>> parser.add_argument('--foo-bar')
756-
>>> parser.parse_args(['--foo-bar', 'FOO-BAR']
756+
>>> parser.parse_args(['--foo-bar', 'FOO-BAR'])
757757
Namespace(foo_bar='FOO-BAR')
758758
>>> parser.print_help()
759759
usage: [-h] [--foo-bar FOO-BAR]

Doc/library/email.message.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ message objects.
5757
:class:`~email.policy.default` policy, which follows the rules of the email
5858
RFCs except for line endings (instead of the RFC mandated ``\r\n``, it uses
5959
the Python standard ``\n`` line endings). For more information see the
60-
:mod:`~email.policy` documentation.
60+
:mod:`~email.policy` documentation. [2]_
6161

6262
.. method:: as_string(unixfrom=False, maxheaderlen=None, policy=None)
6363

@@ -749,3 +749,9 @@ message objects.
749749
.. [1] Originally added in 3.4 as a :term:`provisional module <provisional
750750
package>`. Docs for legacy message class moved to
751751
:ref:`compat32_message`.
752+
753+
.. [2] The :class:`EmailMessage` class requires a policy that provides a
754+
``content_manager`` attribute for content management methods like
755+
``set_content()`` and ``get_content()`` to work. The legacy
756+
:const:`~email.policy.compat32` policy does not support these methods
757+
and should not be used with :class:`EmailMessage`.

Doc/library/email.policy.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,13 @@ The header objects and their attributes are described in
662662
An instance of :class:`Compat32`, providing backward compatibility with the
663663
behavior of the email package in Python 3.2.
664664

665+
.. note::
666+
667+
The :const:`compat32` policy should not be used as a policy for
668+
:class:`~email.message.EmailMessage` objects, and should only be used
669+
to serialize messages that were created using the :const:`compat32`
670+
policy.
671+
665672

666673
.. rubric:: Footnotes
667674

Doc/library/os.rst

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1556,6 +1556,15 @@ or `the MSDN <https://msdn.microsoft.com/en-us/library/z0kc8e3z.aspx>`_ on Windo
15561556
.. versionadded:: 3.15
15571557

15581558

1559+
.. data:: RWF_ATOMIC
1560+
1561+
Write data atomically. Requires alignment to the device's atomic write unit.
1562+
1563+
.. availability:: Linux >= 6.11
1564+
1565+
.. versionadded:: next
1566+
1567+
15591568
.. function:: ptsname(fd, /)
15601569

15611570
Return the name of the slave pseudo-terminal device associated with the
@@ -1598,6 +1607,7 @@ or `the MSDN <https://msdn.microsoft.com/en-us/library/z0kc8e3z.aspx>`_ on Windo
15981607
- :data:`RWF_SYNC`
15991608
- :data:`RWF_APPEND`
16001609
- :data:`RWF_DONTCACHE`
1610+
- :data:`RWF_ATOMIC`
16011611

16021612
Return the total number of bytes actually written.
16031613

@@ -1969,7 +1979,8 @@ can be inherited by child processes. Since Python 3.4, file descriptors
19691979
created by Python are non-inheritable by default.
19701980

19711981
On UNIX, non-inheritable file descriptors are closed in child processes at the
1972-
execution of a new program, other file descriptors are inherited.
1982+
execution of a new program, other file descriptors are inherited. Note that
1983+
non-inheritable file descriptors are still *inherited* by child processes on :func:`os.fork`.
19731984

19741985
On Windows, non-inheritable handles and file descriptors are closed in child
19751986
processes, except for standard streams (file descriptors 0, 1 and 2: stdin, stdout

Doc/library/stdtypes.rst

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2045,7 +2045,18 @@ expression support in the :mod:`re` module).
20452045
.. method:: str.index(sub[, start[, end]])
20462046

20472047
Like :meth:`~str.find`, but raise :exc:`ValueError` when the substring is
2048-
not found.
2048+
not found. For example:
2049+
2050+
.. doctest::
2051+
2052+
>>> 'spam, spam, spam'.index('eggs')
2053+
Traceback (most recent call last):
2054+
File "<python-input-0>", line 1, in <module>
2055+
'spam, spam, spam'.index('eggs')
2056+
~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
2057+
ValueError: substring not found
2058+
2059+
See also :meth:`rindex`.
20492060

20502061

20512062
.. method:: str.isalnum()
@@ -2190,6 +2201,15 @@ expression support in the :mod:`re` module).
21902201
Nonprintable characters are those in group Separator or Other (Z or C),
21912202
except the ASCII space.
21922203

2204+
For example:
2205+
2206+
.. doctest::
2207+
2208+
>>> ''.isprintable(), ' '.isprintable()
2209+
(True, True)
2210+
>>> '\t'.isprintable(), '\n'.isprintable()
2211+
(False, False)
2212+
21932213

21942214
.. method:: str.isspace()
21952215

Doc/library/tempfile.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,9 @@ The module defines the following user-callable items:
225225
properly implements the :const:`os.O_EXCL` flag for :func:`os.open`. The
226226
file is readable and writable only by the creating user ID. If the
227227
platform uses permission bits to indicate whether a file is executable,
228-
the file is executable by no one. The file descriptor is not inherited
229-
by child processes.
228+
the file is executable by no one.
229+
230+
The file descriptor is :ref:`not inherited by child processes <fd_inheritance>`.
230231

231232
Unlike :func:`TemporaryFile`, the user of :func:`mkstemp` is responsible
232233
for deleting the temporary file when done with it.

Doc/whatsnew/3.15.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,11 @@ Results from the `pyperformance <https://github.com/python/pyperformance>`__
891891
benchmark suite report
892892
`3-4% <https://github.com/facebookexperimental/free-threading-benchmarking/blob/main/results/bm-20251214-3.15.0a2%2B-6cddf04-JIT/bm-20251214-vultr-x86_64-python-6cddf04344a1e8ca9df5-3.15.0a2%2B-6cddf04-vs-base.svg>`__
893893
geometric mean performance improvement for the JIT over the standard CPython
894-
interpreter built with all optimizations enabled. The speedups for JIT
894+
interpreter built with all optimizations enabled on x86-64 Linux. On AArch64
895+
macOS, the JIT has a
896+
`7-8% <https://raw.githubusercontent.com/facebookexperimental/free-threading-benchmarking/refs/heads/main/results/bm-20260103-3.15.0a3%2B-9609574-JIT/bm-20260103-macm4pro-arm64-python-9609574e7fd36edfaa8b-3.15.0a3%2B-9609574-vs-base.svg>`__
897+
speedup over the :ref:`tail calling interpreter <whatsnew314-tail-call-interpreter>`
898+
with all optimizations enabled. The speedups for JIT
895899
builds versus no JIT builds range from roughly 20% slowdown to over
896900
100% speedup (ignoring the ``unpack_sequence`` microbenchmark) on
897901
x86-64 Linux and AArch64 macOS systems.

Include/internal/pycore_code.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,12 @@ typedef struct {
160160

161161
#define INLINE_CACHE_ENTRIES_CONTAINS_OP CACHE_ENTRIES(_PyContainsOpCache)
162162

163+
typedef struct {
164+
_Py_BackoffCounter counter;
165+
} _PyCallFunctionExCache;
166+
167+
#define INLINE_CACHE_ENTRIES_CALL_FUNCTION_EX CACHE_ENTRIES(_PyCallFunctionExCache)
168+
163169
/* "Locals plus" for a code object is the set of locals + cell vars +
164170
* free vars. This relates to variable names as well as offsets into
165171
* the "fast locals" storage array of execution frames. The compiler
@@ -326,6 +332,7 @@ PyAPI_FUNC(void) _Py_Specialize_Send(_PyStackRef receiver, _Py_CODEUNIT *instr);
326332
PyAPI_FUNC(void) _Py_Specialize_ToBool(_PyStackRef value, _Py_CODEUNIT *instr);
327333
PyAPI_FUNC(void) _Py_Specialize_ContainsOp(_PyStackRef value, _Py_CODEUNIT *instr);
328334
PyAPI_FUNC(void) _Py_GatherStats_GetIter(_PyStackRef iterable);
335+
PyAPI_FUNC(void) _Py_Specialize_CallFunctionEx(_PyStackRef func_st, _Py_CODEUNIT *instr);
329336

330337
// Utility functions for reading/writing 32/64-bit values in the inline caches.
331338
// Great care should be taken to ensure that these functions remain correct and

Include/internal/pycore_interpframe.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,10 @@ _PyEvalFramePushAndInit(PyThreadState *tstate, _PyStackRef func,
395395
size_t argcount, PyObject *kwnames,
396396
_PyInterpreterFrame *previous);
397397

398+
PyAPI_FUNC(_PyInterpreterFrame *)
399+
_PyEvalFramePushAndInit_Ex(PyThreadState *tstate, _PyStackRef func,
400+
PyObject *locals, Py_ssize_t nargs, PyObject *callargs, PyObject *kwargs, _PyInterpreterFrame *previous);
401+
398402
#ifdef __cplusplus
399403
}
400404
#endif

Include/internal/pycore_magic_number.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,8 @@ Known values:
288288
Python 3.15a1 3655 (Fix miscompilation of some module-level annotations)
289289
Python 3.15a2 3656 (Add TRACE_RECORD instruction, for platforms with switch based interpreter)
290290
Python 3.15a4 3657 (Add BINARY_OP_SUBSCR_USTR_INT)
291+
Python 3.15a4 3658 (Optimize bytecode for list/set called on genexp)
292+
Python 3.15a4 3659 (Add CALL_FUNCTION_EX specialization)
291293
292294
293295
Python 3.16 will start with 3700
@@ -301,7 +303,7 @@ PC/launcher.c must also be updated.
301303
302304
*/
303305

304-
#define PYC_MAGIC_NUMBER 3657
306+
#define PYC_MAGIC_NUMBER 3659
305307
/* This is equivalent to converting PYC_MAGIC_NUMBER to 2 bytes
306308
(little-endian) and then appending b'\r\n'. */
307309
#define PYC_MAGIC_NUMBER_TOKEN \

0 commit comments

Comments
 (0)