Skip to content

Commit

Permalink
Merge branch 'main' into remove-arg
Browse files Browse the repository at this point in the history
  • Loading branch information
Eclips4 authored Jan 19, 2025
2 parents 26f7a0d + 6c52ada commit e7bc9bc
Show file tree
Hide file tree
Showing 123 changed files with 3,373 additions and 1,468 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,14 @@ jobs:
name: >-
Ubuntu
${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }}
${{ fromJSON(matrix.bolt) && '(bolt)' || '' }}
needs: check_source
if: needs.check_source.outputs.run_tests == 'true'
strategy:
matrix:
bolt:
- false
- true
free-threading:
- false
- true
Expand All @@ -246,9 +250,16 @@ jobs:
exclude:
- os: ubuntu-24.04-aarch64
is-fork: true
# Do not test BOLT with free-threading, to conserve resources
- bolt: true
free-threading: true
# BOLT currently crashes during instrumentation on aarch64
- os: ubuntu-24.04-aarch64
bolt: true
uses: ./.github/workflows/reusable-ubuntu.yml
with:
config_hash: ${{ needs.check_source.outputs.config_hash }}
bolt-optimizations: ${{ matrix.bolt }}
free-threading: ${{ matrix.free-threading }}
os: ${{ matrix.os }}

Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/reusable-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ on:
config_hash:
required: true
type: string
bolt-optimizations:
description: Whether to enable BOLT optimizations
required: false
type: boolean
default: false
free-threading:
description: Whether to use free-threaded mode
required: false
Expand Down Expand Up @@ -34,6 +39,12 @@ jobs:
run: echo "::add-matcher::.github/problem-matchers/gcc.json"
- name: Install dependencies
run: sudo ./.github/workflows/posix-deps-apt.sh
- name: Install Clang and BOLT
if: ${{ fromJSON(inputs.bolt-optimizations) }}
run: |
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh 19
sudo apt-get install bolt-19
echo PATH="$(llvm-config-19 --bindir):$PATH" >> $GITHUB_ENV
- name: Configure OpenSSL env vars
run: |
echo "MULTISSL_DIR=${GITHUB_WORKSPACE}/multissl" >> "$GITHUB_ENV"
Expand Down Expand Up @@ -73,14 +84,18 @@ jobs:
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ inputs.config_hash }}
- name: Configure CPython out-of-tree
working-directory: ${{ env.CPYTHON_BUILDDIR }}
# `test_unpickle_module_race` writes to the source directory, which is
# read-only during builds — so we exclude it from profiling with BOLT.
run: >-
PROFILE_TASK='-m test --pgo --ignore test_unpickle_module_race'
../cpython-ro-srcdir/configure
--config-cache
--with-pydebug
--enable-slower-safety
--enable-safety
--with-openssl="$OPENSSL_DIR"
${{ fromJSON(inputs.free-threading) && '--disable-gil' || '' }}
${{ fromJSON(inputs.bolt-optimizations) && '--enable-bolt' || '' }}
- name: Build CPython out-of-tree
if: ${{ inputs.free-threading }}
working-directory: ${{ env.CPYTHON_BUILDDIR }}
Expand Down
10 changes: 4 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.2
rev: v0.9.1
hooks:
- id: ruff
name: Run Ruff (lint) on Doc/
Expand Down Expand Up @@ -29,12 +29,10 @@ repos:
- id: black
name: Run Black on Tools/build/check_warnings.py
files: ^Tools/build/check_warnings.py
language_version: python3.12
args: [--line-length=79]
- id: black
name: Run Black on Tools/jit/
files: ^Tools/jit/
language_version: python3.12

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
Expand All @@ -51,19 +49,19 @@ repos:
types_or: [c, inc, python, rst]

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.30.0
rev: 0.31.0
hooks:
- id: check-dependabot
- id: check-github-workflows
- id: check-readthedocs

- repo: https://github.com/rhysd/actionlint
rev: v1.7.4
rev: v1.7.6
hooks:
- id: actionlint

- repo: https://github.com/woodruffw/zizmor-pre-commit
rev: v0.8.0
rev: v1.1.1
hooks:
- id: zizmor

Expand Down
34 changes: 18 additions & 16 deletions Doc/faq/programming.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1906,28 +1906,30 @@ In the standard library code, you will see several common patterns for
correctly using identity tests:

1) As recommended by :pep:`8`, an identity test is the preferred way to check
for ``None``. This reads like plain English in code and avoids confusion with
other objects that may have boolean values that evaluate to false.
for ``None``. This reads like plain English in code and avoids confusion
with other objects that may have boolean values that evaluate to false.

2) Detecting optional arguments can be tricky when ``None`` is a valid input
value. In those situations, you can create a singleton sentinel object
guaranteed to be distinct from other objects. For example, here is how
to implement a method that behaves like :meth:`dict.pop`::
value. In those situations, you can create a singleton sentinel object
guaranteed to be distinct from other objects. For example, here is how
to implement a method that behaves like :meth:`dict.pop`:

_sentinel = object()
.. code-block:: python
def pop(self, key, default=_sentinel):
if key in self:
value = self[key]
del self[key]
return value
if default is _sentinel:
raise KeyError(key)
return default
_sentinel = object()
def pop(self, key, default=_sentinel):
if key in self:
value = self[key]
del self[key]
return value
if default is _sentinel:
raise KeyError(key)
return default
3) Container implementations sometimes need to augment equality tests with
identity tests. This prevents the code from being confused by objects such as
``float('NaN')`` that are not equal to themselves.
identity tests. This prevents the code from being confused by objects
such as ``float('NaN')`` that are not equal to themselves.

For example, here is the implementation of
:meth:`!collections.abc.Sequence.__contains__`::
Expand Down
4 changes: 2 additions & 2 deletions Doc/glossary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Glossary
:keyword:`yield` expression.

Each :keyword:`yield` temporarily suspends processing, remembering the
location execution state (including local variables and pending
execution state (including local variables and pending
try-statements). When the *asynchronous generator iterator* effectively
resumes with another awaitable returned by :meth:`~object.__anext__`, it
picks up where it left off. See :pep:`492` and :pep:`525`.
Expand Down Expand Up @@ -564,7 +564,7 @@ Glossary
An object created by a :term:`generator` function.

Each :keyword:`yield` temporarily suspends processing, remembering the
location execution state (including local variables and pending
execution state (including local variables and pending
try-statements). When the *generator iterator* resumes, it picks up where
it left off (in contrast to functions which start fresh on every
invocation).
Expand Down
8 changes: 7 additions & 1 deletion Doc/library/email.contentmanager.rst
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,13 @@ Currently the email package provides only one concrete content manager,
:exc:`ValueError`.

* For ``str`` objects, if *cte* is not set use heuristics to
determine the most compact encoding.
determine the most compact encoding. Prior to encoding,
:meth:`str.splitlines` is used to normalize all line boundaries,
ensuring that each line of the payload is terminated by the
current policy's :data:`~email.policy.Policy.linesep` property
(even if the original string did not end with one).
* For ``bytes`` objects, *cte* is taken to be base64 if not set,
and the aforementioned newline translation is not performed.
* For :class:`~email.message.EmailMessage`, per :rfc:`2046`, raise
an error if a *cte* of ``quoted-printable`` or ``base64`` is
requested for *subtype* ``rfc822``, and for any *cte* other than
Expand Down
4 changes: 3 additions & 1 deletion Doc/library/importlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -380,13 +380,15 @@ ABC hierarchy::

.. class:: ResourceLoader

*Superseded by TraversableResources*

An abstract base class for a :term:`loader` which implements the optional
:pep:`302` protocol for loading arbitrary resources from the storage
back-end.

.. deprecated:: 3.7
This ABC is deprecated in favour of supporting resource loading
through :class:`importlib.resources.abc.ResourceReader`.
through :class:`importlib.resources.abc.TraversableResources`.

.. abstractmethod:: get_data(path)

Expand Down
4 changes: 3 additions & 1 deletion Doc/library/os.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5411,6 +5411,8 @@ information, consult your Unix manpages.
The following scheduling policies are exposed if they are supported by the
operating system.

.. _os-scheduling-policy:

.. data:: SCHED_OTHER

The default scheduling policy.
Expand Down Expand Up @@ -5514,7 +5516,7 @@ operating system.

.. function:: sched_yield()

Voluntarily relinquish the CPU.
Voluntarily relinquish the CPU. See :manpage:`sched_yield(2)` for details.


.. function:: sched_setaffinity(pid, mask, /)
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/sys.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

This module provides access to some variables used or maintained by the
interpreter and to functions that interact strongly with the interpreter. It is
always available.
always available. Unless explicitly noted otherwise, all variables are read-only.


.. data:: abiflags
Expand Down
11 changes: 10 additions & 1 deletion Doc/library/time.rst
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,8 @@ Functions
The suspension time may be longer than requested by an arbitrary amount,
because of the scheduling of other activity in the system.

.. rubric:: Windows implementation

On Windows, if *secs* is zero, the thread relinquishes the remainder of its
time slice to any other thread that is ready to run. If there are no other
threads ready to run, the function returns immediately, and the thread
Expand All @@ -393,12 +395,19 @@ Functions
<https://learn.microsoft.com/windows-hardware/drivers/kernel/high-resolution-timers>`_
which provides resolution of 100 nanoseconds. If *secs* is zero, ``Sleep(0)`` is used.

Unix implementation:
.. rubric:: Unix implementation

* Use ``clock_nanosleep()`` if available (resolution: 1 nanosecond);
* Or use ``nanosleep()`` if available (resolution: 1 nanosecond);
* Or use ``select()`` (resolution: 1 microsecond).

.. note::

To emulate a "no-op", use :keyword:`pass` instead of ``time.sleep(0)``.

To voluntarily relinquish the CPU, specify a real-time :ref:`scheduling
policy <os-scheduling-policy>` and use :func:`os.sched_yield` instead.

.. audit-event:: time.sleep secs

.. versionchanged:: 3.5
Expand Down
Loading

0 comments on commit e7bc9bc

Please sign in to comment.