Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into instr_ptr
Browse files Browse the repository at this point in the history
  • Loading branch information
iritkatriel committed Oct 12, 2023
2 parents 86cf45f + 7dd3c2b commit 19da0c0
Show file tree
Hide file tree
Showing 116 changed files with 6,290 additions and 5,504 deletions.
24 changes: 0 additions & 24 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,6 @@ repos:
- id: trailing-whitespace
types_or: [c, inc, python, rst]

- repo: local
hooks:
- id: python-file-whitespace
name: "Check Python file whitespace"
entry: 'python Tools/patchcheck/reindent.py --nobackup --newline LF'
language: 'system'
types: [python]
exclude: '^(Lib/test/tokenizedata/|Tools/c-analyzer/cpython/_parser).*$'

- repo: local
hooks:
- id: c-file-whitespace
name: "Check C file whitespace"
entry: "python Tools/patchcheck/untabify.py"
language: "system"
types_or: ['c', 'c++']
# Don't check the style of vendored libraries
exclude: |
(?x)^(
Modules/_decimal/.*
| Modules/libmpdec/.*
| Modules/expat/.*
)$
- repo: https://github.com/sphinx-contrib/sphinx-lint
rev: v0.6.8
hooks:
Expand Down
24 changes: 12 additions & 12 deletions Doc/c-api/memory.rst
Original file line number Diff line number Diff line change
Expand Up @@ -491,18 +491,18 @@ Customize Memory Allocators
:c:func:`PyMem_SetAllocator` does have the following contract:
* It can be called after :c:func:`Py_PreInitialize` and before
:c:func:`Py_InitializeFromConfig` to install a custom memory
allocator. There are no restrictions over the installed allocator
other than the ones imposed by the domain (for instance, the Raw
Domain allows the allocator to be called without the GIL held). See
:ref:`the section on allocator domains <allocator-domains>` for more
information.
* If called after Python has finish initializing (after
:c:func:`Py_InitializeFromConfig` has been called) the allocator
**must** wrap the existing allocator. Substituting the current
allocator for some other arbitrary one is **not supported**.
* It can be called after :c:func:`Py_PreInitialize` and before
:c:func:`Py_InitializeFromConfig` to install a custom memory
allocator. There are no restrictions over the installed allocator
other than the ones imposed by the domain (for instance, the Raw
Domain allows the allocator to be called without the GIL held). See
:ref:`the section on allocator domains <allocator-domains>` for more
information.
* If called after Python has finish initializing (after
:c:func:`Py_InitializeFromConfig` has been called) the allocator
**must** wrap the existing allocator. Substituting the current
allocator for some other arbitrary one is **not supported**.
.. versionchanged:: 3.12
All allocators must be thread-safe.
Expand Down
15 changes: 8 additions & 7 deletions Doc/howto/enum.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1156,13 +1156,14 @@ the following are true:
There is a new boundary mechanism that controls how out-of-range / invalid
bits are handled: ``STRICT``, ``CONFORM``, ``EJECT``, and ``KEEP``:

* STRICT --> raises an exception when presented with invalid values
* CONFORM --> discards any invalid bits
* EJECT --> lose Flag status and become a normal int with the given value
* KEEP --> keep the extra bits
- keeps Flag status and extra bits
- extra bits do not show up in iteration
- extra bits do show up in repr() and str()
* STRICT --> raises an exception when presented with invalid values
* CONFORM --> discards any invalid bits
* EJECT --> lose Flag status and become a normal int with the given value
* KEEP --> keep the extra bits

- keeps Flag status and extra bits
- extra bits do not show up in iteration
- extra bits do show up in repr() and str()

The default for Flag is ``STRICT``, the default for ``IntFlag`` is ``EJECT``,
and the default for ``_convert_`` is ``KEEP`` (see ``ssl.Options`` for an
Expand Down
14 changes: 6 additions & 8 deletions Doc/howto/instrumentation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ DTrace and SystemTap are monitoring tools, each providing a way to inspect
what the processes on a computer system are doing. They both use
domain-specific languages allowing a user to write scripts which:

- filter which processes are to be observed
- gather data from the processes of interest
- generate reports on the data
- filter which processes are to be observed
- gather data from the processes of interest
- generate reports on the data

As of Python 3.6, CPython can be built with embedded "markers", also
known as "probes", that can be observed by a DTrace or SystemTap script,
Expand Down Expand Up @@ -246,11 +246,9 @@ The output looks like this:
where the columns are:

- time in microseconds since start of script

- name of executable

- PID of process
- time in microseconds since start of script
- name of executable
- PID of process

and the remainder indicates the call/return hierarchy as the script executes.

Expand Down
46 changes: 23 additions & 23 deletions Doc/library/__main__.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,45 +54,45 @@ The top-level code environment can be:

* the scope of an interactive prompt::

>>> __name__
'__main__'
>>> __name__
'__main__'

* the Python module passed to the Python interpreter as a file argument:

.. code-block:: shell-session
.. code-block:: shell-session
$ python helloworld.py
Hello, world!
$ python helloworld.py
Hello, world!
* the Python module or package passed to the Python interpreter with the
:option:`-m` argument:

.. code-block:: shell-session
.. code-block:: shell-session
$ python -m tarfile
usage: tarfile.py [-h] [-v] (...)
$ python -m tarfile
usage: tarfile.py [-h] [-v] (...)
* Python code read by the Python interpreter from standard input:

.. code-block:: shell-session
.. code-block:: shell-session
$ echo "import this" | python
The Zen of Python, by Tim Peters
$ echo "import this" | python
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
...
Beautiful is better than ugly.
Explicit is better than implicit.
...
* Python code passed to the Python interpreter with the :option:`-c` argument:

.. code-block:: shell-session
.. code-block:: shell-session
$ python -c "import this"
The Zen of Python, by Tim Peters
$ python -c "import this"
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
...
Beautiful is better than ugly.
Explicit is better than implicit.
...
In each of these situations, the top-level module's ``__name__`` is set to
``'__main__'``.
Expand All @@ -102,9 +102,9 @@ top-level environment by checking its own ``__name__``, which allows a common
idiom for conditionally executing code when the module is not initialized from
an import statement::

if __name__ == '__main__':
# Execute when the module is not initialized from an import statement.
...
if __name__ == '__main__':
# Execute when the module is not initialized from an import statement.
...

.. seealso::

Expand Down
2 changes: 1 addition & 1 deletion Doc/library/_thread.rst
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ In addition to these methods, lock objects can also be used via the

**Caveats:**

.. index:: pair: module; signal
.. index:: pair: module; signal

* Threads interact strangely with interrupts: the :exc:`KeyboardInterrupt`
exception will be received by an arbitrary thread. (When the :mod:`signal`
Expand Down
9 changes: 5 additions & 4 deletions Doc/library/binascii.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,11 @@ The :mod:`binascii` module defines the following functions:
data will raise :exc:`binascii.Error`.

Valid base64:
* Conforms to :rfc:`3548`.
* Contains only characters from the base64 alphabet.
* Contains no excess data after padding (including excess padding, newlines, etc.).
* Does not start with a padding.

* Conforms to :rfc:`3548`.
* Contains only characters from the base64 alphabet.
* Contains no excess data after padding (including excess padding, newlines, etc.).
* Does not start with a padding.

.. versionchanged:: 3.11
Added the *strict_mode* parameter.
Expand Down
78 changes: 39 additions & 39 deletions Doc/library/collections.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,26 +120,26 @@ The class can be used to simulate nested scopes and is useful in templating.

.. seealso::

* The `MultiContext class
<https://github.com/enthought/codetools/blob/4.0.0/codetools/contexts/multi_context.py>`_
in the Enthought `CodeTools package
<https://github.com/enthought/codetools>`_ has options to support
writing to any mapping in the chain.
* The `MultiContext class
<https://github.com/enthought/codetools/blob/4.0.0/codetools/contexts/multi_context.py>`_
in the Enthought `CodeTools package
<https://github.com/enthought/codetools>`_ has options to support
writing to any mapping in the chain.

* Django's `Context class
<https://github.com/django/django/blob/main/django/template/context.py>`_
for templating is a read-only chain of mappings. It also features
pushing and popping of contexts similar to the
:meth:`~collections.ChainMap.new_child` method and the
:attr:`~collections.ChainMap.parents` property.
* Django's `Context class
<https://github.com/django/django/blob/main/django/template/context.py>`_
for templating is a read-only chain of mappings. It also features
pushing and popping of contexts similar to the
:meth:`~collections.ChainMap.new_child` method and the
:attr:`~collections.ChainMap.parents` property.

* The `Nested Contexts recipe
<https://code.activestate.com/recipes/577434/>`_ has options to control
whether writes and other mutations apply only to the first mapping or to
any mapping in the chain.
* The `Nested Contexts recipe
<https://code.activestate.com/recipes/577434/>`_ has options to control
whether writes and other mutations apply only to the first mapping or to
any mapping in the chain.

* A `greatly simplified read-only version of Chainmap
<https://code.activestate.com/recipes/305268/>`_.
* A `greatly simplified read-only version of Chainmap
<https://code.activestate.com/recipes/305268/>`_.


:class:`ChainMap` Examples and Recipes
Expand Down Expand Up @@ -429,22 +429,22 @@ or subtracting from an empty counter.

.. seealso::

* `Bag class <https://www.gnu.org/software/smalltalk/manual-base/html_node/Bag.html>`_
in Smalltalk.
* `Bag class <https://www.gnu.org/software/smalltalk/manual-base/html_node/Bag.html>`_
in Smalltalk.

* Wikipedia entry for `Multisets <https://en.wikipedia.org/wiki/Multiset>`_.
* Wikipedia entry for `Multisets <https://en.wikipedia.org/wiki/Multiset>`_.

* `C++ multisets <http://www.java2s.com/Tutorial/Cpp/0380__set-multiset/Catalog0380__set-multiset.htm>`_
tutorial with examples.
* `C++ multisets <http://www.java2s.com/Tutorial/Cpp/0380__set-multiset/Catalog0380__set-multiset.htm>`_
tutorial with examples.

* For mathematical operations on multisets and their use cases, see
*Knuth, Donald. The Art of Computer Programming Volume II,
Section 4.6.3, Exercise 19*.
* For mathematical operations on multisets and their use cases, see
*Knuth, Donald. The Art of Computer Programming Volume II,
Section 4.6.3, Exercise 19*.

* To enumerate all distinct multisets of a given size over a given set of
elements, see :func:`itertools.combinations_with_replacement`::
* To enumerate all distinct multisets of a given size over a given set of
elements, see :func:`itertools.combinations_with_replacement`::

map(Counter, combinations_with_replacement('ABC', 2)) # --> AA AB AC BB BC CC
map(Counter, combinations_with_replacement('ABC', 2)) # --> AA AB AC BB BC CC


:class:`deque` objects
Expand Down Expand Up @@ -1062,20 +1062,20 @@ fields:

.. seealso::

* See :class:`typing.NamedTuple` for a way to add type hints for named
tuples. It also provides an elegant notation using the :keyword:`class`
keyword::
* See :class:`typing.NamedTuple` for a way to add type hints for named
tuples. It also provides an elegant notation using the :keyword:`class`
keyword::

class Component(NamedTuple):
part_number: int
weight: float
description: Optional[str] = None
class Component(NamedTuple):
part_number: int
weight: float
description: Optional[str] = None

* See :meth:`types.SimpleNamespace` for a mutable namespace based on an
underlying dictionary instead of a tuple.
* See :meth:`types.SimpleNamespace` for a mutable namespace based on an
underlying dictionary instead of a tuple.

* The :mod:`dataclasses` module provides a decorator and functions for
automatically adding generated special methods to user-defined classes.
* The :mod:`dataclasses` module provides a decorator and functions for
automatically adding generated special methods to user-defined classes.


:class:`OrderedDict` objects
Expand Down
Loading

0 comments on commit 19da0c0

Please sign in to comment.