Skip to content

Commit 7c6d61a

Browse files
Merge branch 'main' into fix-tk-iconbitmap
2 parents 6aac538 + 9ba0528 commit 7c6d61a

File tree

142 files changed

+2255
-1295
lines changed

Some content is hidden

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

142 files changed

+2255
-1295
lines changed

.github/workflows/reusable-macos.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ jobs:
4545
brew link --overwrite tcl-tk@8
4646
- name: Configure CPython
4747
run: |
48+
MACOSX_DEPLOYMENT_TARGET=10.15 \
4849
GDBM_CFLAGS="-I$(brew --prefix gdbm)/include" \
4950
GDBM_LIBS="-L$(brew --prefix gdbm)/lib -lgdbm" \
5051
./configure \

Doc/about.rst

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
=====================
2-
About these documents
3-
=====================
1+
========================
2+
About this documentation
3+
========================
44

55

6-
These documents are generated from `reStructuredText`_ sources by `Sphinx`_, a
7-
document processor specifically written for the Python documentation.
6+
Python's documentation is generated from `reStructuredText`_ sources
7+
using `Sphinx`_, a documentation generator originally created for Python
8+
and now maintained as an independent project.
89

910
.. _reStructuredText: https://docutils.sourceforge.io/rst.html
1011
.. _Sphinx: https://www.sphinx-doc.org/
@@ -20,14 +21,14 @@ volunteers are always welcome!
2021
Many thanks go to:
2122

2223
* Fred L. Drake, Jr., the creator of the original Python documentation toolset
23-
and writer of much of the content;
24+
and author of much of the content;
2425
* the `Docutils <https://docutils.sourceforge.io/>`_ project for creating
2526
reStructuredText and the Docutils suite;
2627
* Fredrik Lundh for his Alternative Python Reference project from which Sphinx
2728
got many good ideas.
2829

2930

30-
Contributors to the Python Documentation
31+
Contributors to the Python documentation
3132
----------------------------------------
3233

3334
Many people have contributed to the Python language, the Python standard

Doc/c-api/object.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ Object Protocol
111111
.. note::
112112
113113
Exceptions that occur when this calls :meth:`~object.__getattr__` and
114-
:meth:`~object.__getattribute__` methods are silently ignored.
114+
:meth:`~object.__getattribute__` methods aren't propagated,
115+
but instead given to :func:`sys.unraisablehook`.
115116
For proper error handling, use :c:func:`PyObject_HasAttrWithError`,
116117
:c:func:`PyObject_GetOptionalAttr` or :c:func:`PyObject_GetAttr` instead.
117118

Doc/c-api/typeobj.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,6 +1023,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
10231023
:c:macro:`Py_TPFLAGS_HAVE_GC` flag bit is clear in the subtype and the
10241024
:c:member:`~PyTypeObject.tp_traverse` and :c:member:`~PyTypeObject.tp_clear` fields in the subtype exist and have
10251025
``NULL`` values.
1026+
10261027
.. XXX are most flag bits *really* inherited individually?
10271028
10281029
**Default:**

Doc/deprecations/pending-removal-in-3.16.rst

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,35 @@ Pending removal in Python 3.16
1919
* :mod:`asyncio`:
2020

2121
* :func:`!asyncio.iscoroutinefunction` is deprecated
22-
and will be removed in Python 3.16,
22+
and will be removed in Python 3.16;
2323
use :func:`inspect.iscoroutinefunction` instead.
2424
(Contributed by Jiahao Li and Kumar Aditya in :gh:`122875`.)
2525

26+
* :mod:`asyncio` policy system is deprecated and will be removed in Python 3.16.
27+
In particular, the following classes and functions are deprecated:
28+
29+
* :class:`asyncio.AbstractEventLoopPolicy`
30+
* :class:`asyncio.DefaultEventLoopPolicy`
31+
* :class:`asyncio.WindowsSelectorEventLoopPolicy`
32+
* :class:`asyncio.WindowsProactorEventLoopPolicy`
33+
* :func:`asyncio.get_event_loop_policy`
34+
* :func:`asyncio.set_event_loop_policy`
35+
* :func:`asyncio.set_event_loop`
36+
37+
Users should use :func:`asyncio.run` or :class:`asyncio.Runner` with
38+
*loop_factory* to use the desired event loop implementation.
39+
40+
For example, to use :class:`asyncio.SelectorEventLoop` on Windows::
41+
42+
import asyncio
43+
44+
async def main():
45+
...
46+
47+
asyncio.run(main(), loop_factory=asyncio.SelectorEventLoop)
48+
49+
(Contributed by Kumar Aditya in :gh:`127949`.)
50+
2651
* :mod:`builtins`:
2752

2853
* Bitwise inversion on boolean types, ``~True`` or ``~False``
@@ -54,3 +79,8 @@ Pending removal in Python 3.16
5479

5580
* The undocumented and unused :attr:`!TarFile.tarfile` attribute
5681
has been deprecated since Python 3.13.
82+
83+
* :mod:`functools`:
84+
85+
* Calling the Python implementation of :func:`functools.reduce` with *function*
86+
or *sequence* as keyword arguments has been deprecated since Python 3.14.

Doc/howto/argparse-optparse.rst

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
11
.. currentmodule:: argparse
22

33
.. _upgrading-optparse-code:
4+
.. _migrating-optparse-code:
45

5-
==========================
6-
Upgrading optparse code
7-
==========================
6+
============================================
7+
Migrating ``optparse`` code to ``argparse``
8+
============================================
89

9-
Originally, the :mod:`argparse` module had attempted to maintain compatibility
10-
with :mod:`optparse`. However, :mod:`optparse` was difficult to extend
11-
transparently, particularly with the changes required to support
12-
``nargs=`` specifiers and better usage messages. When most everything in
13-
:mod:`optparse` had either been copy-pasted over or monkey-patched, it no
14-
longer seemed practical to try to maintain the backwards compatibility.
15-
16-
The :mod:`argparse` module improves on the :mod:`optparse`
17-
module in a number of ways including:
10+
The :mod:`argparse` module offers several higher level features not natively
11+
provided by the :mod:`optparse` module, including:
1812

1913
* Handling positional arguments.
2014
* Supporting subcommands.
@@ -23,7 +17,23 @@ module in a number of ways including:
2317
* Producing more informative usage messages.
2418
* Providing a much simpler interface for custom ``type`` and ``action``.
2519

26-
A partial upgrade path from :mod:`optparse` to :mod:`argparse`:
20+
Originally, the :mod:`argparse` module attempted to maintain compatibility
21+
with :mod:`optparse`. However, the fundamental design differences between
22+
supporting declarative command line option processing (while leaving positional
23+
argument processing to application code), and supporting both named options
24+
and positional arguments in the declarative interface mean that the
25+
API has diverged from that of ``optparse`` over time.
26+
27+
As described in :ref:`choosing-an-argument-parser`, applications that are
28+
currently using :mod:`optparse` and are happy with the way it works can
29+
just continue to use ``optparse``.
30+
31+
Application developers that are considering migrating should also review
32+
the list of intrinsic behavioural differences described in that section
33+
before deciding whether or not migration is desirable.
34+
35+
For applications that do choose to migrate from :mod:`optparse` to :mod:`argparse`,
36+
the following suggestions should be helpful:
2737

2838
* Replace all :meth:`optparse.OptionParser.add_option` calls with
2939
:meth:`ArgumentParser.add_argument` calls.

Doc/howto/argparse.rst

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,16 @@ recommended command-line parsing module in the Python standard library.
1313

1414
.. note::
1515

16-
There are two other modules that fulfill the same task, namely
17-
:mod:`getopt` (an equivalent for ``getopt()`` from the C
18-
language) and the deprecated :mod:`optparse`.
19-
Note also that :mod:`argparse` is based on :mod:`optparse`,
20-
and therefore very similar in terms of usage.
16+
The standard library includes two other libraries directly related
17+
to command-line parameter processing: the lower level :mod:`optparse`
18+
module (which may require more code to configure for a given application,
19+
but also allows an application to request behaviors that ``argparse``
20+
doesn't support), and the very low level :mod:`getopt` (which specifically
21+
serves as an equivalent to the :c:func:`!getopt` family of functions
22+
available to C programmers).
23+
While neither of those modules is covered directly in this guide, many of
24+
the core concepts in ``argparse`` first originated in ``optparse``, so
25+
some aspects of this tutorial will also be relevant to ``optparse`` users.
2126

2227

2328
Concepts

Doc/library/allos.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,9 @@ but they are available on most other systems as well. Here's an overview:
1515
os.rst
1616
io.rst
1717
time.rst
18-
argparse.rst
1918
logging.rst
2019
logging.config.rst
2120
logging.handlers.rst
22-
getpass.rst
23-
curses.rst
24-
curses.ascii.rst
25-
curses.panel.rst
2621
platform.rst
2722
errno.rst
2823
ctypes.rst

Doc/library/argparse.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@
1111

1212
**Source code:** :source:`Lib/argparse.py`
1313

14+
.. note::
15+
16+
While :mod:`argparse` is the default recommended standard library module
17+
for implementing basic command line applications, authors with more
18+
exacting requirements for exactly how their command line applications
19+
behave may find it doesn't provide the necessary level of control.
20+
Refer to :ref:`choosing-an-argument-parser` for alternatives to
21+
consider when ``argparse`` doesn't support behaviors that the application
22+
requires (such as entirely disabling support for interspersed options and
23+
positional arguments, or accepting option parameter values that start
24+
with ``-`` even when they correspond to another defined option).
25+
1426
--------------
1527

1628
.. sidebar:: Tutorial

Doc/library/asyncio-eventloop.rst

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,21 @@ an event loop:
6262
.. versionchanged:: 3.14
6363
Raises a :exc:`RuntimeError` if there is no current event loop.
6464

65+
.. note::
66+
67+
The :mod:`!asyncio` policy system is deprecated and will be removed
68+
in Python 3.16; from there on, this function will always return the
69+
running event loop.
70+
71+
6572
.. function:: set_event_loop(loop)
6673

6774
Set *loop* as the current event loop for the current OS thread.
6875

76+
.. deprecated:: next
77+
The :func:`set_event_loop` function is deprecated and will be removed
78+
in Python 3.16.
79+
6980
.. function:: new_event_loop()
7081

7182
Create and return a new event loop object.
@@ -1777,12 +1788,11 @@ By default asyncio is configured to use :class:`EventLoop`.
17771788
import asyncio
17781789
import selectors
17791790

1780-
class MyPolicy(asyncio.DefaultEventLoopPolicy):
1781-
def new_event_loop(self):
1782-
selector = selectors.SelectSelector()
1783-
return asyncio.SelectorEventLoop(selector)
1791+
async def main():
1792+
...
17841793

1785-
asyncio.set_event_loop_policy(MyPolicy())
1794+
loop_factory = lambda: asyncio.SelectorEventLoop(selectors.SelectSelector())
1795+
asyncio.run(main(), loop_factory=loop_factory)
17861796

17871797

17881798
.. availability:: Unix, Windows.

0 commit comments

Comments
 (0)