Skip to content

Commit

Permalink
Merge branch 'main' into pythongh-110820
Browse files Browse the repository at this point in the history
  • Loading branch information
ned-deily committed Dec 7, 2023
2 parents 494a6e2 + cf6110b commit 3b8134a
Show file tree
Hide file tree
Showing 108 changed files with 5,619 additions and 1,139 deletions.
4 changes: 4 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,7 @@ Doc/howto/clinic.rst @erlend-aasland

# WebAssembly
/Tools/wasm/ @brettcannon

# SBOM
/Misc/sbom.spdx.json @sethmlarson
/Tools/build/generate_sbom.py @sethmlarson
2 changes: 2 additions & 0 deletions .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
paths:
- ".github/workflows/mypy.yml"
- "Lib/test/libregrtest/**"
- "Tools/build/generate_sbom.py"
- "Tools/cases_generator/**"
- "Tools/clinic/**"
- "Tools/peg_generator/**"
Expand All @@ -34,6 +35,7 @@ jobs:
matrix:
target: [
"Lib/test/libregrtest",
"Tools/build/",
"Tools/cases_generator",
"Tools/clinic",
"Tools/peg_generator",
Expand Down
4 changes: 2 additions & 2 deletions Doc/c-api/function.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ There are a few functions specific to Python functions.
The function's docstring and name are retrieved from the code object. *__module__*
is retrieved from *globals*. The argument defaults, annotations and closure are
set to ``NULL``. *__qualname__* is set to the same value as the code object's
``co_qualname`` field.
:attr:`~codeobject.co_qualname` field.
.. c:function:: PyObject* PyFunction_NewWithQualName(PyObject *code, PyObject *globals, PyObject *qualname)
As :c:func:`PyFunction_New`, but also allows setting the function object's
``__qualname__`` attribute. *qualname* should be a unicode object or ``NULL``;
if ``NULL``, the ``__qualname__`` attribute is set to the same value as the
code object's ``co_qualname`` field.
code object's :attr:`~codeobject.co_qualname` field.
.. versionadded:: 3.3
Expand Down
10 changes: 10 additions & 0 deletions Doc/c-api/hash.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,13 @@ See also the :c:member:`PyTypeObject.tp_hash` member.
:pep:`456` "Secure and interchangeable hash algorithm".
.. versionadded:: 3.4
.. c:function:: Py_hash_t Py_HashPointer(const void *ptr)
Hash a pointer value: process the pointer value as an integer (cast it to
``uintptr_t`` internally). The pointer is not dereferenced.
The function cannot fail: it cannot return ``-1``.
.. versionadded:: 3.13
2 changes: 1 addition & 1 deletion Doc/c-api/import.rst
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ Importing Modules
:class:`~importlib.machinery.SourceFileLoader` otherwise.
The module's :attr:`__file__` attribute will be set to the code object's
:attr:`!co_filename`. If applicable, :attr:`__cached__` will also
:attr:`~codeobject.co_filename`. If applicable, :attr:`__cached__` will also
be set.
This function will reload the module if it was already imported. See
Expand Down
19 changes: 10 additions & 9 deletions Doc/library/dis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,9 @@ operation is being performed, so the intermediate analysis object isn't useful:
Line numbers can be decreasing. Before, they were always increasing.

.. versionchanged:: 3.10
The :pep:`626` ``co_lines`` method is used instead of the ``co_firstlineno``
and ``co_lnotab`` attributes of the code object.
The :pep:`626` ``co_lines`` method is used instead of the
:attr:`~codeobject.co_firstlineno` and :attr:`~codeobject.co_lnotab`
attributes of the code object.

.. versionchanged:: 3.13
Line numbers can be ``None`` for bytecode that does not map to source lines.
Expand Down Expand Up @@ -983,13 +984,13 @@ iterations of the loop.
.. opcode:: STORE_NAME (namei)

Implements ``name = STACK.pop()``. *namei* is the index of *name* in the attribute
:attr:`!co_names` of the :ref:`code object <code-objects>`.
:attr:`~codeobject.co_names` of the :ref:`code object <code-objects>`.
The compiler tries to use :opcode:`STORE_FAST` or :opcode:`STORE_GLOBAL` if possible.


.. opcode:: DELETE_NAME (namei)

Implements ``del name``, where *namei* is the index into :attr:`!co_names`
Implements ``del name``, where *namei* is the index into :attr:`~codeobject.co_names`
attribute of the :ref:`code object <code-objects>`.


Expand Down Expand Up @@ -1029,7 +1030,7 @@ iterations of the loop.
value = STACK.pop()
obj.name = value

where *namei* is the index of name in :attr:`!co_names` of the
where *namei* is the index of name in :attr:`~codeobject.co_names` of the
:ref:`code object <code-objects>`.

.. opcode:: DELETE_ATTR (namei)
Expand All @@ -1039,7 +1040,7 @@ iterations of the loop.
obj = STACK.pop()
del obj.name

where *namei* is the index of name into :attr:`!co_names` of the
where *namei* is the index of name into :attr:`~codeobject.co_names` of the
:ref:`code object <code-objects>`.


Expand Down Expand Up @@ -1402,7 +1403,7 @@ iterations of the loop.
Pushes a reference to the object the cell contains on the stack.

.. versionchanged:: 3.11
``i`` is no longer offset by the length of ``co_varnames``.
``i`` is no longer offset by the length of :attr:`~codeobject.co_varnames`.


.. opcode:: LOAD_FROM_DICT_OR_DEREF (i)
Expand All @@ -1424,7 +1425,7 @@ iterations of the loop.
storage.

.. versionchanged:: 3.11
``i`` is no longer offset by the length of ``co_varnames``.
``i`` is no longer offset by the length of :attr:`~codeobject.co_varnames`.


.. opcode:: DELETE_DEREF (i)
Expand All @@ -1435,7 +1436,7 @@ iterations of the loop.
.. versionadded:: 3.2

.. versionchanged:: 3.11
``i`` is no longer offset by the length of ``co_varnames``.
``i`` is no longer offset by the length of :attr:`~codeobject.co_varnames`.


.. opcode:: COPY_FREE_VARS (n)
Expand Down
4 changes: 2 additions & 2 deletions Doc/library/inspect.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1596,8 +1596,8 @@ updated as expected:
Code Objects Bit Flags
----------------------

Python code objects have a ``co_flags`` attribute, which is a bitmap of
the following flags:
Python code objects have a :attr:`~codeobject.co_flags` attribute,
which is a bitmap of the following flags:

.. data:: CO_OPTIMIZED

Expand Down
19 changes: 18 additions & 1 deletion Doc/library/pdb.rst
Original file line number Diff line number Diff line change
Expand Up @@ -570,10 +570,27 @@ can be overridden by the local file.

Start an interactive interpreter (using the :mod:`code` module) whose global
namespace contains all the (global and local) names found in the current
scope.
scope. Use ``exit()`` or ``quit()`` to exit the interpreter and return to
the debugger.

.. note::

Because interact creates a new global namespace with the current global
and local namespace for execution, assignment to variables will not
affect the original namespaces.
However, modification to the mutable objects will be reflected in the
original namespaces.

.. versionadded:: 3.2

.. versionadded:: 3.13
``exit()`` and ``quit()`` can be used to exit :pdbcmd:`interact`
command.

.. versionchanged:: 3.13
:pdbcmd:`interact` directs its output to the debugger's
output channel rather than :data:`sys.stderr`.

.. _debugger-aliases:

.. pdbcommand:: alias [name [command]]
Expand Down
52 changes: 30 additions & 22 deletions Doc/library/reprlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

--------------

The :mod:`reprlib` module provides a means for producing object representations
The :mod:`!reprlib` module provides a means for producing object representations
with limits on the size of the resulting strings. This is used in the Python
debugger and may be useful in other contexts as well.

Expand Down Expand Up @@ -58,29 +58,31 @@ This module provides a class, an instance, and a function:
limits on most sizes.

In addition to size-limiting tools, the module also provides a decorator for
detecting recursive calls to :meth:`__repr__` and substituting a placeholder
string instead.
detecting recursive calls to :meth:`~object.__repr__` and substituting a
placeholder string instead.


.. index:: single: ...; placeholder

.. decorator:: recursive_repr(fillvalue="...")

Decorator for :meth:`__repr__` methods to detect recursive calls within the
Decorator for :meth:`~object.__repr__` methods to detect recursive calls within the
same thread. If a recursive call is made, the *fillvalue* is returned,
otherwise, the usual :meth:`__repr__` call is made. For example:

>>> from reprlib import recursive_repr
>>> class MyList(list):
... @recursive_repr()
... def __repr__(self):
... return '<' + '|'.join(map(repr, self)) + '>'
...
>>> m = MyList('abc')
>>> m.append(m)
>>> m.append('x')
>>> print(m)
<'a'|'b'|'c'|...|'x'>
otherwise, the usual :meth:`!__repr__` call is made. For example:

.. doctest::

>>> from reprlib import recursive_repr
>>> class MyList(list):
... @recursive_repr()
... def __repr__(self):
... return '<' + '|'.join(map(repr, self)) + '>'
...
>>> m = MyList('abc')
>>> m.append(m)
>>> m.append('x')
>>> print(m)
<'a'|'b'|'c'|...|'x'>

.. versionadded:: 3.2

Expand Down Expand Up @@ -148,10 +150,10 @@ which format specific object types.
with no line breaks or indentation, like the standard :func:`repr`.
For example:

.. code-block:: pycon
.. doctest:: indent

>>> example = [
1, 'spam', {'a': 2, 'b': 'spam eggs', 'c': {3: 4.5, 6: []}}, 'ham']
... 1, 'spam', {'a': 2, 'b': 'spam eggs', 'c': {3: 4.5, 6: []}}, 'ham']
>>> import reprlib
>>> aRepr = reprlib.Repr()
>>> print(aRepr.repr(example))
Expand All @@ -160,7 +162,7 @@ which format specific object types.
If :attr:`~Repr.indent` is set to a string, each recursion level
is placed on its own line, indented by that string:

.. code-block:: pycon
.. doctest:: indent

>>> aRepr.indent = '-->'
>>> print(aRepr.repr(example))
Expand All @@ -181,7 +183,7 @@ which format specific object types.
Setting :attr:`~Repr.indent` to a positive integer value behaves as if it
was set to a string with that number of spaces:

.. code-block:: pycon
.. doctest:: indent

>>> aRepr.indent = 4
>>> print(aRepr.repr(example))
Expand Down Expand Up @@ -234,7 +236,9 @@ Subclassing Repr Objects
The use of dynamic dispatching by :meth:`Repr.repr1` allows subclasses of
:class:`Repr` to add support for additional built-in object types or to modify
the handling of types already supported. This example shows how special support
for file objects could be added::
for file objects could be added:

.. testcode::

import reprlib
import sys
Expand All @@ -248,3 +252,7 @@ for file objects could be added::

aRepr = MyRepr()
print(aRepr.repr(sys.stdin)) # prints '<stdin>'

.. testoutput::

<stdin>
Loading

0 comments on commit 3b8134a

Please sign in to comment.