Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fec6666

Browse files
committed
Merge branch 'master' into long_export-decimal
2 parents 7e0e9a9 + d9ed42b commit fec6666

155 files changed

Lines changed: 4454 additions & 2317 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-macos.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@ jobs:
4242
run: |
4343
brew install pkg-config [email protected] xz gdbm tcl-tk@8 make
4444
# Because alternate versions are not symlinked into place by default:
45-
brew link tcl-tk@8
45+
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/c-api/monitoring.rst

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,14 @@ See :mod:`sys.monitoring` for descriptions of the events.
7575
Fire a ``JUMP`` event.
7676
7777
78-
.. c:function:: int PyMonitoring_FireBranchEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset, PyObject *target_offset)
78+
.. c:function:: int PyMonitoring_FireBranchLeftEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset, PyObject *target_offset)
7979
80-
Fire a ``BRANCH`` event.
80+
Fire a ``BRANCH_LEFT`` event.
81+
82+
83+
.. c:function:: int PyMonitoring_FireBranchRightEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset, PyObject *target_offset)
84+
85+
Fire a ``BRANCH_RIGHT`` event.
8186
8287
8388
.. c:function:: int PyMonitoring_FireCReturnEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset, PyObject *retval)
@@ -168,7 +173,8 @@ would typically correspond to a python function.
168173
================================================== =====================================
169174
Macro Event
170175
================================================== =====================================
171-
.. c:macro:: PY_MONITORING_EVENT_BRANCH :monitoring-event:`BRANCH`
176+
.. c:macro:: PY_MONITORING_EVENT_BRANCH_LEFT :monitoring-event:`BRANCH_LEFT`
177+
.. c:macro:: PY_MONITORING_EVENT_BRANCH_RIGHT :monitoring-event:`BRANCH_RIGHT`
172178
.. c:macro:: PY_MONITORING_EVENT_CALL :monitoring-event:`CALL`
173179
.. c:macro:: PY_MONITORING_EVENT_C_RAISE :monitoring-event:`C_RAISE`
174180
.. c:macro:: PY_MONITORING_EVENT_C_RETURN :monitoring-event:`C_RETURN`

Doc/c-api/weakref.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,15 @@ as much as it can.
8888
Use :c:func:`PyWeakref_GetRef` instead.
8989
9090
91+
.. c:function:: int PyWeakref_IsDead(PyObject *ref)
92+
93+
Test if the weak reference *ref* is dead. Returns 1 if the reference is
94+
dead, 0 if it is alive, and -1 with an error set if *ref* is not a weak
95+
reference object.
96+
97+
.. versionadded:: 3.14
98+
99+
91100
.. c:function:: void PyObject_ClearWeakRefs(PyObject *object)
92101
93102
This function is called by the :c:member:`~PyTypeObject.tp_dealloc` handler

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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ an event loop:
6666

6767
Set *loop* as the current event loop for the current OS thread.
6868

69+
.. deprecated:: next
70+
The :func:`set_event_loop` function is deprecated and will be removed
71+
in Python 3.16.
72+
6973
.. function:: new_event_loop()
7074

7175
Create and return a new event loop object.

Doc/library/asyncio-policy.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ The abstract event loop policy base class is defined as follows:
8787

8888
This method should never return ``None``.
8989

90+
.. deprecated:: next
91+
The :class:`AbstractEventLoopPolicy` class is deprecated and
92+
will be removed in Python 3.16.
93+
9094

9195
.. _asyncio-policy-builtin:
9296

@@ -109,6 +113,10 @@ asyncio ships with the following built-in policies:
109113
The :meth:`get_event_loop` method of the default asyncio policy now
110114
raises a :exc:`RuntimeError` if there is no set event loop.
111115

116+
.. deprecated:: next
117+
The :class:`DefaultEventLoopPolicy` class is deprecated and
118+
will be removed in Python 3.16.
119+
112120

113121
.. class:: WindowsSelectorEventLoopPolicy
114122

@@ -117,6 +125,10 @@ asyncio ships with the following built-in policies:
117125

118126
.. availability:: Windows.
119127

128+
.. deprecated:: next
129+
The :class:`WindowsSelectorEventLoopPolicy` class is deprecated and
130+
will be removed in Python 3.16.
131+
120132

121133
.. class:: WindowsProactorEventLoopPolicy
122134

@@ -125,6 +137,10 @@ asyncio ships with the following built-in policies:
125137

126138
.. availability:: Windows.
127139

140+
.. deprecated:: next
141+
The :class:`WindowsProactorEventLoopPolicy` class is deprecated and
142+
will be removed in Python 3.16.
143+
128144

129145
.. _asyncio-custom-policies:
130146

Doc/library/cmdlinelibs.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.. _cmdlinelibs:
2+
3+
********************************
4+
Command Line Interface Libraries
5+
********************************
6+
7+
The modules described in this chapter assist with implementing
8+
command line and terminal interfaces for applications.
9+
10+
Here's an overview:
11+
12+
.. toctree::
13+
:maxdepth: 1
14+
15+
argparse.rst
16+
optparse.rst
17+
getpass.rst
18+
fileinput.rst
19+
curses.rst
20+
curses.ascii.rst
21+
curses.panel.rst

0 commit comments

Comments
 (0)