Skip to content

Commit 1e515a4

Browse files
authored
Merge branch 'main' into gh-123599-use-urllib
2 parents 5e24cd4 + d783d7b commit 1e515a4

File tree

231 files changed

+4911
-2813
lines changed

Some content is hidden

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

231 files changed

+4911
-2813
lines changed

Doc/c-api/monitoring.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,3 +196,15 @@ would typically correspond to a python function.
196196
.. c:function:: int PyMonitoring_ExitScope(void)
197197
198198
Exit the last scope that was entered with :c:func:`!PyMonitoring_EnterScope`.
199+
200+
201+
.. c:function:: int PY_MONITORING_IS_INSTRUMENTED_EVENT(uint8_t ev)
202+
203+
Return true if the event corresponding to the event ID *ev* is
204+
a :ref:`local event <monitoring-event-local>`.
205+
206+
.. versionadded:: 3.13
207+
208+
.. deprecated:: next
209+
210+
This function is :term:`soft deprecated`.

Doc/glossary.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,10 @@ Glossary
800800
thread removes *key* from *mapping* after the test, but before the lookup.
801801
This issue can be solved with locks or by using the EAFP approach.
802802

803+
lexical analyzer
804+
805+
Formal name for the *tokenizer*; see :term:`token`.
806+
803807
list
804808
A built-in Python :term:`sequence`. Despite its name it is more akin
805809
to an array in other languages than to a linked list since access to
@@ -1291,6 +1295,17 @@ Glossary
12911295
See also :term:`binary file` for a file object able to read and write
12921296
:term:`bytes-like objects <bytes-like object>`.
12931297

1298+
token
1299+
1300+
A small unit of source code, generated by the
1301+
:ref:`lexical analyzer <lexical>` (also called the *tokenizer*).
1302+
Names, numbers, strings, operators,
1303+
newlines and similar are represented by tokens.
1304+
1305+
The :mod:`tokenize` module exposes Python's lexical analyzer.
1306+
The :mod:`token` module contains information on the various types
1307+
of tokens.
1308+
12941309
triple-quoted string
12951310
A string which is bound by three instances of either a quotation mark
12961311
(") or an apostrophe ('). While they don't provide any functionality

Doc/library/bdb.rst

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ The :mod:`bdb` module also defines two classes:
118118

119119
Count of the number of times a :class:`Breakpoint` has been hit.
120120

121-
.. class:: Bdb(skip=None)
121+
.. class:: Bdb(skip=None, backend='settrace')
122122

123123
The :class:`Bdb` class acts as a generic Python debugger base class.
124124

@@ -132,9 +132,22 @@ The :mod:`bdb` module also defines two classes:
132132
frame is considered to originate in a certain module is determined
133133
by the ``__name__`` in the frame globals.
134134

135+
The *backend* argument specifies the backend to use for :class:`Bdb`. It
136+
can be either ``'settrace'`` or ``'monitoring'``. ``'settrace'`` uses
137+
:func:`sys.settrace` which has the best backward compatibility. The
138+
``'monitoring'`` backend uses the new :mod:`sys.monitoring` that was
139+
introduced in Python 3.12, which can be much more efficient because it
140+
can disable unused events. We are trying to keep the exact interfaces
141+
for both backends, but there are some differences. The debugger developers
142+
are encouraged to use the ``'monitoring'`` backend to achieve better
143+
performance.
144+
135145
.. versionchanged:: 3.1
136146
Added the *skip* parameter.
137147

148+
.. versionchanged:: 3.14
149+
Added the *backend* parameter.
150+
138151
The following methods of :class:`Bdb` normally don't need to be overridden.
139152

140153
.. method:: canonic(filename)
@@ -146,6 +159,20 @@ The :mod:`bdb` module also defines two classes:
146159
<os.path.abspath>`. A *filename* with angle brackets, such as ``"<stdin>"``
147160
generated in interactive mode, is returned unchanged.
148161

162+
.. method:: start_trace(self)
163+
164+
Start tracing. For ``'settrace'`` backend, this method is equivalent to
165+
``sys.settrace(self.trace_dispatch)``
166+
167+
.. versionadded:: 3.14
168+
169+
.. method:: stop_trace(self)
170+
171+
Stop tracing. For ``'settrace'`` backend, this method is equivalent to
172+
``sys.settrace(None)``
173+
174+
.. versionadded:: 3.14
175+
149176
.. method:: reset()
150177

151178
Set the :attr:`!botframe`, :attr:`!stopframe`, :attr:`!returnframe` and
@@ -364,6 +391,28 @@ The :mod:`bdb` module also defines two classes:
364391
Return all breakpoints that are set.
365392

366393

394+
Derived classes and clients can call the following methods to disable and
395+
restart events to achieve better performance. These methods only work
396+
when using the ``'monitoring'`` backend.
397+
398+
.. method:: disable_current_event()
399+
400+
Disable the current event until the next time :func:`restart_events` is
401+
called. This is helpful when the debugger is not interested in the current
402+
line.
403+
404+
.. versionadded:: 3.14
405+
406+
.. method:: restart_events()
407+
408+
Restart all the disabled events. This function is automatically called in
409+
``dispatch_*`` methods after ``user_*`` methods are called. If the
410+
``dispatch_*`` methods are not overridden, the disabled events will be
411+
restarted after each user interaction.
412+
413+
.. versionadded:: 3.14
414+
415+
367416
Derived classes and clients can call the following methods to get a data
368417
structure representing a stack trace.
369418

Doc/library/cmdline.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The following modules have a command-line interface.
1212
* :ref:`compileall <compileall-cli>`
1313
* :mod:`cProfile`: see :ref:`profile <profile-cli>`
1414
* :ref:`dis <dis-cli>`
15-
* :mod:`doctest`
15+
* :ref:`doctest <doctest-cli>`
1616
* :mod:`!encodings.rot_13`
1717
* :mod:`ensurepip`
1818
* :mod:`filecmp`

Doc/library/dis.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ details of bytecode instructions as :class:`Instruction` instances:
535535
:class:`dis.Positions` object holding the
536536
start and end locations that are covered by this instruction.
537537

538-
.. data::cache_info
538+
.. data:: cache_info
539539

540540
Information about the cache entries of this instruction, as
541541
triplets of the form ``(name, size, data)``, where the ``name``

Doc/library/doctest.rst

Lines changed: 46 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,8 @@ prohibit it by passing ``verbose=False``. In either of those cases,
177177
``sys.argv`` is not examined by :func:`testmod` (so passing ``-v`` or not
178178
has no effect).
179179

180-
There is also a command line shortcut for running :func:`testmod`. You can
181-
instruct the Python interpreter to run the doctest module directly from the
182-
standard library and pass the module name(s) on the command line::
183-
184-
python -m doctest -v example.py
185-
186-
This will import :file:`example.py` as a standalone module and run
187-
:func:`testmod` on it. Note that this may not work correctly if the file is
188-
part of a package and imports other submodules from that package.
180+
There is also a command line shortcut for running :func:`testmod`, see section
181+
:ref:`doctest-cli`.
189182

190183
For more information on :func:`testmod`, see section :ref:`doctest-basic-api`.
191184

@@ -248,16 +241,53 @@ Like :func:`testmod`, :func:`testfile`'s verbosity can be set with the
248241
``-v`` command-line switch or with the optional keyword argument
249242
*verbose*.
250243

251-
There is also a command line shortcut for running :func:`testfile`. You can
252-
instruct the Python interpreter to run the doctest module directly from the
253-
standard library and pass the file name(s) on the command line::
244+
There is also a command line shortcut for running :func:`testfile`, see section
245+
:ref:`doctest-cli`.
254246

255-
python -m doctest -v example.txt
247+
For more information on :func:`testfile`, see section :ref:`doctest-basic-api`.
256248

257-
Because the file name does not end with :file:`.py`, :mod:`doctest` infers that
258-
it must be run with :func:`testfile`, not :func:`testmod`.
259249

260-
For more information on :func:`testfile`, see section :ref:`doctest-basic-api`.
250+
.. _doctest-cli:
251+
252+
Command-line Usage
253+
------------------
254+
255+
The :mod:`doctest` module can be invoked as a script from the command line:
256+
257+
.. code-block:: bash
258+
259+
python -m doctest [-v] [-o OPTION] [-f] file [file ...]
260+
261+
.. program:: doctest
262+
263+
.. option:: -v, --verbose
264+
265+
Detailed report of all examples tried is printed to standard output,
266+
along with assorted summaries at the end::
267+
268+
python -m doctest -v example.py
269+
270+
This will import :file:`example.py` as a standalone module and run
271+
:func:`testmod` on it. Note that this may not work correctly if the
272+
file is part of a package and imports other submodules from that package.
273+
274+
If the file name does not end with :file:`.py`, :mod:`!doctest` infers
275+
that it must be run with :func:`testfile` instead::
276+
277+
python -m doctest -v example.txt
278+
279+
.. option:: -o, --option <option>
280+
281+
Option flags control various aspects of doctest's behavior, see section
282+
:ref:`doctest-options`.
283+
284+
.. versionadded:: 3.4
285+
286+
.. option:: -f, --fail-fast
287+
288+
This is shorthand for ``-o FAIL_FAST``.
289+
290+
.. versionadded:: 3.4
261291

262292

263293
.. _doctest-how-it-works:
@@ -540,9 +570,6 @@ Symbolic names for the flags are supplied as module constants, which can be
540570
The names can also be used in :ref:`doctest directives <doctest-directives>`,
541571
and may be passed to the doctest command line interface via the ``-o`` option.
542572

543-
.. versionadded:: 3.4
544-
The ``-o`` command line option.
545-
546573
The first group of options define test semantics, controlling aspects of how
547574
doctest decides whether actual output matches an example's expected output:
548575

@@ -682,11 +709,6 @@ The second group of options controls how test failures are reported:
682709
1. This flag may be useful during debugging, since examples after the first
683710
failure won't even produce debugging output.
684711

685-
The doctest command line accepts the option ``-f`` as a shorthand for ``-o
686-
FAIL_FAST``.
687-
688-
.. versionadded:: 3.4
689-
690712

691713
.. data:: REPORTING_FLAGS
692714

Doc/library/graphlib.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,14 @@
106106
function, the graph cannot be modified, and therefore no more nodes can be
107107
added using :meth:`~TopologicalSorter.add`.
108108

109+
A :exc:`ValueError` will be raised if the sort has been started by
110+
:meth:`~.static_order` or :meth:`~.get_ready`.
111+
112+
.. versionchanged:: next
113+
114+
``prepare()`` can now be called more than once as long as the sort has
115+
not started. Previously this raised :exc:`ValueError`.
116+
109117
.. method:: is_active()
110118

111119
Returns ``True`` if more progress can be made and ``False`` otherwise.

Doc/library/math.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,8 @@ Floating point manipulation functions
350350

351351
*abs_tol* is the absolute tolerance; it defaults to ``0.0`` and it must be
352352
nonnegative. When comparing ``x`` to ``0.0``, ``isclose(x, 0)`` is computed
353-
as ``abs(x) <= rel_tol * abs(x)``, which is ``False`` for any ``x`` and
354-
rel_tol less than ``1.0``. So add an appropriate positive abs_tol argument
353+
as ``abs(x) <= rel_tol * abs(x)``, which is ``False`` for any nonzero ``x`` and
354+
*rel_tol* less than ``1.0``. So add an appropriate positive *abs_tol* argument
355355
to the call.
356356

357357
The IEEE 754 special values of ``NaN``, ``inf``, and ``-inf`` will be

Doc/library/pdb.rst

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,13 +203,32 @@ slightly different way:
203203
Enter post-mortem debugging of the exception found in
204204
:data:`sys.last_exc`.
205205

206+
.. function:: set_default_backend(backend)
207+
208+
There are two supported backends for pdb: ``'settrace'`` and ``'monitoring'``.
209+
See :class:`bdb.Bdb` for details. The user can set the default backend to
210+
use if none is specified when instantiating :class:`Pdb`. If no backend is
211+
specified, the default is ``'settrace'``.
212+
213+
.. note::
214+
215+
:func:`breakpoint` and :func:`set_trace` will not be affected by this
216+
function. They always use ``'monitoring'`` backend.
217+
218+
.. versionadded:: 3.14
219+
220+
.. function:: get_default_backend()
221+
222+
Returns the default backend for pdb.
223+
224+
.. versionadded:: 3.14
206225

207226
The ``run*`` functions and :func:`set_trace` are aliases for instantiating the
208227
:class:`Pdb` class and calling the method of the same name. If you want to
209228
access further features, you have to do this yourself:
210229

211230
.. class:: Pdb(completekey='tab', stdin=None, stdout=None, skip=None, \
212-
nosigint=False, readrc=True, mode=None)
231+
nosigint=False, readrc=True, mode=None, backend=None)
213232

214233
:class:`Pdb` is the debugger class.
215234

@@ -235,6 +254,10 @@ access further features, you have to do this yourself:
235254
or ``None`` (for backwards compatible behaviour, as before the *mode*
236255
argument was added).
237256

257+
The *backend* argument specifies the backend to use for the debugger. If ``None``
258+
is passed, the default backend will be used. See :func:`set_default_backend`.
259+
Otherwise the supported backends are ``'settrace'`` and ``'monitoring'``.
260+
238261
Example call to enable tracing with *skip*::
239262

240263
import pdb; pdb.Pdb(skip=['django.*']).set_trace()
@@ -254,6 +277,9 @@ access further features, you have to do this yourself:
254277
.. versionadded:: 3.14
255278
Added the *mode* argument.
256279

280+
.. versionadded:: 3.14
281+
Added the *backend* argument.
282+
257283
.. versionchanged:: 3.14
258284
Inline breakpoints like :func:`breakpoint` or :func:`pdb.set_trace` will
259285
always stop the program at calling frame, ignoring the *skip* pattern (if any).

Doc/library/pickletools.rst

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ ordinary users of the :mod:`pickle` module probably won't find the
1919

2020
.. _pickletools-cli:
2121

22-
Command line usage
22+
Command-line usage
2323
------------------
2424

2525
.. versionadded:: 3.2
@@ -48,7 +48,7 @@ For example, with a tuple ``(1, 2)`` pickled in file ``x.pickle``:
4848
9: . STOP
4949
highest protocol among opcodes = 2
5050
51-
Command line options
51+
Command-line options
5252
^^^^^^^^^^^^^^^^^^^^
5353

5454
.. program:: pickletools
@@ -72,12 +72,16 @@ Command line options
7272

7373
.. option:: -p, --preamble=<preamble>
7474

75-
When more than one pickle file are specified, print given preamble
75+
When more than one pickle file is specified, print given preamble
7676
before each disassembly.
7777

78+
.. option:: pickle_file
7879

80+
A pickle file to read, or ``-`` to indicate reading from standard input.
7981

80-
Programmatic Interface
82+
83+
84+
Programmatic interface
8185
----------------------
8286

8387

0 commit comments

Comments
 (0)