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

Skip to content

Commit eb4dc55

Browse files
authored
Merge branch 'main' into t001
2 parents b40f727 + 7b20a0f commit eb4dc55

60 files changed

Lines changed: 1708 additions & 457 deletions

Some content is hidden

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

.azure-pipelines/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
displayName: Pre-build checks
99

1010
pool:
11-
vmImage: ubuntu-20.04
11+
vmImage: ubuntu-22.04
1212

1313
steps:
1414
- template: ./prebuild-checks.yml
@@ -20,7 +20,7 @@ jobs:
2020
condition: and(succeeded(), eq(dependencies.Prebuild.outputs['docs.run'], 'true'))
2121

2222
pool:
23-
vmImage: ubuntu-20.04
23+
vmImage: ubuntu-22.04
2424

2525
steps:
2626
- template: ./docs-steps.yml
@@ -52,7 +52,7 @@ jobs:
5252
condition: and(succeeded(), eq(dependencies.Prebuild.outputs['tests.run'], 'true'))
5353

5454
pool:
55-
vmImage: ubuntu-20.04
55+
vmImage: ubuntu-22.04
5656

5757
variables:
5858
testRunTitle: '$(build.sourceBranchName)-linux'
@@ -78,7 +78,7 @@ jobs:
7878
)
7979
8080
pool:
81-
vmImage: ubuntu-20.04
81+
vmImage: ubuntu-22.04
8282

8383
variables:
8484
testRunTitle: '$(Build.SourceBranchName)-linux-coverage'

.azure-pipelines/pr.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
displayName: Pre-build checks
99

1010
pool:
11-
vmImage: ubuntu-20.04
11+
vmImage: ubuntu-22.04
1212

1313
steps:
1414
- template: ./prebuild-checks.yml
@@ -20,7 +20,7 @@ jobs:
2020
condition: and(succeeded(), eq(dependencies.Prebuild.outputs['docs.run'], 'true'))
2121

2222
pool:
23-
vmImage: ubuntu-20.04
23+
vmImage: ubuntu-22.04
2424

2525
steps:
2626
- template: ./docs-steps.yml
@@ -52,7 +52,7 @@ jobs:
5252
condition: and(succeeded(), eq(dependencies.Prebuild.outputs['tests.run'], 'true'))
5353

5454
pool:
55-
vmImage: ubuntu-20.04
55+
vmImage: ubuntu-22.04
5656

5757
variables:
5858
testRunTitle: '$(system.pullRequest.TargetBranch)-linux'
@@ -78,7 +78,7 @@ jobs:
7878
)
7979
8080
pool:
81-
vmImage: ubuntu-20.04
81+
vmImage: ubuntu-22.04
8282

8383
variables:
8484
testRunTitle: '$(Build.SourceBranchName)-linux-coverage'

.github/CODEOWNERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
# GitHub
88
.github/** @ezio-melotti
99

10+
# Build system
11+
configure* @erlend-aasland
12+
1013
# asyncio
1114
**/*asyncio* @1st1 @asvetlov @gvanrossum @kumaraditya303
1215

Doc/library/asyncio.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,18 @@ Additionally, there are **low-level** APIs for
5656
* :ref:`bridge <asyncio-futures>` callback-based libraries and code
5757
with async/await syntax.
5858

59+
You can experiment with an ``asyncio`` concurrent context in the REPL:
60+
61+
.. code-block:: pycon
62+
63+
$ python -m asyncio
64+
asyncio REPL ...
65+
Use "await" directly instead of "asyncio.run()".
66+
Type "help", "copyright", "credits" or "license" for more information.
67+
>>> import asyncio
68+
>>> await asyncio.sleep(10, result='hello')
69+
'hello'
70+
5971
.. include:: ../includes/wasm-notavail.rst
6072

6173
.. We use the "rubric" directive here to avoid creating

Doc/library/ctypes.rst

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,14 @@ integer, string, bytes, a :mod:`ctypes` instance, or an object with an
466466
Return types
467467
^^^^^^^^^^^^
468468

469+
.. testsetup::
470+
471+
from ctypes import CDLL, c_char, c_char_p
472+
from ctypes.util import find_library
473+
libc = CDLL(find_library('c'))
474+
strchr = libc.strchr
475+
476+
469477
By default functions are assumed to return the C :c:expr:`int` type. Other
470478
return types can be specified by setting the :attr:`restype` attribute of the
471479
function object.
@@ -502,18 +510,19 @@ If you want to avoid the ``ord("x")`` calls above, you can set the
502510
:attr:`argtypes` attribute, and the second argument will be converted from a
503511
single character Python bytes object into a C char::
504512

513+
.. doctest::
514+
505515
>>> strchr.restype = c_char_p
506516
>>> strchr.argtypes = [c_char_p, c_char]
507517
>>> strchr(b"abcdef", b"d")
508-
'def'
518+
b'def'
509519
>>> strchr(b"abcdef", b"def")
510520
Traceback (most recent call last):
511-
File "<stdin>", line 1, in <module>
512-
ArgumentError: argument 2: TypeError: one character string expected
521+
ctypes.ArgumentError: argument 2: TypeError: one character bytes, bytearray or integer expected
513522
>>> print(strchr(b"abcdef", b"x"))
514523
None
515524
>>> strchr(b"abcdef", b"d")
516-
'def'
525+
b'def'
517526
>>>
518527

519528
You can also use a callable Python object (a function or a class for example) as

Doc/library/fractions.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ another rational number, or from a string.
101101
.. versionchanged:: 3.12
102102
Space is allowed around the slash for string inputs: ``Fraction('2 / 3')``.
103103

104+
.. versionchanged:: 3.12
105+
:class:`Fraction` instances now support float-style formatting, with
106+
presentation types ``"e"``, ``"E"``, ``"f"``, ``"F"``, ``"g"``, ``"G"``
107+
and ``"%""``.
108+
104109
.. attribute:: numerator
105110

106111
Numerator of the Fraction in lowest term.
@@ -193,6 +198,29 @@ another rational number, or from a string.
193198
``ndigits`` is negative), again rounding half toward even. This
194199
method can also be accessed through the :func:`round` function.
195200

201+
.. method:: __format__(format_spec, /)
202+
203+
Provides support for float-style formatting of :class:`Fraction`
204+
instances via the :meth:`str.format` method, the :func:`format` built-in
205+
function, or :ref:`Formatted string literals <f-strings>`. The
206+
presentation types ``"e"``, ``"E"``, ``"f"``, ``"F"``, ``"g"``, ``"G"``
207+
and ``"%"`` are supported. For these presentation types, formatting for a
208+
:class:`Fraction` object ``x`` follows the rules outlined for
209+
the :class:`float` type in the :ref:`formatspec` section.
210+
211+
Here are some examples::
212+
213+
>>> from fractions import Fraction
214+
>>> format(Fraction(1, 7), '.40g')
215+
'0.1428571428571428571428571428571428571429'
216+
>>> format(Fraction('1234567.855'), '_.2f')
217+
'1_234_567.86'
218+
>>> f"{Fraction(355, 113):*>20.6e}"
219+
'********3.141593e+00'
220+
>>> old_price, new_price = 499, 672
221+
>>> "{:.2%} price increase".format(Fraction(new_price, old_price) - 1)
222+
'34.67% price increase'
223+
196224

197225
.. seealso::
198226

Doc/library/io.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,8 +1021,8 @@ Text I/O
10211021

10221022
.. versionadded:: 3.7
10231023

1024-
.. method:: reconfigure(*[, encoding][, errors][, newline][, \
1025-
line_buffering][, write_through])
1024+
.. method:: reconfigure(*, encoding=None, errors=None, newline=None, \
1025+
line_buffering=None, write_through=None)
10261026

10271027
Reconfigure this text stream using new settings for *encoding*,
10281028
*errors*, *newline*, *line_buffering* and *write_through*.

Doc/library/optparse.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ Other actions
404404
Some other actions supported by :mod:`optparse` are:
405405

406406
``"store_const"``
407-
store a constant value
407+
store a constant value, pre-set via :attr:`Option.const`
408408

409409
``"append"``
410410
append this option's argument to a list
@@ -925,7 +925,7 @@ The canonical way to create an :class:`Option` instance is with the
925925
store this option's argument (default)
926926

927927
``"store_const"``
928-
store a constant value
928+
store a constant value, pre-set via :attr:`Option.const`
929929

930930
``"store_true"``
931931
store ``True``
@@ -937,7 +937,7 @@ The canonical way to create an :class:`Option` instance is with the
937937
append this option's argument to a list
938938

939939
``"append_const"``
940-
append a constant value to a list
940+
append a constant value to a list, pre-set via :attr:`Option.const`
941941

942942
``"count"``
943943
increment a counter by one

Doc/library/pathlib.rst

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ Accessing individual parts
266266
To access the individual "parts" (components) of a path, use the following
267267
property:
268268

269-
.. data:: PurePath.parts
269+
.. attribute:: PurePath.parts
270270

271271
A tuple giving access to the path's various components::
272272

@@ -290,7 +290,7 @@ Methods and properties
290290

291291
Pure paths provide the following methods and properties:
292292

293-
.. data:: PurePath.drive
293+
.. attribute:: PurePath.drive
294294

295295
A string representing the drive letter or name, if any::
296296

@@ -306,7 +306,7 @@ Pure paths provide the following methods and properties:
306306
>>> PureWindowsPath('//host/share/foo.txt').drive
307307
'\\\\host\\share'
308308

309-
.. data:: PurePath.root
309+
.. attribute:: PurePath.root
310310

311311
A string representing the (local or global) root, if any::
312312

@@ -342,7 +342,7 @@ Pure paths provide the following methods and properties:
342342
an implementation-defined manner, although more than two leading slashes
343343
shall be treated as a single slash."*
344344

345-
.. data:: PurePath.anchor
345+
.. attribute:: PurePath.anchor
346346

347347
The concatenation of the drive and root::
348348

@@ -356,7 +356,7 @@ Pure paths provide the following methods and properties:
356356
'\\\\host\\share\\'
357357

358358

359-
.. data:: PurePath.parents
359+
.. attribute:: PurePath.parents
360360

361361
An immutable sequence providing access to the logical ancestors of
362362
the path::
@@ -372,7 +372,7 @@ Pure paths provide the following methods and properties:
372372
.. versionchanged:: 3.10
373373
The parents sequence now supports :term:`slices <slice>` and negative index values.
374374

375-
.. data:: PurePath.parent
375+
.. attribute:: PurePath.parent
376376

377377
The logical parent of the path::
378378

@@ -401,7 +401,7 @@ Pure paths provide the following methods and properties:
401401
symlinks and eliminate ``".."`` components.
402402

403403

404-
.. data:: PurePath.name
404+
.. attribute:: PurePath.name
405405

406406
A string representing the final path component, excluding the drive and
407407
root, if any::
@@ -417,7 +417,7 @@ Pure paths provide the following methods and properties:
417417
''
418418

419419

420-
.. data:: PurePath.suffix
420+
.. attribute:: PurePath.suffix
421421

422422
The file extension of the final component, if any::
423423

@@ -429,7 +429,7 @@ Pure paths provide the following methods and properties:
429429
''
430430

431431

432-
.. data:: PurePath.suffixes
432+
.. attribute:: PurePath.suffixes
433433

434434
A list of the path's file extensions::
435435

@@ -441,7 +441,7 @@ Pure paths provide the following methods and properties:
441441
[]
442442

443443

444-
.. data:: PurePath.stem
444+
.. attribute:: PurePath.stem
445445

446446
The final path component, without its suffix::
447447

@@ -1270,7 +1270,8 @@ call fails (for example because the path doesn't exist).
12701270
.. method:: Path.rglob(pattern)
12711271

12721272
Glob the given relative *pattern* recursively. This is like calling
1273-
:func:`Path.glob` with "``**/``" added in front of the *pattern*::
1273+
:func:`Path.glob` with "``**/``" added in front of the *pattern*, where
1274+
*patterns* are the same as for :mod:`fnmatch`::
12741275

12751276
>>> sorted(Path().rglob("*.py"))
12761277
[PosixPath('build/lib/pathlib.py'),
@@ -1445,11 +1446,11 @@ Below is a table mapping various :mod:`os` functions to their corresponding
14451446
:meth:`Path.group`
14461447
:func:`os.path.isabs` :meth:`PurePath.is_absolute`
14471448
:func:`os.path.join` :func:`PurePath.joinpath`
1448-
:func:`os.path.basename` :data:`PurePath.name`
1449-
:func:`os.path.dirname` :data:`PurePath.parent`
1449+
:func:`os.path.basename` :attr:`PurePath.name`
1450+
:func:`os.path.dirname` :attr:`PurePath.parent`
14501451
:func:`os.path.samefile` :meth:`Path.samefile`
1451-
:func:`os.path.splitext` :data:`PurePath.stem` and
1452-
:data:`PurePath.suffix`
1452+
:func:`os.path.splitext` :attr:`PurePath.stem` and
1453+
:attr:`PurePath.suffix`
14531454
==================================== ==============================
14541455

14551456
.. rubric:: Footnotes

Doc/library/random.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ lognormal, negative exponential, gamma, and beta distributions. For generating
2121
distributions of angles, the von Mises distribution is available.
2222

2323
Almost all module functions depend on the basic function :func:`.random`, which
24-
generates a random float uniformly in the semi-open range [0.0, 1.0). Python
25-
uses the Mersenne Twister as the core generator. It produces 53-bit precision
24+
generates a random float uniformly in the half-open range ``0.0 <= X < 1.0``.
25+
Python uses the Mersenne Twister as the core generator. It produces 53-bit precision
2626
floats and has a period of 2\*\*19937-1. The underlying implementation in C is
2727
both fast and threadsafe. The Mersenne Twister is one of the most extensively
2828
tested random number generators in existence. However, being completely
@@ -294,7 +294,7 @@ be found in any statistics text.
294294

295295
.. function:: random()
296296

297-
Return the next random floating point number in the range [0.0, 1.0).
297+
Return the next random floating point number in the range ``0.0 <= X < 1.0``
298298

299299

300300
.. function:: uniform(a, b)

0 commit comments

Comments
 (0)