Skip to content

Commit 92e4c77

Browse files
committed
Fix merge conflicts.
2 parents e79162d + 6b632ce commit 92e4c77

147 files changed

Lines changed: 6443 additions & 2306 deletions

File tree

Some content is hidden

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

.github/workflows/posix-deps-apt.sh

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,16 @@ apt-get -yq --no-install-recommends install \
2626
xvfb \
2727
zlib1g-dev
2828

29-
# Workaround missing libmpdec-dev on ubuntu 24.04:
30-
# https://launchpad.net/~ondrej/+archive/ubuntu/php
31-
# https://deb.sury.org/
32-
sudo add-apt-repository ppa:ondrej/php
33-
apt-get update
34-
apt-get -yq --no-install-recommends install libmpdec-dev
29+
# Workaround missing libmpdec-dev on ubuntu 24.04 by building mpdecimal
30+
# from source. ppa:ondrej/php (launchpad.net) are unreliable
31+
# (https://status.canonical.com) so fetch the tarball directly
32+
# from the upstream host.
33+
# https://www.bytereef.org/mpdecimal/
34+
MPDECIMAL_VERSION=4.0.1
35+
curl -fsSL "https://www.bytereef.org/software/mpdecimal/releases/mpdecimal-${MPDECIMAL_VERSION}.tar.gz" \
36+
| tar -xz -C /tmp
37+
(cd "/tmp/mpdecimal-${MPDECIMAL_VERSION}" \
38+
&& ./configure --prefix=/usr/local \
39+
&& make -j"$(nproc)" \
40+
&& make install)
41+
ldconfig

Doc/c-api/perfmaps.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Note that holding an :term:`attached thread state` is not required for these API
3131
or ``-2`` on failure to create a lock. Check ``errno`` for more information
3232
about the cause of a failure.
3333

34-
.. c:function:: int PyUnstable_WritePerfMapEntry(const void *code_addr, unsigned int code_size, const char *entry_name)
34+
.. c:function:: int PyUnstable_WritePerfMapEntry(const void *code_addr, size_t code_size, const char *entry_name)
3535
3636
Write one single entry to the ``/tmp/perf-$pid.map`` file. This function is
3737
thread safe. Here is what an example entry looks like::

Doc/deprecations/pending-removal-in-3.20.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,8 @@ Pending removal in Python 3.20
3838
- :mod:`zlib`
3939

4040
(Contributed by Hugo van Kemenade and Stan Ulbrych in :gh:`76007`.)
41+
42+
* :mod:`ast`:
43+
44+
* Creating instances of abstract AST nodes (such as :class:`ast.AST`
45+
or :class:`!ast.expr`) is deprecated and will raise an error in Python 3.20.

Doc/faq/programming.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1924,7 +1924,7 @@ correctly using identity tests:
19241924

19251925
.. code-block:: python
19261926
1927-
_sentinel = object()
1927+
_sentinel = sentinel('_sentinel')
19281928
19291929
def pop(self, key, default=_sentinel):
19301930
if key in self:

Doc/howto/descriptor.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ a pure Python equivalent:
594594

595595
def object_getattribute(obj, name):
596596
"Emulate PyObject_GenericGetAttr() in Objects/object.c"
597-
null = object()
597+
null = sentinel('null')
598598
objtype = type(obj)
599599
cls_var = find_name_in_mro(objtype, name, null)
600600
descr_get = getattr(type(cls_var), '__get__', null)
@@ -1635,12 +1635,12 @@ by member descriptors:
16351635

16361636
.. testcode::
16371637

1638-
null = object()
1638+
null = sentinel('null')
16391639

16401640
class Member:
16411641

16421642
def __init__(self, name, clsname, offset):
1643-
'Emulate PyMemberDef in Include/structmember.h'
1643+
'Emulate PyMemberDef in Include/descrobject.h'
16441644
# Also see descr_new() in Objects/descrobject.c
16451645
self.name = name
16461646
self.clsname = clsname

Doc/howto/perf_profiling.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,9 @@ Example, using the :mod:`sys` APIs in file :file:`example.py`:
217217
How to obtain the best results
218218
------------------------------
219219

220-
For best results, Python should be compiled with
221-
``CFLAGS="-fno-omit-frame-pointer -mno-omit-leaf-frame-pointer"`` as this allows
220+
For best results, keep frame pointers enabled. On supported GCC-compatible
221+
toolchains, CPython builds itself with ``-fno-omit-frame-pointer`` and, when
222+
available, ``-mno-omit-leaf-frame-pointer`` by default. These flags allow
222223
profilers to unwind using only the frame pointer and not on DWARF debug
223224
information. This is because as the code that is interposed to allow ``perf``
224225
support is dynamically generated it doesn't have any DWARF debugging information

Doc/library/ast.rst

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Node classes
4242

4343
.. class:: AST
4444

45-
This is the base of all AST node classes. The actual node classes are
45+
This is the abstract base of all AST node classes. The actual node classes are
4646
derived from the :file:`Parser/Python.asdl` file, which is reproduced
4747
:ref:`above <abstract-grammar>`. They are defined in the :mod:`!_ast` C
4848
module and re-exported in :mod:`!ast`.
@@ -168,6 +168,15 @@ Node classes
168168
arguments that were set as attributes of the AST node, even if they did not
169169
match any of the fields of the AST node. These cases now raise a :exc:`TypeError`.
170170

171+
.. deprecated-removed:: next 3.20
172+
173+
In the :ref:`grammar above <abstract-grammar>`, the AST node classes that
174+
correspond to production rules with variants (aka "sums") are abstract
175+
classes. Previous versions of Python allowed for the creation of direct
176+
instances of these abstract node classes. This behavior is deprecated and
177+
will be removed in Python 3.20.
178+
179+
171180
.. note::
172181
The descriptions of the specific node classes displayed here
173182
were initially adapted from the fantastic `Green Tree
@@ -271,18 +280,25 @@ Root nodes
271280
Literals
272281
^^^^^^^^
273282

274-
.. class:: Constant(value)
283+
.. class:: Constant(value, kind)
275284

276285
A constant value. The ``value`` attribute of the ``Constant`` literal contains the
277286
Python object it represents. The values represented can be instances of :class:`str`,
278287
:class:`bytes`, :class:`int`, :class:`float`, :class:`complex`, and :class:`bool`,
279288
and the constants :data:`None` and :data:`Ellipsis`.
280289

290+
The ``kind`` attribute is an optional string. For string literals with a
291+
``u`` prefix, ``kind`` is set to ``'u'``. For all other
292+
constants, ``kind`` is ``None``.
293+
281294
.. doctest::
282295

283296
>>> print(ast.dump(ast.parse('123', mode='eval'), indent=4))
284297
Expression(
285298
body=Constant(value=123))
299+
>>> print(ast.dump(ast.parse("u'hello'", mode='eval'), indent=4))
300+
Expression(
301+
body=Constant(value='hello', kind='u'))
286302

287303

288304
.. class:: FormattedValue(value, conversion, format_spec)
@@ -2536,6 +2552,20 @@ and classes for traversing abstract syntax trees:
25362552
Added the *color* parameter.
25372553

25382554

2555+
.. function:: compare(a, b, /, *, compare_attributes=False)
2556+
2557+
Recursively compares two ASTs.
2558+
2559+
*compare_attributes* affects whether AST attributes are considered
2560+
in the comparison. If *compare_attributes* is ``False`` (default), then
2561+
attributes are ignored. Otherwise they must all be equal. This
2562+
option is useful to check whether the ASTs are structurally equal but
2563+
differ in whitespace or similar details. Attributes include line numbers
2564+
and column offsets.
2565+
2566+
.. versionadded:: 3.14
2567+
2568+
25392569
.. _ast-compiler-flags:
25402570

25412571
Compiler flags
@@ -2571,20 +2601,6 @@ effects on the compilation of a program:
25712601
.. versionadded:: 3.8
25722602

25732603

2574-
.. function:: compare(a, b, /, *, compare_attributes=False)
2575-
2576-
Recursively compares two ASTs.
2577-
2578-
*compare_attributes* affects whether AST attributes are considered
2579-
in the comparison. If *compare_attributes* is ``False`` (default), then
2580-
attributes are ignored. Otherwise they must all be equal. This
2581-
option is useful to check whether the ASTs are structurally equal but
2582-
differ in whitespace or similar details. Attributes include line numbers
2583-
and column offsets.
2584-
2585-
.. versionadded:: 3.14
2586-
2587-
25882604
.. _ast-cli:
25892605

25902606
Command-line usage

Doc/library/compression.zstd.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,14 @@ Compressing and decompressing data in memory
331331

332332
If *max_length* is non-negative, the method returns at most *max_length*
333333
bytes of decompressed data. If this limit is reached and further
334-
output can be produced, the :attr:`~.needs_input` attribute will
335-
be set to ``False``. In this case, the next call to
334+
output can be produced (or EOF is reached), the :attr:`~.needs_input`
335+
attribute will be set to ``False``. In this case, the next call to
336336
:meth:`~.decompress` may provide *data* as ``b''`` to obtain
337-
more of the output.
337+
more of the output. The full content can thus be read like::
338+
339+
process_output(d.decompress(data, max_length))
340+
while not d.eof and not d.needs_input:
341+
process_output(d.decompress(b"", max_length))
338342

339343
If all of the input data was decompressed and returned (either
340344
because this was less than *max_length* bytes, or because

Doc/library/email.policy.rst

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,11 +403,26 @@ added matters. To illustrate::
403403
.. attribute:: utf8
404404

405405
If ``False``, follow :rfc:`5322`, supporting non-ASCII characters in
406-
headers by encoding them as "encoded words". If ``True``, follow
407-
:rfc:`6532` and use ``utf-8`` encoding for headers. Messages
406+
headers by encoding them as :rfc:`2047` "encoded words". If ``True``,
407+
follow :rfc:`6532` and use ``utf-8`` encoding for headers. Messages
408408
formatted in this way may be passed to SMTP servers that support
409409
the ``SMTPUTF8`` extension (:rfc:`6531`).
410410

411+
When ``False``, the generator will raise
412+
:exc:`~email.errors.HeaderWriteError` if any header includes non-ASCII
413+
characters in a context where :rfc:`2047` does not permit encoded words.
414+
This particularly applies to mailboxes ("addr-spec") with non-ASCII
415+
characters, which can be created via
416+
:class:`~email.headerregistry.Address`. To use a mailbox with a non-ASCII
417+
domain name with ``utf8=False``, first encode the domain using the
418+
third-party :pypi:`idna` or :pypi:`uts46` module or with
419+
:mod:`encodings.idna`. It is not possible to use a non-ASCII username
420+
("local-part") in a mailbox when ``utf8=False``.
421+
422+
.. versionchanged:: 3.15
423+
Can trigger the raising of :exc:`~email.errors.HeaderWriteError`.
424+
(Earlier versions incorrectly applied :rfc:`2047` in certain contexts,
425+
mostly notably in addr-specs.)
411426

412427
.. attribute:: refold_source
413428

Doc/library/statistics.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ However, for reading convenience, most of the examples show sorted sequences.
713713

714714
.. function:: covariance(x, y, /)
715715

716-
Return the sample covariance of two inputs *x* and *y*. Covariance
716+
Return the sample covariance of two sequence inputs *x* and *y*. Covariance
717717
is a measure of the joint variability of two inputs.
718718

719719
Both inputs must be of the same length (no less than two), otherwise
@@ -739,7 +739,7 @@ However, for reading convenience, most of the examples show sorted sequences.
739739

740740
Return the `Pearson's correlation coefficient
741741
<https://en.wikipedia.org/wiki/Pearson_correlation_coefficient>`_
742-
for two inputs. Pearson's correlation coefficient *r* takes values
742+
for two sequence inputs. Pearson's correlation coefficient *r* takes values
743743
between -1 and +1. It measures the strength and direction of a linear
744744
relationship.
745745

@@ -802,7 +802,7 @@ However, for reading convenience, most of the examples show sorted sequences.
802802
(it is equal to the difference between predicted and actual values
803803
of the dependent variable).
804804

805-
Both inputs must be of the same length (no less than two), and
805+
Both inputs must be sequences of the same length (no less than two), and
806806
the independent variable *x* cannot be constant;
807807
otherwise a :exc:`StatisticsError` is raised.
808808

0 commit comments

Comments
 (0)