Skip to content

Commit 9c3ad31

Browse files
authored
Merge branch 'main' into scanfix-stringio-mphgx2fl
2 parents 8cfce4e + 2c24bc1 commit 9c3ad31

138 files changed

Lines changed: 3006 additions & 1048 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/reusable-emscripten.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,5 @@ jobs:
7979
run: python3 Platforms/emscripten run --test
8080
- name: "Test Repl"
8181
run: Platforms/emscripten/browser_test/run_test.sh
82+
- name: "Test embedding"
83+
run: Platforms/emscripten/web_embed_test/run_test.sh

‎.github/workflows/reusable-wasi.yml‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ jobs:
1616
timeout-minutes: 60
1717
env:
1818
WASMTIME_VERSION: 48.0.2
19-
CROSS_BUILD_WASI: cross-build/wasm32-wasip1
2019
steps:
2120
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
2221
with:
@@ -65,4 +64,6 @@ jobs:
6564
- name: "Display build info of the host/WASI Python"
6665
run: python3 Platforms/WASI pythoninfo-host
6766
- name: "Test"
68-
run: make --directory "${CROSS_BUILD_WASI}" test
67+
run: |
68+
CROSS_BUILD_WASI=$(python3 Platforms/WASI path)
69+
make --directory "${CROSS_BUILD_WASI}" test

‎Doc/README.rst‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ tree but are maintained separately and are available from
2121
* `Sphinx <https://pypi.org/project/Sphinx/>`_
2222
* `blurb <https://pypi.org/project/blurb/>`_
2323
* `python-docs-theme <https://pypi.org/project/python-docs-theme/>`_
24+
* `sphinx-linklint <https://pypi.org/project/sphinx-linklint/>`_
2425

2526
The easiest way to install these tools is to create a virtual environment and
2627
install the tools into there.
@@ -57,6 +58,8 @@ Available make targets are:
5758
* "venv", which creates a virtual environment with all necessary tools
5859
installed.
5960

61+
* "lock", which regenerates the pinned dependencies in ``pylock.toml``.
62+
6063
* "html", which builds standalone HTML files for offline viewing.
6164

6265
* "htmlview", which re-uses the "html" builder, but then opens the main page
@@ -79,6 +82,9 @@ Available make targets are:
7982

8083
* "text", which builds a plain text file for each source file.
8184

85+
* "texinfo", which builds Texinfo source files as input to ``makeinfo`` to
86+
produce Info documents.
87+
8288
* "epub", which builds an EPUB document, suitable to be viewed on e-book
8389
readers.
8490

@@ -97,6 +103,10 @@ Available make targets are:
97103
plain text documentation for the labels defined in
98104
``tools/pyspecific.py`` -- pydoc needs these to show topic and keyword help.
99105

106+
* "doctest", which runs doctests in the documentation.
107+
108+
* "gettext", which generates gettext message catalog templates.
109+
100110
* "check", which checks for frequent markup errors.
101111

102112
* "dist", (Unix only) which creates distributable archives of HTML, text,

‎Doc/library/argparse.rst‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,9 @@ how the command-line arguments should be handled. The supplied actions are:
789789
>>> parser.parse_args('--foo --bar'.split())
790790
Namespace(foo=True, bar=False, baz=True)
791791

792+
These defaults apply when the options are absent. They can be overridden
793+
by default_ or argument_default_.
794+
792795
* ``'append'`` - This appends each argument value to a list.
793796
It is useful for allowing an option to be specified multiple times.
794797
If the default value is a non-empty list, the parsed value for the option
@@ -1016,10 +1019,8 @@ default
10161019

10171020
All optional arguments and some positional arguments may be omitted at the
10181021
command line. The ``default`` keyword argument of
1019-
:meth:`~ArgumentParser.add_argument`, whose value defaults to ``None``,
1020-
specifies what value should be used if the command-line argument is not present.
1021-
For optional arguments, the ``default`` value is used when the option string
1022-
was not present at the command line::
1022+
:meth:`~ArgumentParser.add_argument` specifies what value should be used if the
1023+
command-line argument is not present. For example::
10231024

10241025
>>> parser = argparse.ArgumentParser()
10251026
>>> parser.add_argument('--foo', default=42)
@@ -1028,6 +1029,11 @@ was not present at the command line::
10281029
>>> parser.parse_args([])
10291030
Namespace(foo=42)
10301031

1032+
If ``default`` is omitted, :meth:`~ArgumentParser.add_argument` uses a value
1033+
previously set for the dest_ with :meth:`~ArgumentParser.set_defaults`, or
1034+
otherwise a non-``None`` argument_default_. If neither is set, the action's
1035+
own default is used.
1036+
10311037
If the target namespace already has an attribute set, the action *default*
10321038
will not overwrite it::
10331039

‎Doc/library/ctypes.rst‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,6 +1337,31 @@ write::
13371337
:class:`threading.local` will *not* survive across different callbacks, even when
13381338
those calls are made from the same C thread.
13391339

1340+
Callback functions can return structures and unions by value, in addition to
1341+
the simple types:
1342+
1343+
.. code-block:: python
1344+
1345+
class Point(Structure):
1346+
_fields_ = [("x", c_int), ("y", c_int)]
1347+
1348+
@CFUNCTYPE(Point)
1349+
def get_origin():
1350+
return Point(0, 0)
1351+
1352+
.. note::
1353+
1354+
A structure or union returned from a callback is copied *by value*, and
1355+
:mod:`!ctypes` does not keep the returned object alive after the callback
1356+
returns. If the structure contains a pointer field (such as
1357+
:class:`c_char_p` or a :func:`POINTER` type), you must ensure that the
1358+
memory it refers to stays valid for as long as the C code uses it -- the
1359+
same requirement C itself imposes. Returning a pointer to memory owned by
1360+
a temporary Python object will leave the C caller with a dangling pointer.
1361+
1362+
.. versionchanged:: next
1363+
Callback functions can now return structures and unions.
1364+
13401365
.. _ctypes-accessing-values-exported-from-dlls:
13411366

13421367
Accessing values exported from dlls

‎Doc/library/curses.rst‎

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,11 @@ Input options
274274

275275
Used for half-delay mode, which is similar to cbreak mode in that characters
276276
typed by the user are immediately available to the program. However, after
277-
blocking for *tenths* tenths of seconds, raise an exception if nothing has
278-
been typed. The value of *tenths* must be a number between ``1`` and ``255``. Use
279-
:func:`nocbreak` to leave half-delay mode.
277+
blocking for *tenths* tenths of seconds, if nothing has been typed,
278+
:meth:`~window.getch` returns ``-1``, while :meth:`~window.getkey` and
279+
:meth:`~window.get_wch` raise :exc:`curses.error`.
280+
The value of *tenths* must be a number between ``1`` and ``255``.
281+
Use :func:`nocbreak` to leave half-delay mode.
280282

281283
.. function:: meta(flag)
282284

@@ -893,8 +895,10 @@ Querying the terminal
893895

894896
.. function:: termname()
895897

896-
Return the value of the environment variable :envvar:`TERM`, as a bytes object,
897-
truncated to 14 characters.
898+
Return the name of the terminal in use, as a bytes object.
899+
This is the name passed to :func:`newterm` or
900+
:func:`setupterm`, or the value of the :envvar:`TERM` environment variable
901+
if none was given. Some curses libraries truncate it to 14 characters.
898902

899903
.. function:: longname()
900904

@@ -1227,7 +1231,8 @@ Adding and inserting text
12271231
Insert character *ch* with attributes *attr* before the character under the
12281232
cursor, or at ``(y, x)`` if specified. All characters to the right of the
12291233
cursor are shifted one position right, with the rightmost character on the
1230-
line being lost. The cursor position does not change.
1234+
line being lost.
1235+
The cursor position does not change (after moving to *y*, *x*, if specified).
12311236

12321237
.. versionchanged:: 3.16
12331238
Wide and combining characters, and :class:`complexchar` cells, are now
@@ -1251,8 +1256,8 @@ Adding and inserting text
12511256
window.insnstr(y, x, str, n[, attr])
12521257

12531258
Insert a character string (as many characters as will fit on the line) before
1254-
the character under the cursor, up to *n* characters. If *n* is zero or
1255-
negative, the entire string is inserted. All characters to the right of the
1259+
the character under the cursor, up to *n* characters. If *n* is negative,
1260+
the entire string is inserted. All characters to the right of the
12561261
cursor are shifted right, with the rightmost characters on the line being lost.
12571262
The cursor position does not change (after moving to *y*, *x*, if specified).
12581263

@@ -1871,8 +1876,9 @@ Output options
18711876
.. method:: window.scroll([lines=1])
18721877

18731878
Scroll the screen or scrolling region. Scroll upward by *lines* lines if
1874-
*lines* is positive, or downward if it is negative. Scrolling has no effect
1875-
unless it has been enabled for the window with :meth:`scrollok`.
1879+
*lines* is positive, or downward if it is negative.
1880+
Raise :exc:`curses.error` unless scrolling has been enabled for the window
1881+
with :meth:`scrollok`.
18761882

18771883
.. method:: window.setscrreg(top, bottom)
18781884

‎Doc/library/dis.rst‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,10 +1436,14 @@ iterations of the loop.
14361436
.. opcode:: LOAD_GLOBAL (namei)
14371437

14381438
Loads the global named ``co_names[namei>>1]`` onto the stack.
1439+
If the low bit of ``namei`` is set, a ``NULL`` is pushed onto the stack
1440+
after the global variable.
14391441

14401442
.. versionchanged:: 3.11
1441-
If the low bit of ``namei`` is set, then a ``NULL`` is pushed to the
1442-
stack before the global variable.
1443+
The low bit of ``namei`` indicates whether a ``NULL`` is pushed.
1444+
1445+
.. versionchanged:: 3.13
1446+
The ``NULL`` is pushed after the global variable, rather than before it.
14431447

14441448
.. opcode:: LOAD_FAST (var_num)
14451449

‎Doc/library/shutil.rst‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ Directory and files operations
242242

243243
.. function:: copytree(src, dst, symlinks=False, ignore=None, \
244244
copy_function=copy2, ignore_dangling_symlinks=False, \
245-
dirs_exist_ok=False)
245+
dirs_exist_ok=False, *, copy_dir_stat=True)
246246
247247
Recursively copy an entire directory tree rooted at *src* to a directory
248248
named *dst* and return the destination directory. All intermediate
@@ -251,6 +251,12 @@ Directory and files operations
251251
Permissions and times of directories are copied with :func:`copystat`,
252252
individual files are copied using :func:`~shutil.copy2`.
253253

254+
If *copy_dir_stat* is false, directory metadata is not copied with
255+
:func:`copystat`, e.g. to copy a read-only tree into a writable one.
256+
It defaults to true. Note that file metadata is always handled by
257+
*copy_function*: use e.g. ``copy_function=shutil.copyfile`` to skip
258+
that as well.
259+
254260
If *symlinks* is true, symbolic links in the source tree are represented as
255261
symbolic links in the new tree and the metadata of the original links will
256262
be copied as far as the platform allows; if false or omitted, the contents
@@ -306,6 +312,9 @@ Directory and files operations
306312
.. versionchanged:: 3.8
307313
Added the *dirs_exist_ok* parameter.
308314

315+
.. versionchanged:: 3.16
316+
Added the *copy_dir_stat* parameter.
317+
309318
.. function:: rmtree(path, ignore_errors=False, onerror=None, *, onexc=None, dir_fd=None)
310319

311320
.. index:: single: directory; deleting
@@ -316,6 +325,12 @@ Directory and files operations
316325
handled by calling a handler specified by *onexc* or *onerror* or, if both
317326
are omitted, exceptions are propagated to the caller.
318327

328+
If *path* is a symbolic link to a directory followed by a trailing path
329+
separator, such as ``'link/'``, the operating system resolves the link, so
330+
:func:`!rmtree` deletes the contents of the directory it points to and then
331+
fails to remove *path* itself. :class:`pathlib.Path` strips trailing
332+
separators, so ``rmtree(Path('link/'))`` refuses the link as usual.
333+
319334
This function can support :ref:`paths relative to directory descriptors
320335
<dir_fd>`.
321336

‎Doc/library/tarfile.rst‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,11 @@ reused in custom filters:
11311131
- :ref:`Refuse <tarfile-extraction-refuse>` to extract files whose absolute
11321132
path (after following symlinks) would end up outside the destination.
11331133
This raises :class:`~tarfile.OutsideDestinationError`.
1134+
- :ref:`Refuse <tarfile-extraction-refuse>` to extract links (hard or soft)
1135+
whose name refers to the destination directory itself.
1136+
This raises :class:`~tarfile.OutsideDestinationError`.
1137+
Note that such files are refused even on platforms that do not support
1138+
symbolic links.
11341139
- Clear high mode bits (setuid, setgid, sticky) and group/other write bits
11351140
(:const:`~stat.S_IWGRP` | :const:`~stat.S_IWOTH`).
11361141

‎Doc/library/zipfile.rst‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,10 @@ Path objects are traversable using the ``/`` operator or ``joinpath``.
722722

723723
Enumerate the children of the current directory.
724724

725+
.. versionchanged:: 3.16
726+
Raises :exc:`NotADirectoryError` when the current context does not
727+
reference a directory. Previously, it raised :exc:`ValueError`.
728+
725729
.. method:: Path.is_dir()
726730

727731
Return ``True`` if the current context references a directory.

0 commit comments

Comments
 (0)