Skip to content

Commit 60ad88d

Browse files
Merge branch 'main' into fix-slot-wrapper-inheritance-tests
2 parents 700fb9e + c086962 commit 60ad88d

File tree

74 files changed

+1776
-1254
lines changed

Some content is hidden

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

74 files changed

+1776
-1254
lines changed

.github/workflows/build.yml

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -249,27 +249,38 @@ jobs:
249249
arch: ${{ matrix.arch }}
250250

251251
build_macos:
252-
name: 'macOS'
253-
needs: check_source
254-
if: needs.check_source.outputs.run_tests == 'true'
255-
uses: ./.github/workflows/reusable-macos.yml
256-
with:
257-
config_hash: ${{ needs.check_source.outputs.config_hash }}
258-
# Cirrus and macos-14 are M1, macos-13 is default GHA Intel.
259-
# Cirrus used for upstream, macos-14 for forks.
260-
os-matrix: '["ghcr.io/cirruslabs/macos-runner:sonoma", "macos-14", "macos-13"]'
261-
262-
build_macos_free_threading:
263-
name: 'macOS (free-threading)'
252+
name: >-
253+
macOS
254+
${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }}
264255
needs: check_source
265256
if: needs.check_source.outputs.run_tests == 'true'
257+
strategy:
258+
fail-fast: false
259+
matrix:
260+
# Cirrus and macos-14 are M1, macos-13 is default GHA Intel.
261+
# macOS 13 only runs tests against the GIL-enabled CPython.
262+
# Cirrus used for upstream, macos-14 for forks.
263+
os:
264+
- ghcr.io/cirruslabs/macos-runner:sonoma
265+
- macos-14
266+
- macos-13
267+
is-fork: # only used for the exclusion trick
268+
- ${{ github.repository_owner != 'python' }}
269+
free-threading:
270+
- false
271+
- true
272+
exclude:
273+
- os: ghcr.io/cirruslabs/macos-runner:sonoma
274+
is-fork: true
275+
- os: macos-14
276+
is-fork: false
277+
- os: macos-13
278+
free-threading: true
266279
uses: ./.github/workflows/reusable-macos.yml
267280
with:
268281
config_hash: ${{ needs.check_source.outputs.config_hash }}
269-
free-threading: true
270-
# Cirrus and macos-14 are M1.
271-
# Cirrus used for upstream, macos-14 for forks.
272-
os-matrix: '["ghcr.io/cirruslabs/macos-runner:sonoma", "macos-14"]'
282+
free-threading: ${{ matrix.free-threading }}
283+
os: ${{ matrix.os }}
273284

274285
build_ubuntu:
275286
name: >-
@@ -596,7 +607,6 @@ jobs:
596607
- check-docs
597608
- check_generated_files
598609
- build_macos
599-
- build_macos_free_threading
600610
- build_ubuntu
601611
- build_ubuntu_ssltests
602612
- build_wasi
@@ -632,7 +642,6 @@ jobs:
632642
&& '
633643
check_generated_files,
634644
build_macos,
635-
build_macos_free_threading,
636645
build_ubuntu,
637646
build_ubuntu_ssltests,
638647
build_wasi,

.github/workflows/reusable-macos.yml

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ on:
88
required: false
99
type: boolean
1010
default: false
11-
os-matrix:
12-
required: false
11+
os:
12+
description: OS to run the job
13+
required: true
1314
type: string
1415

1516
jobs:
1617
build_macos:
17-
name: build and test (${{ matrix.os }})
18+
name: build and test (${{ inputs.os }})
1819
timeout-minutes: 60
1920
env:
2021
HOMEBREW_NO_ANALYTICS: 1
@@ -23,18 +24,7 @@ jobs:
2324
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
2425
PYTHONSTRICTEXTENSIONBUILD: 1
2526
TERM: linux
26-
strategy:
27-
fail-fast: false
28-
matrix:
29-
os: ${{fromJson(inputs.os-matrix)}}
30-
is-fork:
31-
- ${{ github.repository_owner != 'python' }}
32-
exclude:
33-
- os: "ghcr.io/cirruslabs/macos-runner:sonoma"
34-
is-fork: true
35-
- os: "macos-14"
36-
is-fork: false
37-
runs-on: ${{ matrix.os }}
27+
runs-on: ${{ inputs.os }}
3828
steps:
3929
- uses: actions/checkout@v4
4030
- name: Runner image version
@@ -43,7 +33,7 @@ jobs:
4333
uses: actions/cache@v4
4434
with:
4535
path: config.cache
46-
key: ${{ github.job }}-${{ matrix.os }}-${{ env.IMAGE_VERSION }}-${{ inputs.config_hash }}
36+
key: ${{ github.job }}-${{ inputs.os }}-${{ env.IMAGE_VERSION }}-${{ inputs.config_hash }}
4737
- name: Install Homebrew dependencies
4838
run: brew install pkg-config [email protected] xz gdbm tcl-tk
4939
- name: Configure CPython

Doc/bugs.rst

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,16 @@ Documentation bugs
1616
==================
1717

1818
If you find a bug in this documentation or would like to propose an improvement,
19-
please submit a bug report on the :ref:`tracker <using-the-tracker>`. If you
19+
please submit a bug report on the :ref:`issue tracker <using-the-tracker>`. If you
2020
have a suggestion on how to fix it, include that as well.
2121

2222
You can also open a discussion item on our
2323
`Documentation Discourse forum <https://discuss.python.org/c/documentation/26>`_.
2424

2525
If you find a bug in the theme (HTML / CSS / JavaScript) of the
26-
documentation, please submit a bug report on the `python-doc-theme bug
26+
documentation, please submit a bug report on the `python-doc-theme issue
2727
tracker <https://github.com/python/python-docs-theme>`_.
2828

29-
If you're short on time, you can also email documentation bug reports to
30-
[email protected] (behavioral bugs can be sent to [email protected]).
31-
'docs@' is a mailing list run by volunteers; your request will be noticed,
32-
though it may take a while to be processed.
33-
3429
.. seealso::
3530

3631
`Documentation bugs`_

Doc/library/ast.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,9 @@ Literals
316316
args=[
317317
Name(id='a', ctx=Load())]),
318318
conversion=-1,
319-
format_spec=Constant(value='.3'))]))
319+
format_spec=JoinedStr(
320+
values=[
321+
Constant(value='.3')]))]))
320322

321323

322324
.. class:: List(elts, ctx)

Doc/library/dis.rst

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,15 +1109,6 @@ iterations of the loop.
11091109
empty dictionary pre-sized to hold *count* items.
11101110

11111111

1112-
.. opcode:: BUILD_CONST_KEY_MAP (count)
1113-
1114-
The version of :opcode:`BUILD_MAP` specialized for constant keys. Pops the
1115-
top element on the stack which contains a tuple of keys, then starting from
1116-
``STACK[-2]``, pops *count* values to form values in the built dictionary.
1117-
1118-
.. versionadded:: 3.6
1119-
1120-
11211112
.. opcode:: BUILD_STRING (count)
11221113

11231114
Concatenates *count* strings from the stack and pushes the resulting string

Doc/library/mimetypes.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,3 +295,13 @@ than one MIME-type database; it provides an interface similar to the one of the
295295
types, else to the list of non-standard types.
296296

297297
.. versionadded:: 3.2
298+
299+
300+
.. method:: MimeTypes.add_type(type, ext, strict=True)
301+
302+
Add a mapping from the MIME type *type* to the extension *ext*. When the
303+
extension is already known, the new type will replace the old one. When the type
304+
is already known the extension will be added to the list of known extensions.
305+
306+
When *strict* is ``True`` (the default), the mapping will be added to the
307+
official MIME types, otherwise to the non-standard ones.

Doc/library/shutil.rst

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -706,11 +706,9 @@ provided. They rely on the :mod:`zipfile` and :mod:`tarfile` modules.
706706

707707
The keyword-only *filter* argument is passed to the underlying unpacking
708708
function. For zip files, *filter* is not accepted.
709-
For tar files, it is recommended to set it to ``'data'``,
710-
unless using features specific to tar and UNIX-like filesystems.
709+
For tar files, it is recommended to use ``'data'`` (default since Python
710+
3.14), unless using features specific to tar and UNIX-like filesystems.
711711
(See :ref:`tarfile-extraction-filter` for details.)
712-
The ``'data'`` filter will become the default for tar files
713-
in Python 3.14.
714712

715713
.. audit-event:: shutil.unpack_archive filename,extract_dir,format shutil.unpack_archive
716714

@@ -721,6 +719,12 @@ provided. They rely on the :mod:`zipfile` and :mod:`tarfile` modules.
721719
the *extract_dir* argument, e.g. members that have absolute filenames
722720
starting with "/" or filenames with two dots "..".
723721

722+
Since Python 3.14, the defaults for both built-in formats (zip and tar
723+
files) will prevent the most dangerous of such security issues,
724+
but will not prevent *all* unintended behavior.
725+
Read the :ref:`tarfile-further-verification`
726+
section for tar-specific details.
727+
724728
.. versionchanged:: 3.7
725729
Accepts a :term:`path-like object` for *filename* and *extract_dir*.
726730

Doc/library/sys.monitoring.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,10 @@ To allow tools to monitor for real exceptions without slowing down generators
226226
and coroutines, the :monitoring-event:`STOP_ITERATION` event is provided.
227227
:monitoring-event:`STOP_ITERATION` can be locally disabled, unlike :monitoring-event:`RAISE`.
228228

229+
Note that the :monitoring-event:`STOP_ITERATION` event and the :monitoring-event:`RAISE`
230+
event for a :exc:`StopIteration` exception are equivalent, and are treated as interchangeable
231+
when generating events. Implementations will favor :monitoring-event:`STOP_ITERATION` for
232+
performance reasons, but may generate a :monitoring-event:`RAISE` event with a :exc:`StopIteration`.
229233

230234
Turning events on and off
231235
-------------------------

Doc/library/tarfile.rst

Lines changed: 47 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,12 @@ Some facts and figures:
4040
Archives are extracted using a :ref:`filter <tarfile-extraction-filter>`,
4141
which makes it possible to either limit surprising/dangerous features,
4242
or to acknowledge that they are expected and the archive is fully trusted.
43-
By default, archives are fully trusted, but this default is deprecated
44-
and slated to change in Python 3.14.
4543

44+
.. versionchanged:: 3.14
45+
Set the default extraction filter to :func:`data <data_filter>`,
46+
which disallows some dangerous features such as links to absolute paths
47+
or paths outside of the destination. Previously, the filter strategy
48+
was equivalent to :func:`fully_trusted <fully_trusted_filter>`.
4649

4750
.. function:: open(name=None, mode='r', fileobj=None, bufsize=10240, **kwargs)
4851

@@ -495,18 +498,18 @@ be finalized; only the internally used file object will be closed. See the
495498
The *filter* argument specifies how ``members`` are modified or rejected
496499
before extraction.
497500
See :ref:`tarfile-extraction-filter` for details.
498-
It is recommended to set this explicitly depending on which *tar* features
499-
you need to support.
501+
It is recommended to set this explicitly only if specific *tar* features
502+
are required, or as ``filter='data'`` to support Python versions with a less
503+
secure default (3.13 and lower).
500504

501505
.. warning::
502506

503507
Never extract archives from untrusted sources without prior inspection.
504-
It is possible that files are created outside of *path*, e.g. members
505-
that have absolute filenames starting with ``"/"`` or filenames with two
506-
dots ``".."``.
507508

508-
Set ``filter='data'`` to prevent the most dangerous security issues,
509-
and read the :ref:`tarfile-extraction-filter` section for details.
509+
Since Python 3.14, the default (:func:`data <data_filter>`) will prevent
510+
the most dangerous security issues.
511+
However, it will not prevent *all* unintended or insecure behavior.
512+
Read the :ref:`tarfile-extraction-filter` section for details.
510513

511514
.. versionchanged:: 3.5
512515
Added the *numeric_owner* parameter.
@@ -517,6 +520,9 @@ be finalized; only the internally used file object will be closed. See the
517520
.. versionchanged:: 3.12
518521
Added the *filter* parameter.
519522

523+
.. versionchanged:: 3.14
524+
The *filter* parameter now defaults to ``'data'``.
525+
520526

521527
.. method:: TarFile.extract(member, path="", set_attrs=True, *, numeric_owner=False, filter=None)
522528

@@ -536,10 +542,8 @@ be finalized; only the internally used file object will be closed. See the
536542

537543
.. warning::
538544

539-
See the warning for :meth:`extractall`.
540-
541-
Set ``filter='data'`` to prevent the most dangerous security issues,
542-
and read the :ref:`tarfile-extraction-filter` section for details.
545+
Never extract archives from untrusted sources without prior inspection.
546+
See the warning for :meth:`extractall` for details.
543547

544548
.. versionchanged:: 3.2
545549
Added the *set_attrs* parameter.
@@ -602,14 +606,8 @@ be finalized; only the internally used file object will be closed. See the
602606
String names are not allowed for this attribute, unlike the *filter*
603607
argument to :meth:`~TarFile.extract`.
604608

605-
If ``extraction_filter`` is ``None`` (the default),
606-
calling an extraction method without a *filter* argument will raise a
607-
``DeprecationWarning``,
608-
and fall back to the :func:`fully_trusted <fully_trusted_filter>` filter,
609-
whose dangerous behavior matches previous versions of Python.
610-
611-
In Python 3.14+, leaving ``extraction_filter=None`` will cause
612-
extraction methods to use the :func:`data <data_filter>` filter by default.
609+
If ``extraction_filter`` is ``None`` (the default), extraction methods
610+
will use the :func:`data <data_filter>` filter by default.
613611

614612
The attribute may be set on instances or overridden in subclasses.
615613
It also is possible to set it on the ``TarFile`` class itself to set a
@@ -619,6 +617,14 @@ be finalized; only the internally used file object will be closed. See the
619617
To set a global default this way, a filter function needs to be wrapped in
620618
:func:`staticmethod()` to prevent injection of a ``self`` argument.
621619

620+
.. versionchanged:: 3.14
621+
622+
The default filter is set to :func:`data <data_filter>`,
623+
which disallows some dangerous features such as links to absolute paths
624+
or paths outside of the destination.
625+
Previously, the default was equivalent to
626+
:func:`fully_trusted <fully_trusted_filter>`.
627+
622628
.. method:: TarFile.add(name, arcname=None, recursive=True, *, filter=None)
623629

624630
Add the file *name* to the archive. *name* may be any type of file
@@ -969,6 +975,12 @@ In most cases, the full functionality is not needed.
969975
Therefore, *tarfile* supports extraction filters: a mechanism to limit
970976
functionality, and thus mitigate some of the security issues.
971977

978+
.. warning::
979+
980+
None of the available filters blocks *all* dangerous archive features.
981+
Never extract archives from untrusted sources without prior inspection.
982+
See also :ref:`tarfile-further-verification`.
983+
972984
.. seealso::
973985

974986
:pep:`706`
@@ -992,12 +1004,13 @@ can be:
9921004

9931005
* ``None`` (default): Use :attr:`TarFile.extraction_filter`.
9941006

995-
If that is also ``None`` (the default), raise a ``DeprecationWarning``,
996-
and fall back to the ``'fully_trusted'`` filter, whose dangerous behavior
997-
matches previous versions of Python.
1007+
If that is also ``None`` (the default), the ``'data'`` filter will be used.
1008+
1009+
.. versionchanged:: 3.14
9981010

999-
In Python 3.14, the ``'data'`` filter will become the default instead.
1000-
It's possible to switch earlier; see :attr:`TarFile.extraction_filter`.
1011+
The default filter is set to :func:`data <data_filter>`.
1012+
Previously, the default was equivalent to
1013+
:func:`fully_trusted <fully_trusted_filter>`.
10011014

10021015
* A callable which will be called for each extracted member with a
10031016
:ref:`TarInfo <tarinfo-objects>` describing the member and the destination
@@ -1080,6 +1093,9 @@ reused in custom filters:
10801093

10811094
Return the modified ``TarInfo`` member.
10821095

1096+
Note that this filter does not block *all* dangerous archive features.
1097+
See :ref:`tarfile-further-verification` for details.
1098+
10831099

10841100
.. _tarfile-extraction-refuse:
10851101

@@ -1093,6 +1109,8 @@ With ``errorlevel=0`` the error will be logged and the member will be skipped,
10931109
but extraction will continue.
10941110

10951111

1112+
.. _tarfile-further-verification:
1113+
10961114
Hints for further verification
10971115
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10981116

@@ -1110,9 +1128,10 @@ Here is an incomplete list of things to consider:
11101128
disk, memory and CPU usage.
11111129
* Check filenames against an allow-list of characters
11121130
(to filter out control characters, confusables, foreign path separators,
1113-
etc.).
1131+
and so on).
11141132
* Check that filenames have expected extensions (discouraging files that
1115-
execute when you “click on them”, or extension-less files like Windows special device names).
1133+
execute when you “click on them”, or extension-less files like Windows
1134+
special device names).
11161135
* Limit the number of extracted files, total size of extracted data,
11171136
filename length (including symlink length), and size of individual files.
11181137
* Check for files that would be shadowed on case-insensitive filesystems.

0 commit comments

Comments
 (0)