8000 Merge branch 'main' into add-macos-warnings-tracking-tooling · python/cpython@7780da6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7780da6

Browse files
committed
Merge branch 'main' into add-macos-warnings-tracking-tooling
2 parents b654a84 + a9344cd commit 7780da6

Some content is hidden

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

42 files changed

+781
-469
lines changed

.github/workflows/reusable-tsan.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ jobs:
3636
# Install clang-18
3737
wget https://apt.llvm.org/llvm.sh
3838
chmod +x llvm.sh
39-
sudo ./llvm.sh 18
40-
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-18 100
41-
sudo update-alternatives --set clang /usr/bin/clang-18
42-
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-18 100
43-
sudo update-alternatives --set clang++ /usr/bin/clang++-18
39+
sudo ./llvm.sh 17 # gh-121946: llvm-18 package is temporarily broken
40+
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-17 100
41+
sudo update-alternatives --set clang /usr/bin/clang-17
42+
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-17 100
43+
sudo update-alternatives --set clang++ /usr/bin/clang++-17
4444
# Reduce ASLR to avoid TSAN crashing
4545
sudo sysctl -w vm.mmap_rnd_bits=28
4646
- name: TSAN Option Setup

.github/workflows/reusable-ubuntu.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ jobs:
7575
${{ fromJSON(inputs.free-threading) && '--disable-gil' || '' }}
7676
- name: Build CPython out-of-tree
7777
working-directory: ${{ env.CPYTHON_BUILDDIR }}
78-
run: make -j4 &> compiler_output.txt
78+
run: set -o pipefail; make -j4 2>&1 | tee compiler_output.txt
7979
- name: Display build info
8080
working-directory: ${{ env.CPYTHON_BUILDDIR }}
8181
run: make pythoninfo

Android/android.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python3
22

33
import argparse
4+
from glob import glob
45
import os
56
import re
67
import shutil
@@ -16,16 +17,21 @@
1617
CROSS_BUILD_DIR = CHECKOUT / "cross-build"
1718

1819

19-
def delete_if_exists(path):
20-
if path.exists():
20+
def delete_glob(pattern):
21+
# Path.glob doesn't accept non-relative patterns.
22+
for path in glob(str(pattern)):
23+
path = Path(path)
2124
print(f"Deleting {path} ...")
22-
shutil.rmtree(path)
25+
if path.is_dir() and not path.is_symlink():
26+
shutil.rmtree(path)
27+
else:
28+
path.unlink()
2329

2430

2531
def subdir(name, *, clean=None):
2632
path = CROSS_BUILD_DIR / name
2733
if clean:
28-
delete_if_exists(path)
34+
delete_glob(path)
2935
if not path.exists():
3036
if clean is None:
3137
sys.exit(
@@ -150,10 +156,17 @@ def configure_host_python(context):
150156

151157

152158
def make_host_python(context):
159+
# The CFLAGS and LDFLAGS set in android-env include the prefix dir, so
160+
# delete any previously-installed Python libs and include files to prevent
161+
# them being used during the build.
153162
host_dir = subdir(context.host)
163+
prefix_dir = host_dir / "prefix"
164+
delete_glob(f"{prefix_dir}/include/python*")
165+
delete_glob(f"{prefix_dir}/lib/libpython*")
166+
154167
os.chdir(host_dir / "build")
155168
run(["make", "-j", str(os.cpu_count())], host=context.host)
156-
run(["make", "install", f"prefix={host_dir}/prefix"], host=context.host)
169+
run(["make", "install", f"prefix={prefix_dir}"], host=context.host)
157170

158171

159172
def build_all(context):
@@ -164,7 +177,7 @@ def build_all(context):
164177

165178

166179
def clean_all(context):
167-
delete_if_exists(CROSS_BUILD_DIR)
180+
delete_glob(CROSS_BUILD_DIR)
168181

169182

170183
# To avoid distributing compiled artifacts without corresponding source code,

Android/testbed/app/build.gradle.kts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,17 @@ plugins {
77

88
val PYTHON_DIR = File(projectDir, "../../..").canonicalPath
99
val PYTHON_CROSS_DIR = "$PYTHON_DIR/cross-build"
10+
1011
val ABIS = mapOf(
1112
"arm64-v8a" to "aarch64-linux-android",
1213
"x86_64" to "x86_64-linux-android",
13-
)
14+
).filter { File("$PYTHON_CROSS_DIR/${it.value}").exists() }
15+
if (ABIS.isEmpty()) {
16+
throw GradleException(
17+
"No Android ABIs found in $PYTHON_CROSS_DIR: see Android/README.md " +
18+
"for building instructions."
19+
)
20+
}
1421

1522
val PYTHON_VERSION = File("$PYTHON_DIR/Include/patchlevel.h").useLines {
1623
for (line in it) {

Doc/library/email.errors.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ The following exception classes are defined in the :mod:`email.errors` module:
5858
:class:`~email.mime.nonmultipart.MIMENonMultipart` (e.g.
5959
:class:`~email.mime.image.MIMEImage`).
6060

61+
62+
.. exception:: HeaderWriteError()
63+
64+
Raised when an error occurs when the :mod:`~email.generator` outputs
65+
headers.
66+
67+
6168
.. exception:: MessageDefect()
6269

6370
This is the base class for all defects found when parsing email messages.

Doc/library/email.policy.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,24 @@ added matters. To illustrate::
229229

230230
.. versionadded:: 3.6
231231

232+
233+
.. attribute:: verify_generated_headers
234+
235+
If ``True`` (the default), the generator will raise
236+
:exc:`~email.errors.HeaderWriteError` instead of writing a header
237+
that is improperly folded or delimited, such that it would
238+
be parsed as multiple headers or joined with adjacent data.
239+
Such headers can be generated by custom header classes or bugs
240+
in the ``email`` module.
241+
242+
As it's a security feature, this defaults to ``True`` even in the
243+
:class:`~email.policy.Compat32` policy.
244+
For backwards compatible, but unsafe, behavior, it must be set to
1241 245+
``False`` explicitly.
246+
247+
.. versionadded:: 3.13
248+
249+
232250
The following :class:`Policy` method is intended to be called by code using
233251
the email library to create policy instances with custom settings:
234252

Doc/library/subprocess.rst

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,41 +1561,26 @@ runtime):
15611561
Module which provides function to parse and escape command lines.
15621562

15631563

1564-
.. _disable_vfork:
15651564
.. _disable_posix_spawn:
15661565

1567-
Disabling use of ``vfork()`` or ``posix_spawn()``
1568-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1566+
Disable use of ``posix_spawn()``
1567+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
15691568

15701569
On Linux, :mod:`subprocess` defaults to using the ``vfork()`` system call
15711570
internally when it is safe to do so rather than ``fork()``. This greatly
15721571
improves performance.
15731572

1574-
If you ever encounter a presumed highly unusual situation where you need to
1575-
prevent ``vfork()`` from being used by Python, you can set the
1576-
:const:`subprocess._USE_VFORK` attribute to a false value.
1577-
1578-
::
1579-
1580-
subprocess._USE_VFORK = False # See CPython issue gh-NNNNNN.
1581-
1582-
Setting this has no impact on use of ``posix_spawn()`` which could use
1583-
``vfork()`` internally within its libc implementation. There is a similar
1584-
:const:`subprocess._USE_POSIX_SPAWN` attribute if you need to prevent use of
1585-
that.
1586-
15871573
::
15881574

15891575
subprocess._USE_POSIX_SPAWN = False # See CPython issue gh-NNNNNN.
15901576

1591-
It is safe to set these to false on any Python version. They will have no
1592-
effect on older versions when unsupported. Do not assume the attributes are
1593-
available to read. Despite their names, a true value does not indicate that the
1577+
It is safe to set this to false on any Python version. It will have no
1578+
effect on older or newer versions where unsupported. Do not assume the attribute
1579+
is available to read. Despite the name, a true value does not indicate the
15941580
corresponding function will be used, only that it may be.
15951581

15961582
Please file issues any time you have to use these private knobs with a way to
15971583
reproduce the issue you were seeing. Link to that issue from a comment in your
15981584
code.
15991585

16001586
.. versionadded:: 3.8 ``_USE_POSIX_SPAWN``
1601-
.. versionadded:: 3.11 ``_USE_VFORK``

Doc/reference/datamodel.rst

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -730,14 +730,7 @@ When an instance method object is derived from a :class:`classmethod` object, th
730730
itself, so that calling either ``x.f(1)`` or ``C.f(1)`` is equivalent to
731731
calling ``f(C,1)`` where ``f`` is the underlying function.
732732

733-
Note that the transformation from :ref:`function object <user-defined-funcs>`
734-
to instance method
735-
object happens each time the attribute is retrieved from the instance. In
736-
some cases, a fruitful optimization is to assign the attribute to a local
737-
variable and call that local variable. Also notice that this
738-
transformation only happens for user-defined functions; other callable
739-
objects (and all non-callable objects) are retrieved without
740-
transformation. It is also important to note that user-defined functions
733+
It is important to note that user-defined functions
741734
which are attributes of a class instance are not converted to bound
742735
methods; this *only* happens when the function is an attribute of the
743736
class.

Doc/whatsnew/3.13.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,15 @@ doctest
736736
email
737737
-----
738738

739+
* Headers with embedded newlines are now quoted on output.
740+
741+
The :mod:`~email.generator` will now refuse to serialize (write) headers
742+
that are improperly folded or delimited, such that they would be parsed as
743+
multiple headers or joined with adjacent data.
744+
If you need to turn this safety feature off,
745+
set :attr:`~email.policy.Policy.verify_generated_headers`.
746+
(Contributed by Bas Bloemsaat and Petr Viktorin in :gh:`121650`.)
747+
739748
* :func:`email.utils.getaddresses` and :func:`email.utils.parseaddr` now return
740749
``('', '')`` 2-tuples in more situations where invalid email addresses are
741750
encountered instead of potentially inaccurate values. Add optional *strict*

0 commit comments

Comments
 (0)
0