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

Skip to content

Commit 5bf5187

Browse files
committed
Catch up with main
2 parents 4cb7a87 + 48dfd74 commit 5bf5187

284 files changed

Lines changed: 5090 additions & 2037 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/build.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ jobs:
190190
build_windows_free_threaded:
191191
name: 'Windows (free-threaded)'
192192
needs: check_source
193-
if: needs.check_source.outputs.run_tests == 'true' && contains(github.event.pull_request.labels.*.name, 'topic-free-threaded')
193+
if: needs.check_source.outputs.run_tests == 'true'
194194
uses: ./.github/workflows/reusable-windows.yml
195195
with:
196196
free-threaded: true
@@ -206,7 +206,7 @@ jobs:
206206
build_macos_free_threaded:
207207
name: 'macOS (free-threaded)'
208208
needs: check_source
209-
if: needs.check_source.outputs.run_tests == 'true' && contains(github.event.pull_request.labels.*.name, 'topic-free-threaded')
209+
if: needs.check_source.outputs.run_tests == 'true'
210210
uses: ./.github/workflows/reusable-macos.yml
211211
with:
212212
config_hash: ${{ needs.check_source.outputs.config_hash }}
@@ -228,7 +228,7 @@ jobs:
228228
build_ubuntu_free_threaded:
229229
name: 'Ubuntu (free-threaded)'
230230
needs: check_source
231-
if: needs.check_source.outputs.run_tests == 'true' && contains(github.event.pull_request.labels.*.name, 'topic-free-threaded')
231+
if: needs.check_source.outputs.run_tests == 'true'
232232
uses: ./.github/workflows/reusable-ubuntu.yml
233233
with:
234234
config_hash: ${{ needs.check_source.outputs.config_hash }}
@@ -521,10 +521,7 @@ jobs:
521521
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe
522522
with:
523523
allowed-failures: >-
524-
build_macos_free_threaded,
525-
build_ubuntu_free_threaded,
526524
build_ubuntu_ssltests,
527-
build_windows_free_threaded,
528525
cifuzz,
529526
test_hypothesis,
530527
allowed-skips: >-

Doc/c-api/set.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ subtypes but not for instances of :class:`frozenset` or its subtypes.
147147
148148
Return ``1`` if found and removed, ``0`` if not found (no action taken), and ``-1`` if an
149149
error is encountered. Does not raise :exc:`KeyError` for missing keys. Raise a
150-
:exc:`TypeError` if the *key* is unhashable. Unlike the Python :meth:`~set.discard`
150+
:exc:`TypeError` if the *key* is unhashable. Unlike the Python :meth:`~frozenset.discard`
151151
method, this function does not automatically convert unhashable sets into
152152
temporary frozensets. Raise :exc:`SystemError` if *set* is not an
153153
instance of :class:`set` or its subtype.

Doc/extending/newtypes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ An interesting advantage of using the :c:member:`~PyTypeObject.tp_members` table
296296
descriptors that are used at runtime is that any attribute defined this way can
297297
have an associated doc string simply by providing the text in the table. An
298298
application can use the introspection API to retrieve the descriptor from the
299-
class object, and get the doc string using its :attr:`__doc__` attribute.
299+
class object, and get the doc string using its :attr:`!__doc__` attribute.
300300

301301
As with the :c:member:`~PyTypeObject.tp_methods` table, a sentinel entry with a :c:member:`~PyMethodDef.ml_name` value
302302
of ``NULL`` is required.

Doc/howto/descriptor.rst

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -521,11 +521,11 @@ everyday Python programs.
521521
Descriptor protocol
522522
-------------------
523523

524-
``descr.__get__(self, obj, type=None) -> value``
524+
``descr.__get__(self, obj, type=None)``
525525

526-
``descr.__set__(self, obj, value) -> None``
526+
``descr.__set__(self, obj, value)``
527527

528-
``descr.__delete__(self, obj) -> None``
528+
``descr.__delete__(self, obj)``
529529

530530
That is all there is to it. Define any of these methods and an object is
531531
considered a descriptor and can override default behavior upon being looked up
@@ -1013,17 +1013,23 @@ here is a pure Python equivalent:
10131013
if obj is None:
10141014
return self
10151015
if self.fget is None:
1016-
raise AttributeError(f"property '{self._name}' has no getter")
1016+
raise AttributeError(
1017+
f'property {self._name!r} of {type(obj).__name__!r} object has no getter'
1018+
)
10171019
return self.fget(obj)
10181020

10191021
def __set__(self, obj, value):
10201022
if self.fset is None:
1021-
raise AttributeError(f"property '{self._name}' has no setter")
1023+
raise AttributeError(
1024+
f'property {self._name!r} of {type(obj).__name__!r} object has no setter'
1025+
)
10221026
self.fset(obj, value)
10231027

10241028
def __delete__(self, obj):
10251029
if self.fdel is None:
1026-
raise AttributeError(f"property '{self._name}' has no deleter")
1030+
raise AttributeError(
1031+
f'property {self._name!r} of {type(obj).__name__!r} object has no deleter'
1032+
)
10271033
self.fdel(obj)
10281034

10291035
def getter(self, fget):
@@ -1054,6 +1060,11 @@ here is a pure Python equivalent:
10541060
def delx(self):
10551061
del self.__x
10561062
x = Property(getx, setx, delx, "I'm the 'x' property.")
1063+
no_getter = Property(None, setx, delx, "I'm the 'x' property.")
1064+
no_setter = Property(getx, None, delx, "I'm the 'x' property.")
1065+
no_deleter = Property(getx, setx, None, "I'm the 'x' property.")
1066+
no_doc = Property(getx, setx, delx, None)
1067+
10571068

10581069
# Now do it again but use the decorator style
10591070

@@ -1092,6 +1103,32 @@ here is a pure Python equivalent:
10921103
>>> hasattr(ccc, 'x')
10931104
False
10941105

1106+
>>> cc = CC()
1107+
>>> cc.x = 33
1108+
>>> try:
1109+
... cc.no_getter
1110+
... except AttributeError as e:
1111+
... e.args[0]
1112+
...
1113+
"property 'no_getter' of 'CC' object has no getter"
1114+
1115+
>>> try:
1116+
... cc.no_setter = 33
1117+
... except AttributeError as e:
1118+
... e.args[0]
1119+
...
1120+
"property 'no_setter' of 'CC' object has no setter"
1121+
1122+
>>> try:
1123+
... del cc.no_deleter
1124+
... except AttributeError as e:
1125+
... e.args[0]
1126+
...
1127+
"property 'no_deleter' of 'CC' object has no deleter"
1128+
1129+
>>> CC.no_doc.__doc__ is None
1130+
True
1131+
10951132
The :func:`property` builtin helps whenever a user interface has granted
10961133
attribute access and then subsequent changes require the intervention of a
10971134
method.

Doc/library/asyncio-stream.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ StreamReader
204204
directly; use :func:`open_connection` and :func:`start_server`
205205
instead.
206206

207+
.. method:: feed_eof()
208+
209+
Acknowledge the EOF.
210+
207211
.. coroutinemethod:: read(n=-1)
208212

209213
Read up to *n* bytes from the stream.

Doc/library/dis.rst

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ interpreter.
5151
transparent for forward jumps but needs to be taken into account when
5252
reasoning about backward jumps.
5353

54+
.. versionchanged:: 3.13
55+
The output shows logical labels rather than instruction offsets
56+
for jump targets and exception handlers. The ``-O`` command line
57+
option and the ``show_offsets`` argument were added.
58+
5459
Example: Given the function :func:`!myfunc`::
5560

5661
def myfunc(alist):
@@ -62,12 +67,12 @@ the following command can be used to display the disassembly of
6267
.. doctest::
6368

6469
>>> dis.dis(myfunc)
65-
2 0 RESUME 0
70+
2 RESUME 0
6671
<BLANKLINE>
67-
3 2 LOAD_GLOBAL 1 (len + NULL)
68-
12 LOAD_FAST 0 (alist)
69-
14 CALL 1
70-
22 RETURN_VALUE
72+
3 LOAD_GLOBAL 1 (len + NULL)
73+
LOAD_FAST 0 (alist)
74+
CALL 1
75+
RETURN_VALUE
7176

7277
(The "2" is a line number).
7378

@@ -80,7 +85,7 @@ The :mod:`dis` module can be invoked as a script from the command line:
8085

8186
.. code-block:: sh
8287
83-
python -m dis [-h] [-C] [infile]
88+
python -m dis [-h] [-C] [-O] [infile]
8489
8590
The following options are accepted:
8691

@@ -94,6 +99,10 @@ The following options are accepted:
9499

95100
Show inline caches.
96101

102+
.. cmdoption:: -O, --show-offsets
103+
104+
Show offsets of instructions.
105+
97106
If :file:`infile` is specified, its disassembled code will be written to stdout.
98107
Otherwise, disassembly is performed on compiled source code recieved from stdin.
99108

@@ -107,7 +116,7 @@ The bytecode analysis API allows pieces of Python code to be wrapped in a
107116
code.
108117

109118
.. class:: Bytecode(x, *, first_line=None, current_offset=None,\
110-
show_caches=False, adaptive=False)
119+
show_caches=False, adaptive=False, show_offsets=False)
111120

112121
Analyse the bytecode corresponding to a function, generator, asynchronous
113122
generator, coroutine, method, string of source code, or a code object (as
@@ -132,6 +141,9 @@ code.
132141
If *adaptive* is ``True``, :meth:`.dis` will display specialized bytecode
133142
that may be different from the original bytecode.
134143

144+
If *show_offsets* is ``True``, :meth:`.dis` will include instruction
145+
offsets in the output.
146+
135147
.. classmethod:: from_traceback(tb, *, show_caches=False)
136148

137149
Construct a :class:`Bytecode` instance from the given traceback, setting
@@ -254,7 +266,8 @@ operation is being performed, so the intermediate analysis object isn't useful:
254266
Added the *show_caches* and *adaptive* parameters.
255267

256268

257-
.. function:: distb(tb=None, *, file=None, show_caches=False, adaptive=False)
269+
.. function:: distb(tb=None, *, file=None, show_caches=False, adaptive=False,
270+
show_offset=False)
258271

259272
Disassemble the top-of-stack function of a traceback, using the last
260273
traceback if none was passed. The instruction causing the exception is
@@ -269,9 +282,12 @@ operation is being performed, so the intermediate analysis object isn't useful:
269282
.. versionchanged:: 3.11
270283
Added the *show_caches* and *adaptive* parameters.
271284

285+
.. versionchanged:: 3.13
286+
Added the *show_offsets* parameter.
272287

273288
.. function:: disassemble(code, lasti=-1, *, file=None, show_caches=False, adaptive=False)
274-
disco(code, lasti=-1, *, file=None, show_caches=False, adaptive=False)
289+
disco(code, lasti=-1, *, file=None, show_caches=False, adaptive=False,
290+
show_offsets=False)
275291
276292
Disassemble a code object, indicating the last instruction if *lasti* was
277293
provided. The output is divided in the following columns:
@@ -296,6 +312,8 @@ operation is being performed, so the intermediate analysis object isn't useful:
296312
.. versionchanged:: 3.11
297313
Added the *show_caches* and *adaptive* parameters.
298314

315+
.. versionchanged:: 3.13
316+
Added the *show_offsets* parameter.
299317

300318
.. function:: get_instructions(x, *, first_line=None, show_caches=False, adaptive=False)
301319

Doc/library/doctest.rst

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,13 @@ Simple Usage: Checking Examples in Docstrings
143143
---------------------------------------------
144144

145145
The simplest way to start using doctest (but not necessarily the way you'll
146-
continue to do it) is to end each module :mod:`M` with::
146+
continue to do it) is to end each module :mod:`!M` with::
147147

148148
if __name__ == "__main__":
149149
import doctest
150150
doctest.testmod()
151151

152-
:mod:`doctest` then examines docstrings in module :mod:`M`.
152+
:mod:`!doctest` then examines docstrings in module :mod:`!M`.
153153

154154
Running the module as a script causes the examples in the docstrings to get
155155
executed and verified::
@@ -403,10 +403,10 @@ What's the Execution Context?
403403
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
404404

405405
By default, each time :mod:`doctest` finds a docstring to test, it uses a
406-
*shallow copy* of :mod:`M`'s globals, so that running tests doesn't change the
407-
module's real globals, and so that one test in :mod:`M` can't leave behind
406+
*shallow copy* of :mod:`!M`'s globals, so that running tests doesn't change the
407+
module's real globals, and so that one test in :mod:`!M` can't leave behind
408408
crumbs that accidentally allow another test to work. This means examples can
409-
freely use any names defined at top-level in :mod:`M`, and names defined earlier
409+
freely use any names defined at top-level in :mod:`!M`, and names defined earlier
410410
in the docstring being run. Examples cannot see names defined in other
411411
docstrings.
412412

@@ -958,7 +958,8 @@ and :ref:`doctest-simple-testfile`.
958958

959959
Optional argument *exclude_empty* defaults to false. If true, objects for which
960960
no doctests are found are excluded from consideration. The default is a backward
961-
compatibility hack, so that code still using :meth:`doctest.master.summarize` in
961+
compatibility hack, so that code still using
962+
:meth:`doctest.master.summarize <DocTestRunner.summarize>` in
962963
conjunction with :func:`testmod` continues to get output for objects with no
963964
tests. The *exclude_empty* argument to the newer :class:`DocTestFinder`
964965
constructor defaults to true.
@@ -997,7 +998,7 @@ As your collection of doctest'ed modules grows, you'll want a way to run all
997998
their doctests systematically. :mod:`doctest` provides two functions that can
998999
be used to create :mod:`unittest` test suites from modules and text files
9991000
containing doctests. To integrate with :mod:`unittest` test discovery, include
1000-
a :func:`load_tests` function in your test module::
1001+
a :ref:`load_tests <load_tests-protocol>` function in your test module::
10011002

10021003
import unittest
10031004
import doctest
@@ -1111,19 +1112,24 @@ from text files and modules with doctests:
11111112
:func:`DocTestSuite` returns an empty :class:`unittest.TestSuite` if *module*
11121113
contains no docstrings instead of raising :exc:`ValueError`.
11131114

1115+
.. exception:: failureException
1116+
1117+
When doctests which have been converted to unit tests by :func:`DocFileSuite`
1118+
or :func:`DocTestSuite` fail, this exception is raised showing the name of
1119+
the file containing the test and a (sometimes approximate) line number.
11141120

11151121
Under the covers, :func:`DocTestSuite` creates a :class:`unittest.TestSuite` out
1116-
of :class:`doctest.DocTestCase` instances, and :class:`DocTestCase` is a
1117-
subclass of :class:`unittest.TestCase`. :class:`DocTestCase` isn't documented
1122+
of :class:`!doctest.DocTestCase` instances, and :class:`!DocTestCase` is a
1123+
subclass of :class:`unittest.TestCase`. :class:`!DocTestCase` isn't documented
11181124
here (it's an internal detail), but studying its code can answer questions about
11191125
the exact details of :mod:`unittest` integration.
11201126

11211127
Similarly, :func:`DocFileSuite` creates a :class:`unittest.TestSuite` out of
1122-
:class:`doctest.DocFileCase` instances, and :class:`DocFileCase` is a subclass
1123-
of :class:`DocTestCase`.
1128+
:class:`!doctest.DocFileCase` instances, and :class:`!DocFileCase` is a subclass
1129+
of :class:`!DocTestCase`.
11241130

11251131
So both ways of creating a :class:`unittest.TestSuite` run instances of
1126-
:class:`DocTestCase`. This is important for a subtle reason: when you run
1132+
:class:`!DocTestCase`. This is important for a subtle reason: when you run
11271133
:mod:`doctest` functions yourself, you can control the :mod:`doctest` options in
11281134
use directly, by passing option flags to :mod:`doctest` functions. However, if
11291135
you're writing a :mod:`unittest` framework, :mod:`unittest` ultimately controls
@@ -1144,14 +1150,14 @@ reporting flags specific to :mod:`unittest` support, via this function:
11441150
section :ref:`doctest-options`. Only "reporting flags" can be used.
11451151

11461152
This is a module-global setting, and affects all future doctests run by module
1147-
:mod:`unittest`: the :meth:`runTest` method of :class:`DocTestCase` looks at
1148-
the option flags specified for the test case when the :class:`DocTestCase`
1153+
:mod:`unittest`: the :meth:`!runTest` method of :class:`!DocTestCase` looks at
1154+
the option flags specified for the test case when the :class:`!DocTestCase`
11491155
instance was constructed. If no reporting flags were specified (which is the
1150-
typical and expected case), :mod:`doctest`'s :mod:`unittest` reporting flags are
1156+
typical and expected case), :mod:`!doctest`'s :mod:`unittest` reporting flags are
11511157
:ref:`bitwise ORed <bitwise>` into the option flags, and the option flags
11521158
so augmented are passed to the :class:`DocTestRunner` instance created to
11531159
run the doctest. If any reporting flags were specified when the
1154-
:class:`DocTestCase` instance was constructed, :mod:`doctest`'s
1160+
:class:`!DocTestCase` instance was constructed, :mod:`!doctest`'s
11551161
:mod:`unittest` reporting flags are ignored.
11561162

11571163
The value of the :mod:`unittest` reporting flags in effect before the function
@@ -1321,7 +1327,8 @@ Example Objects
13211327
A dictionary mapping from option flags to ``True`` or ``False``, which is used
13221328
to override default options for this example. Any option flags not contained
13231329
in this dictionary are left at their default value (as specified by the
1324-
:class:`DocTestRunner`'s :attr:`optionflags`). By default, no options are set.
1330+
:class:`DocTestRunner`'s :ref:`optionflags <doctest-options>`).
1331+
By default, no options are set.
13251332

13261333

13271334
.. _doctest-doctestfinder:
@@ -1560,7 +1567,7 @@ DocTestRunner objects
15601567

15611568
The output of each example is checked using the :class:`DocTestRunner`'s
15621569
output checker, and the results are formatted by the
1563-
:meth:`DocTestRunner.report_\*` methods.
1570+
:meth:`!DocTestRunner.report_\*` methods.
15641571

15651572

15661573
.. method:: summarize(verbose=None)
@@ -1735,12 +1742,12 @@ code under the debugger:
17351742
module) of the object with the doctests of interest. The result is a string,
17361743
containing the object's docstring converted to a Python script, as described for
17371744
:func:`script_from_examples` above. For example, if module :file:`a.py`
1738-
contains a top-level function :func:`f`, then ::
1745+
contains a top-level function :func:`!f`, then ::
17391746

17401747
import a, doctest
17411748
print(doctest.testsource(a, "a.f"))
17421749

1743-
prints a script version of function :func:`f`'s docstring, with doctests
1750+
prints a script version of function :func:`!f`'s docstring, with doctests
17441751
converted to code, and the rest placed in comments.
17451752

17461753

0 commit comments

Comments
 (0)