Skip to content

Commit f3beb18

Browse files
committed
Merge remote-tracking branch 'upstream/main' into nested-async-comp
2 parents 08f657d + 0ee0a74 commit f3beb18

36 files changed

+629
-189
lines changed

.github/workflows/doc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
- name: 'Build documentation'
4141
run: xvfb-run make -C Doc/ PYTHON=../python SPHINXOPTS="-q -W --keep-going -j4" doctest html
4242
- name: 'Upload'
43-
uses: actions/[email protected].3
43+
uses: actions/[email protected].4
4444
with:
4545
name: doc-html
4646
path: Doc/build/html

Doc/c-api/code.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,11 @@ bound into a function.
5959
6060
For efficiently iterating over the line numbers in a code object, use `the API described in PEP 626
6161
<https://www.python.org/dev/peps/pep-0626/#out-of-process-debuggers-and-profilers>`_.
62+
63+
.. c:function:: int PyCode_Addr2Location(PyObject *co, int byte_offset, int *start_line, int *start_column, int *end_line, int *end_column)
64+
65+
Sets the passed ``int`` pointers to the source code line and column numbers
66+
for the instruction at ``byte_offset``. Sets the value to ``0`` when
67+
information is not available for any particular element.
68+
69+
Returns ``1`` if the function succeeds and 0 otherwise.

Doc/library/argparse.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,8 @@ is available in ``argparse`` and adds support for boolean actions such as
853853
>>> parser.parse_args(['--no-foo'])
854854
Namespace(foo=False)
855855

856+
.. versionadded:: 3.9
857+
856858
The recommended way to create a custom action is to extend :class:`Action`,
857859
overriding the ``__call__`` method and optionally the ``__init__`` and
858860
``format_usage`` methods.

Doc/library/bz2.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,3 +325,8 @@ Writing and reading a bzip2-compressed file in binary mode:
325325
... content = f.read()
326326
>>> content == data # Check equality to original object after round-trip
327327
True
328+
329+
.. testcleanup::
330+
331+
import os
332+
os.remove("myfile.bz2")

Doc/library/configparser.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ can be customized by end users easily.
4646

4747
import configparser
4848

49+
.. testcleanup::
50+
51+
import os
52+
os.remove("example.ini")
53+
4954

5055
Quick Start
5156
-----------

Doc/library/importlib.metadata.rst

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,11 @@
88
:synopsis: The implementation of the importlib metadata.
99

1010
.. versionadded:: 3.8
11+
.. versionchanged:: 3.10
12+
``importlib.metadata`` is no longer provisional.
1113

1214
**Source code:** :source:`Lib/importlib/metadata.py`
1315

14-
.. note::
15-
This functionality is provisional and may deviate from the usual
16-
version semantics of the standard library.
17-
1816
``importlib.metadata`` is a library that provides for access to installed
1917
package metadata. Built in part on Python's import system, this library
2018
intends to replace similar functionality in the `entry point

Doc/library/io.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,9 @@ I/O Base Classes
391391
to control the number of lines read: no more lines will be read if the
392392
total size (in bytes/characters) of all lines so far exceeds *hint*.
393393

394+
*hint* values of ``0`` or less, as well as ``None``, are treated as no
395+
hint.
396+
394397
Note that it's already possible to iterate on file objects using ``for
395398
line in file: ...`` without calling ``file.readlines()``.
396399

Doc/library/os.path.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,14 @@ the :mod:`glob` module.)
340340
that contains symbolic links. On Windows, it converts forward slashes to
341341
backward slashes. To normalize case, use :func:`normcase`.
342342

343+
.. note::
344+
On POSIX systems, in accordance with `IEEE Std 1003.1 2013 Edition; 4.13
345+
Pathname Resolution <http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13>`_,
346+
if a pathname begins with exactly two slashes, the first component
347+
following the leading characters may be interpreted in an implementation-defined
348+
manner, although more than two leading characters shall be treated as a
349+
single character.
350+
343351
.. versionchanged:: 3.6
344352
Accepts a :term:`path-like object`.
345353

Doc/library/traceback.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ The output for the example would look similar to this:
473473
['Traceback (most recent call last):\n',
474474
' File "<doctest default[0]>", line 10, in <module>\n lumberjack()\n ^^^^^^^^^^^^\n',
475475
' File "<doctest default[0]>", line 4, in lumberjack\n bright_side_of_death()\n ^^^^^^^^^^^^^^^^^^^^^^\n',
476-
' File "<doctest default[0]>", line 7, in bright_side_of_death\n return tuple()[0]\n ^^^^^^^^^^\n',
476+
' File "<doctest default[0]>", line 7, in bright_side_of_death\n return tuple()[0]\n ~~~~~~~^^^\n',
477477
'IndexError: tuple index out of range\n']
478478
*** extract_tb:
479479
[<FrameSummary file <doctest...>, line 10 in <module>>,
@@ -482,7 +482,7 @@ The output for the example would look similar to this:
482482
*** format_tb:
483483
[' File "<doctest default[0]>", line 10, in <module>\n lumberjack()\n ^^^^^^^^^^^^\n',
484484
' File "<doctest default[0]>", line 4, in lumberjack\n bright_side_of_death()\n ^^^^^^^^^^^^^^^^^^^^^^\n',
485-
' File "<doctest default[0]>", line 7, in bright_side_of_death\n return tuple()[0]\n ^^^^^^^^^^\n']
485+
' File "<doctest default[0]>", line 7, in bright_side_of_death\n return tuple()[0]\n ~~~~~~~^^^\n']
486486
*** tb_lineno: 10
487487

488488

Doc/reference/datamodel.rst

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,6 +1015,39 @@ Internal types
10151015
If a code object represents a function, the first item in :attr:`co_consts` is
10161016
the documentation string of the function, or ``None`` if undefined.
10171017

1018+
.. method:: codeobject.co_positions()
1019+
1020+
Returns an iterable over the source code positions of each bytecode
1021+
instruction in the code object.
1022+
1023+
The iterator returns tuples containing the ``(start_line, end_line,
1024+
start_column, end_column)``. The *i-th* tuple corresponds to the
1025+
position of the source code that compiled to the *i-th* instruction.
1026+
Column information is 0-indexed utf-8 byte offsets on the given source
1027+
line.
1028+
1029+
This positional information can be missing. A non-exhaustive lists of
1030+
cases where this may happen:
1031+
1032+
- Running the interpreter with :option:`-X` ``no_debug_ranges``.
1033+
- Loading a pyc file compiled while using :option:`-X` ``no_debug_ranges``.
1034+
- Position tuples corresponding to artificial instructions.
1035+
- Line and column numbers that can't be represented due to
1036+
implementation specific limitations.
1037+
1038+
When this occurs, some or all of the tuple elements can be
1039+
:const:`None`.
1040+
1041+
.. versionadded:: 3.11
1042+
1043+
.. note::
1044+
This feature requires storing column positions in code objects which may
1045+
result in a small increase of disk usage of compiled Python files or
1046+
interpreter memory usage. To avoid storing the extra information and/or
1047+
deactivate printing the extra traceback information, the
1048+
:option:`-X` ``no_debug_ranges`` command line flag or the :envvar:`PYTHONNODEBUGRANGES`
1049+
environment variable can be used.
1050+
10181051
.. _frame-objects:
10191052

10201053
Frame objects

0 commit comments

Comments
 (0)