Skip to content

Commit b8d967e

Browse files
authored
Merge branch 'main' into issue-65329
2 parents bb8e73f + f184abb commit b8d967e

File tree

111 files changed

+2368
-1438
lines changed

Some content is hidden

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

111 files changed

+2368
-1438
lines changed

.devcontainer/devcontainer.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,16 @@
3737
// "ms-python.python"
3838
],
3939
"settings": {
40+
"C_Cpp.default.compilerPath": "/usr/bin/clang",
4041
"C_Cpp.default.cStandard": "c11",
4142
"C_Cpp.default.defines": [
43+
"CONFIG_64",
4244
"Py_BUILD_CORE"
4345
],
46+
"C_Cpp.default.includePath": [
47+
"${workspaceFolder}/*",
48+
"${workspaceFolder}/Include/**"
49+
],
4450
// https://github.com/microsoft/vscode-cpptools/issues/10732
4551
"C_Cpp.errorSquiggles": "disabled",
4652
"editor.insertSpaces": true,

Doc/howto/enum.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ The values are chosen by :func:`_generate_next_value_`, which can be
284284
overridden::
285285

286286
>>> class AutoName(Enum):
287+
... @staticmethod
287288
... def _generate_next_value_(name, start, count, last_values):
288289
... return name
289290
...
@@ -372,6 +373,11 @@ below)::
372373
>>> Color.BLUE == 2
373374
False
374375

376+
.. warning::
377+
378+
It is possible to reload modules -- if a reloaded module contains
379+
enums, they will be recreated, and the new members may not
380+
compare identical/equal to the original members.
375381

376382
Allowed members and attributes of enumerations
377383
----------------------------------------------

Doc/library/enum.rst

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,8 @@ Module Contents
141141
:func:`global_enum`
142142

143143
Modify the :class:`str() <str>` and :func:`repr` of an enum
144-
to show its members as belonging to the module instead of its class.
145-
Should only be used if the enum members will be exported to the
146-
module global namespace.
144+
to show its members as belonging to the module instead of its class,
145+
and export the enum members to the global namespace.
147146

148147
:func:`show_flag_values`
149148

@@ -170,6 +169,27 @@ Data Types
170169
final *enum*, as well as creating the enum members, properly handling
171170
duplicates, providing iteration over the enum class, etc.
172171

172+
.. method:: EnumType.__call__(cls, value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
173+
174+
This method is called in two different ways:
175+
176+
* to look up an existing member:
177+
178+
:cls: The enum class being called.
179+
:value: The value to lookup.
180+
181+
* to use the ``cls`` enum to create a new enum (only if the existing enum
182+
does not have any members):
183+
184+
:cls: The enum class being called.
185+
:value: The name of the new Enum to create.
186+
:names: The names/values of the members for the new Enum.
187+
:module: The name of the module the new Enum is created in.
188+
:qualname: The actual location in the module where this Enum can be found.
189+
:type: A mix-in type for the new Enum.
190+
:start: The first integer value for the Enum (used by :class:`auto`).
191+
:boundary: How to handle out-of-range values from bit operations (:class:`Flag` only).
192+
173193
.. method:: EnumType.__contains__(cls, member)
174194

175195
Returns ``True`` if member belongs to the ``cls``::
@@ -255,26 +275,6 @@ Data Types
255275
names will also be removed from the completed enumeration. See
256276
:ref:`TimePeriod <enum-time-period>` for an example.
257277

258-
.. method:: Enum.__call__(cls, value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
259-
260-
This method is called in two different ways:
261-
262-
* to look up an existing member:
263-
264-
:cls: The enum class being called.
265-
:value: The value to lookup.
266-
267-
* to use the ``cls`` enum to create a new enum:
268-
269-
:cls: The enum class being called.
270-
:value: The name of the new Enum to create.
271-
:names: The names/values of the members for the new Enum.
272-
:module: The name of the module the new Enum is created in.
273-
:qualname: The actual location in the module where this Enum can be found.
274-
:type: A mix-in type for the new Enum.
275-
:start: The first integer value for the Enum (used by :class:`auto`).
276-
:boundary: How to handle out-of-range values from bit operations (:class:`Flag` only).
277-
278278
.. method:: Enum.__dir__(self)
279279

280280
Returns ``['__class__', '__doc__', '__module__', 'name', 'value']`` and
@@ -728,7 +728,6 @@ Data Types
728728
.. attribute:: EJECT
729729

730730
Out-of-range values lose their *Flag* membership and revert to :class:`int`.
731-
This is the default for :class:`IntFlag`::
732731

733732
>>> from enum import Flag, EJECT, auto
734733
>>> class EjectFlag(Flag, boundary=EJECT):
@@ -741,8 +740,8 @@ Data Types
741740

742741
.. attribute:: KEEP
743742

744-
Out-of-range values are kept, and the *Flag* membership is kept. This is
745-
used for some stdlib flags::
743+
Out-of-range values are kept, and the *Flag* membership is kept.
744+
This is the default for :class:`IntFlag`::
746745

747746
>>> from enum import Flag, KEEP, auto
748747
>>> class KeepFlag(Flag, boundary=KEEP):

Doc/library/profile.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ the following::
8282

8383
The first line indicates that 214 calls were monitored. Of those calls, 207
8484
were :dfn:`primitive`, meaning that the call was not induced via recursion. The
85-
next line: ``Ordered by: cumulative name``, indicates that the text string in the
85+
next line: ``Ordered by: cumulative time``, indicates that the text string in the
8686
far right column was used to sort the output. The column headings include:
8787

8888
ncalls

Doc/library/test.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1691,6 +1691,21 @@ The :mod:`test.support.warnings_helper` module provides support for warnings tes
16911691
.. versionadded:: 3.10
16921692

16931693

1694+
.. function:: ignore_warnings(*, category)
1695+
1696+
Suppress warnings that are instances of *category*,
1697+
which must be :exc:`Warning` or a subclass.
1698+
Roughly equivalent to :func:`warnings.catch_warnings`
1699+
with :meth:`warnings.simplefilter('ignore', category=category) <warnings.simplefilter>`.
1700+
For example::
1701+
1702+
@warning_helper.ignore_warnings(category=DeprecationWarning)
1703+
def test_suppress_warning():
1704+
# do something
1705+
1706+
.. versionadded:: 3.8
1707+
1708+
16941709
.. function:: check_no_resource_warning(testcase)
16951710

16961711
Context manager to check that no :exc:`ResourceWarning` was raised. You

Doc/library/unittest.rst

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,10 @@ Command-line options
244244

245245
Show local variables in tracebacks.
246246

247+
.. cmdoption:: --durations N
248+
249+
Show the N slowest test cases (N=0 for all).
250+
247251
.. versionadded:: 3.2
248252
The command-line options ``-b``, ``-c`` and ``-f`` were added.
249253

@@ -253,10 +257,12 @@ Command-line options
253257
.. versionadded:: 3.7
254258
The command-line option ``-k``.
255259

260+
.. versionadded:: 3.12
261+
The command-line option ``--durations``.
262+
256263
The command line can also be used for test discovery, for running all of the
257264
tests in a project or just a subset.
258265

259-
260266
.. _unittest-test-discovery:
261267

262268
Test Discovery
@@ -2009,6 +2015,13 @@ Loading and running tests
20092015
A list containing :class:`TestCase` instances that were marked as expected
20102016
failures, but succeeded.
20112017

2018+
.. attribute:: collectedDurations
2019+
2020+
A list containing 2-tuples of :class:`TestCase` instances and floats
2021+
representing the elapsed time of each test which was run.
2022+
2023+
.. versionadded:: 3.12
2024+
20122025
.. attribute:: shouldStop
20132026

20142027
Set to ``True`` when the execution of tests should stop by :meth:`stop`.
@@ -2160,14 +2173,27 @@ Loading and running tests
21602173

21612174
.. versionadded:: 3.4
21622175

2176+
.. method:: addDuration(test, elapsed)
2177+
2178+
Called when the test case finishes. *elapsed* is the time represented in
2179+
seconds, and it includes the execution of cleanup functions.
2180+
2181+
.. versionadded:: 3.12
21632182

2164-
.. class:: TextTestResult(stream, descriptions, verbosity)
2183+
.. class:: TextTestResult(stream, descriptions, verbosity, *, durations=None)
21652184

21662185
A concrete implementation of :class:`TestResult` used by the
2167-
:class:`TextTestRunner`.
2186+
:class:`TextTestRunner`. Subclasses should accept ``**kwargs`` to ensure
2187+
compatibility as the interface changes.
21682188

21692189
.. versionadded:: 3.2
21702190

2191+
.. versionadded:: 3.12
2192+
Added *durations* keyword argument.
2193+
2194+
.. versionchanged:: 3.12
2195+
Subclasses should accept ``**kwargs`` to ensure compatibility as the
2196+
interface changes.
21712197

21722198
.. data:: defaultTestLoader
21732199

@@ -2177,7 +2203,8 @@ Loading and running tests
21772203

21782204

21792205
.. class:: TextTestRunner(stream=None, descriptions=True, verbosity=1, failfast=False, \
2180-
buffer=False, resultclass=None, warnings=None, *, tb_locals=False)
2206+
buffer=False, resultclass=None, warnings=None, *, \
2207+
tb_locals=False, durations=None)
21812208
21822209
A basic test runner implementation that outputs results to a stream. If *stream*
21832210
is ``None``, the default, :data:`sys.stderr` is used as the output stream. This class
@@ -2195,14 +2222,17 @@ Loading and running tests
21952222
*warnings* to ``None``.
21962223

21972224
.. versionchanged:: 3.2
2198-
Added the ``warnings`` argument.
2225+
Added the *warnings* parameter.
21992226

22002227
.. versionchanged:: 3.2
22012228
The default stream is set to :data:`sys.stderr` at instantiation time rather
22022229
than import time.
22032230

22042231
.. versionchanged:: 3.5
2205-
Added the tb_locals parameter.
2232+
Added the *tb_locals* parameter.
2233+
2234+
.. versionchanged:: 3.12
2235+
Added the *durations* parameter.
22062236

22072237
.. method:: _makeResult()
22082238

Doc/reference/datamodel.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,8 @@ Internal types
991991
the filename from which the code was compiled; :attr:`co_firstlineno` is
992992
the first line number of the function; :attr:`co_lnotab` is a string
993993
encoding the mapping from bytecode offsets to line numbers (for details
994-
see the source code of the interpreter); :attr:`co_stacksize` is the
994+
see the source code of the interpreter, is deprecated since 3.12
995+
and may be removed in 3.14); :attr:`co_stacksize` is the
995996
required stack size; :attr:`co_flags` is an integer encoding a number
996997
of flags for the interpreter.
997998

0 commit comments

Comments
 (0)