Skip to content

Commit

Permalink
Catch up with main
Browse files Browse the repository at this point in the history
  • Loading branch information
brandtbucher committed Jan 3, 2024
2 parents 20ad5f5 + 1ae7ceb commit 3342775
Show file tree
Hide file tree
Showing 43 changed files with 342 additions and 273 deletions.
7 changes: 7 additions & 0 deletions Doc/data/refcounts.dat
Original file line number Diff line number Diff line change
Expand Up @@ -1589,6 +1589,13 @@ PyObject_Call:PyObject*:callable_object:0:
PyObject_Call:PyObject*:args:0:
PyObject_Call:PyObject*:kw:0:

PyObject_CallNoArgs:PyObject*::+1:
PyObject_CallNoArgs:PyObject*:callable_object:0:

PyObject_CallOneArg:PyObject*::+1:
PyObject_CallOneArg:PyObject*:callable_object:0:
PyObject_CallOneArg:PyObject*:arg:0:

PyObject_CallFunction:PyObject*::+1:
PyObject_CallFunction:PyObject*:callable_object:0:
PyObject_CallFunction:const char*:format::
Expand Down
9 changes: 5 additions & 4 deletions Doc/library/dis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -342,17 +342,18 @@ operation is being performed, so the intermediate analysis object isn't useful:

.. function:: findlinestarts(code)

This generator function uses the ``co_lines`` method
of the code object *code* to find the offsets which are starts of
This generator function uses the :meth:`~codeobject.co_lines` method
of the :ref:`code object <code-objects>` *code* to find the offsets which
are starts of
lines in the source code. They are generated as ``(offset, lineno)`` pairs.

.. versionchanged:: 3.6
Line numbers can be decreasing. Before, they were always increasing.

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

.. versionchanged:: 3.13
Line numbers can be ``None`` for bytecode that does not map to source lines.
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/functools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ have three read-only attributes:
called.

:class:`partial` objects are like :class:`function` objects in that they are
callable, weak referencable, and can have attributes. There are some important
callable, weak referenceable, and can have attributes. There are some important
differences. For instance, the :attr:`~definition.__name__` and :attr:`__doc__` attributes
are not created automatically. Also, :class:`partial` objects defined in
classes behave like static methods and do not transform into bound methods
Expand Down
39 changes: 37 additions & 2 deletions Doc/reference/datamodel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1219,8 +1219,8 @@ If a code object represents a function, the first item in
:attr:`~codeobject.co_consts` is
the documentation string of the function, or ``None`` if undefined.

The :meth:`!co_positions` method
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Methods on code objects
~~~~~~~~~~~~~~~~~~~~~~~

.. method:: codeobject.co_positions()

Expand Down Expand Up @@ -1255,6 +1255,41 @@ The :meth:`!co_positions` method
:option:`-X` ``no_debug_ranges`` command line flag or the :envvar:`PYTHONNODEBUGRANGES`
environment variable can be used.

.. method:: codeobject.co_lines()

Returns an iterator that yields information about successive ranges of
:term:`bytecode`\s. Each item yielded is a ``(start, end, lineno)``
:class:`tuple`:

* ``start`` (an :class:`int`) represents the offset (inclusive) of the start
of the :term:`bytecode` range
* ``end`` (an :class:`int`) represents the offset (inclusive) of the end of
the :term:`bytecode` range
* ``lineno`` is an :class:`int` representing the line number of the
:term:`bytecode` range, or ``None`` if the bytecodes in the given range
have no line number

The items yielded generated will have the following properties:

* The first range yielded will have a ``start`` of 0.
* The ``(start, end)`` ranges will be non-decreasing and consecutive. That
is, for any pair of :class:`tuple`\s, the ``start`` of the second will be
equal to the ``end`` of the first.
* No range will be backwards: ``end >= start`` for all triples.
* The :class:`tuple` yielded will have ``end`` equal to the size of the
:term:`bytecode`.

Zero-width ranges, where ``start == end``, are allowed. Zero-width ranges
are used for lines that are present in the source code, but have been
eliminated by the :term:`bytecode` compiler.

.. versionadded:: 3.10

.. seealso::

:pep:`626` - Precise line numbers for debugging and other tools.
The PEP that introduced the :meth:`!co_lines` method.


.. _frame-objects:

Expand Down
13 changes: 7 additions & 6 deletions Doc/tools/extensions/c_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ def add_annotations(self, app, doctree):
f"Object type mismatch in limited API annotation "
f"for {name}: {record['role']!r} != {objtype!r}")
stable_added = record['added']
message = sphinx_gettext(' Part of the ')
message = sphinx_gettext('Part of the')
message = message.center(len(message) + 2)
emph_node = nodes.emphasis(message, message,
classes=['stableabi'])
ref_node = addnodes.pending_xref(
Expand All @@ -139,27 +140,27 @@ def add_annotations(self, app, doctree):
ref_node += nodes.Text(sphinx_gettext('Stable ABI'))
emph_node += ref_node
if struct_abi_kind == 'opaque':
emph_node += nodes.Text(sphinx_gettext(' (as an opaque struct)'))
emph_node += nodes.Text(' ' + sphinx_gettext('(as an opaque struct)'))
elif struct_abi_kind == 'full-abi':
emph_node += nodes.Text(sphinx_gettext(' (including all members)'))
emph_node += nodes.Text(' ' + sphinx_gettext('(including all members)'))
if record['ifdef_note']:
emph_node += nodes.Text(' ' + record['ifdef_note'])
if stable_added == '3.2':
# Stable ABI was introduced in 3.2.
pass
else:
emph_node += nodes.Text(sphinx_gettext(' since version %s') % stable_added)
emph_node += nodes.Text(' ' + sphinx_gettext('since version %s') % stable_added)
emph_node += nodes.Text('.')
if struct_abi_kind == 'members':
emph_node += nodes.Text(
sphinx_gettext(' (Only some members are part of the stable ABI.)'))
' ' + sphinx_gettext('(Only some members are part of the stable ABI.)'))
node.insert(0, emph_node)

# Unstable API annotation.
if name.startswith('PyUnstable'):
warn_node = nodes.admonition(
classes=['unstable-c-api', 'warning'])
message = sphinx_gettext('This is ')
message = sphinx_gettext('This is') + ' '
emph_node = nodes.emphasis(message, message)
ref_node = addnodes.pending_xref(
'Unstable API', refdomain="std",
Expand Down
12 changes: 6 additions & 6 deletions Doc/tools/templates/dummy.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@

In extensions/c_annotations.py:

{% trans %} Part of the {% endtrans %}
{% trans %}Part of the{% endtrans %}
{% trans %}Limited API{% endtrans %}
{% trans %}Stable ABI{% endtrans %}
{% trans %} (as an opaque struct){% endtrans %}
{% trans %} (including all members){% endtrans %}
{% trans %} since version %s{% endtrans %}
{% trans %} (Only some members are part of the stable ABI.){% endtrans %}
{% trans %}This is {% endtrans %}
{% trans %}(as an opaque struct){% endtrans %}
{% trans %}(including all members){% endtrans %}
{% trans %}since version %s{% endtrans %}
{% trans %}(Only some members are part of the stable ABI.){% endtrans %}
{% trans %}This is{% endtrans %}
{% trans %}Unstable API{% endtrans %}
{% trans %}. It may change without warning in minor releases.{% endtrans %}
{% trans %}Return value: Always NULL.{% endtrans %}
Expand Down
2 changes: 1 addition & 1 deletion Doc/whatsnew/2.4.rst
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,7 @@ fixes. Here's a partial list of the most notable changes, sorted alphabetically
by module name. Consult the :file:`Misc/NEWS` file in the source tree for a more
complete list of changes, or look through the CVS logs for all the details.

* The :mod:`asyncore` module's :func:`loop` function now has a *count* parameter
* The :mod:`!asyncore` module's :func:`!loop` function now has a *count* parameter
that lets you perform a limited number of passes through the polling loop. The
default is still to loop forever.

Expand Down
2 changes: 1 addition & 1 deletion Doc/whatsnew/2.6.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1789,7 +1789,7 @@ changes, sorted alphabetically by module name. Consult the
:file:`Misc/NEWS` file in the source tree for a more complete list of
changes, or look through the Subversion logs for all the details.

* The :mod:`asyncore` and :mod:`asynchat` modules are
* The :mod:`!asyncore` and :mod:`!asynchat` modules are
being actively maintained again, and a number of patches and bugfixes
were applied. (Maintained by Josiah Carlson; see :issue:`1736190` for
one patch.)
Expand Down
12 changes: 7 additions & 5 deletions Doc/whatsnew/3.10.rst
Original file line number Diff line number Diff line change
Expand Up @@ -402,9 +402,11 @@ Tracing events, with the correct line number, are generated for all lines of cod
The :attr:`~frame.f_lineno` attribute of frame objects will always contain the
expected line number.
The :attr:`~codeobject.co_lnotab` attribute of code objects is deprecated and
The :attr:`~codeobject.co_lnotab` attribute of
:ref:`code objects <code-objects>` is deprecated and
will be removed in 3.12.
Code that needs to convert from offset to line number should use the new ``co_lines()`` method instead.
Code that needs to convert from offset to line number should use the new
:meth:`~codeobject.co_lines` method instead.
PEP 634: Structural Pattern Matching
------------------------------------
Expand Down Expand Up @@ -1278,7 +1280,7 @@ Add negative indexing support to :attr:`PurePath.parents
(Contributed by Yaroslav Pankovych in :issue:`21041`.)
Add :meth:`Path.hardlink_to <pathlib.Path.hardlink_to>` method that
supersedes :meth:`~pathlib.Path.link_to`. The new method has the same argument
supersedes :meth:`!link_to`. The new method has the same argument
order as :meth:`~pathlib.Path.symlink_to`.
(Contributed by Barney Gale in :issue:`39950`.)
Expand Down Expand Up @@ -1740,7 +1742,7 @@ Deprecated
(Contributed by Jelle Zijlstra in :gh:`87889`.)
* :meth:`pathlib.Path.link_to` is deprecated and slated for removal in
* :meth:`!pathlib.Path.link_to` is deprecated and slated for removal in
Python 3.12. Use :meth:`pathlib.Path.hardlink_to` instead.
(Contributed by Barney Gale in :issue:`39950`.)
Expand Down Expand Up @@ -1771,7 +1773,7 @@ Deprecated
* NPN features like :meth:`ssl.SSLSocket.selected_npn_protocol` and
:meth:`ssl.SSLContext.set_npn_protocols` are replaced by ALPN.
* The threading debug (:envvar:`PYTHONTHREADDEBUG` environment variable) is
* The threading debug (:envvar:`!PYTHONTHREADDEBUG` environment variable) is
deprecated in Python 3.10 and will be removed in Python 3.12. This feature
requires a :ref:`debug build of Python <debug-build>`.
(Contributed by Victor Stinner in :issue:`44584`.)
Expand Down
12 changes: 6 additions & 6 deletions Doc/whatsnew/3.11.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1747,7 +1747,7 @@ Modules
(Contributed by Brett Cannon in :issue:`47061` and Victor Stinner in
:gh:`68966`.)

* The :mod:`asynchat`, :mod:`asyncore` and :mod:`smtpd` modules have been
* The :mod:`!asynchat`, :mod:`!asyncore` and :mod:`!smtpd` modules have been
deprecated since at least Python 3.6. Their documentation and deprecation
warnings have now been updated to note they will be removed in Python 3.12.
(Contributed by Hugo van Kemenade in :issue:`47022`.)
Expand Down Expand Up @@ -1877,8 +1877,8 @@ and will be removed in Python 3.12.
C APIs pending removal are
:ref:`listed separately <whatsnew311-c-api-pending-removal>`.

* The :mod:`asynchat` module
* The :mod:`asyncore` module
* The :mod:`!asynchat` module
* The :mod:`!asyncore` module
* The :ref:`entire distutils package <distutils-deprecated>`
* The :mod:`!imp` module
* The :class:`typing.io <typing.IO>` namespace
Expand All @@ -1902,10 +1902,10 @@ C APIs pending removal are
* :func:`!importlib.util.set_package_wrapper`
* :class:`!pkgutil.ImpImporter`
* :class:`!pkgutil.ImpLoader`
* :meth:`pathlib.Path.link_to`
* :meth:`!pathlib.Path.link_to`
* :func:`!sqlite3.enable_shared_cache`
* :func:`!sqlite3.OptimizedUnicode`
* :envvar:`PYTHONTHREADDEBUG` environment variable
* :envvar:`!PYTHONTHREADDEBUG` environment variable
* The following deprecated aliases in :mod:`unittest`:

============================ =============================== ===============
Expand Down Expand Up @@ -2007,7 +2007,7 @@ Removed C APIs are :ref:`listed separately <whatsnew311-c-api-removed>`.
because it was not used and added by mistake in previous versions.
(Contributed by Nikita Sobolev in :issue:`46483`.)

* Removed the :class:`!MailmanProxy` class in the :mod:`smtpd` module,
* Removed the :class:`!MailmanProxy` class in the :mod:`!smtpd` module,
as it is unusable without the external :mod:`!mailman` package.
(Contributed by Donghee Na in :issue:`35800`.)

Expand Down
3 changes: 2 additions & 1 deletion Doc/whatsnew/3.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,8 @@ although there is currently no date scheduled for their removal.

* :mod:`!sre_compile`, :mod:`!sre_constants` and :mod:`!sre_parse` modules.

* :attr:`~codeobject.co_lnotab`: use the ``co_lines`` attribute instead.
* :attr:`codeobject.co_lnotab`: use the :meth:`codeobject.co_lines` method
instead.

* :class:`typing.Text` (:gh:`92332`).

Expand Down
12 changes: 6 additions & 6 deletions Doc/whatsnew/3.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1858,12 +1858,12 @@ structure.
asyncore
--------

:class:`asyncore.dispatcher` now provides a
:meth:`~asyncore.dispatcher.handle_accepted()` method
:class:`!asyncore.dispatcher` now provides a
:meth:`!handle_accepted()` method
returning a ``(sock, addr)`` pair which is called when a connection has actually
been established with a new remote endpoint. This is supposed to be used as a
replacement for old :meth:`~asyncore.dispatcher.handle_accept()` and avoids
the user to call :meth:`~asyncore.dispatcher.accept()` directly.
replacement for old :meth:`!handle_accept()` and avoids
the user to call :meth:`!accept()` directly.

(Contributed by Giampaolo Rodolà; :issue:`6706`.)

Expand Down Expand Up @@ -2737,8 +2737,8 @@ require changes to your code:
thread-state aware APIs (such as :c:func:`PyEval_SaveThread`
and :c:func:`PyEval_RestoreThread`) should be used instead.

* Due to security risks, :func:`asyncore.handle_accept` has been deprecated, and
a new function, :func:`asyncore.handle_accepted`, was added to replace it.
* Due to security risks, :func:`!asyncore.handle_accept` has been deprecated, and
a new function, :func:`!asyncore.handle_accepted`, was added to replace it.

(Contributed by Giampaolo Rodola in :issue:`6706`.)

Expand Down
2 changes: 1 addition & 1 deletion Doc/whatsnew/3.3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1845,7 +1845,7 @@ signal
smtpd
-----

The :mod:`smtpd` module now supports :rfc:`5321` (extended SMTP) and :rfc:`1870`
The :mod:`!smtpd` module now supports :rfc:`5321` (extended SMTP) and :rfc:`1870`
(size extension). Per the standard, these extensions are enabled if and only
if the client initiates the session with an ``EHLO`` command.

Expand Down
6 changes: 3 additions & 3 deletions Doc/whatsnew/3.4.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1369,9 +1369,9 @@ error. (Contributed by Atsuo Ishimoto and Hynek Schlawack in
smtpd
-----

The :class:`~smtpd.SMTPServer` and :class:`~smtpd.SMTPChannel` classes now
The :class:`!SMTPServer` and :class:`!SMTPChannel` classes now
accept a *map* keyword argument which, if specified, is passed in to
:class:`asynchat.async_chat` as its *map* argument. This allows an application
:class:`!asynchat.async_chat` as its *map* argument. This allows an application
to avoid affecting the global socket map. (Contributed by Vinay Sajip in
:issue:`11959`.)

Expand Down Expand Up @@ -2370,7 +2370,7 @@ Changes in the Python API
:issue:`18011`.) Note: this change was also inadvertently applied in Python
3.3.3.

* The :attr:`~cgi.FieldStorage.file` attribute is now automatically closed when
* The :attr:`!file` attribute is now automatically closed when
the creating :class:`!cgi.FieldStorage` instance is garbage collected. If you
were pulling the file object out separately from the :class:`!cgi.FieldStorage`
instance and not keeping the instance alive, then you should either store the
Expand Down
Loading

0 comments on commit 3342775

Please sign in to comment.