Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a75cc40

Browse filesBrowse files
committed
Merge branch 'main' into burn-posixsubprocess-with-ac
2 parents e09851f + f5ad63f commit a75cc40
Copy full SHA for a75cc40

File tree

Expand file treeCollapse file tree

139 files changed

+5788
-2653
lines changed
Filter options

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree

139 files changed

+5788
-2653
lines changed

‎.azure-pipelines/ci.yml

Copy file name to clipboardExpand all lines: .azure-pipelines/ci.yml
+4-4Lines 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

Copy file name to clipboardExpand all lines: .azure-pipelines/pr.yml
+4-4Lines 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

Copy file name to clipboardExpand all lines: .github/CODEOWNERS
+3Lines 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 @corona10
12+
1013
# asyncio
1114
**/*asyncio* @1st1 @asvetlov @gvanrossum @kumaraditya303
1215

‎Doc/c-api/long.rst

Copy file name to clipboardExpand all lines: Doc/c-api/long.rst
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
9494
ignored. If there are no digits or *str* is not NULL-terminated following the
9595
digits and trailing whitespace, :exc:`ValueError` will be raised.
9696
97+
.. seealso:: Python methods :meth:`int.to_bytes` and :meth:`int.from_bytes`
98+
to convert a :c:type:`PyLongObject` to/from an array of bytes in base
99+
``256``. You can call those from C using :c:func:`PyObject_CallMethod`.
100+
97101
98102
.. c:function:: PyObject* PyLong_FromUnicodeObject(PyObject *u, int base)
99103

‎Doc/howto/logging-cookbook.rst

Copy file name to clipboardExpand all lines: Doc/howto/logging-cookbook.rst
+31-10Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1982,26 +1982,47 @@ Using a rotator and namer to customize log rotation processing
19821982
--------------------------------------------------------------
19831983

19841984
An example of how you can define a namer and rotator is given in the following
1985-
snippet, which shows zlib-based compression of the log file::
1985+
runnable script, which shows gzip compression of the log file::
1986+
1987+
import gzip
1988+
import logging
1989+
import logging.handlers
1990+
import os
1991+
import shutil
19861992

19871993
def namer(name):
19881994
return name + ".gz"
19891995

19901996
def rotator(source, dest):
1991-
with open(source, "rb") as sf:
1992-
data = sf.read()
1993-
compressed = zlib.compress(data, 9)
1994-
with open(dest, "wb") as df:
1995-
df.write(compressed)
1997+
with open(source, 'rb') as f_in:
1998+
with gzip.open(dest, 'wb') as f_out:
1999+
shutil.copyfileobj(f_in, f_out)
19962000
os.remove(source)
19972001

1998-
rh = logging.handlers.RotatingFileHandler(...)
2002+
2003+
rh = logging.handlers.RotatingFileHandler('rotated.log', maxBytes=128, backupCount=5)
19992004
rh.rotator = rotator
20002005
rh.namer = namer
20012006

2002-
These are not "true" .gz files, as they are bare compressed data, with no
2003-
"container" such as you’d find in an actual gzip file. This snippet is just
2004-
for illustration purposes.
2007+
root = logging.getLogger()
2008+
root.setLevel(logging.INFO)
2009+
root.addHandler(rh)
2010+
f = logging.Formatter('%(asctime)s %(message)s')
2011+
rh.setFormatter(f)
2012+
for i in range(1000):
2013+
root.info(f'Message no. {i + 1}')
2014+
2015+
After running this, you will see six new files, five of which are compressed:
2016+
2017+
.. code-block:: shell-session
2018+
2019+
$ ls rotated.log*
2020+
rotated.log rotated.log.2.gz rotated.log.4.gz
2021+
rotated.log.1.gz rotated.log.3.gz rotated.log.5.gz
2022+
$ zcat rotated.log.1.gz
2023+
2023-01-20 02:28:17,767 Message no. 996
2024+
2023-01-20 02:28:17,767 Message no. 997
2025+
2023-01-20 02:28:17,767 Message no. 998
20052026
20062027
A more elaborate multiprocessing example
20072028
----------------------------------------

‎Doc/library/asyncio.rst

Copy file name to clipboardExpand all lines: Doc/library/asyncio.rst
+12Lines 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

Copy file name to clipboardExpand all lines: Doc/library/ctypes.rst
+15-6Lines changed: 15 additions & 6 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
@@ -1656,12 +1665,12 @@ They are instances of a private class:
16561665
passed arguments.
16571666

16581667

1659-
.. audit-event:: ctypes.seh_exception code foreign-functions
1668+
.. audit-event:: ctypes.set_exception code foreign-functions
16601669

16611670
On Windows, when a foreign function call raises a system exception (for
16621671
example, due to an access violation), it will be captured and replaced with
16631672
a suitable Python exception. Further, an auditing event
1664-
``ctypes.seh_exception`` with argument ``code`` will be raised, allowing an
1673+
``ctypes.set_exception`` with argument ``code`` will be raised, allowing an
16651674
audit hook to replace the exception with its own.
16661675

16671676
.. audit-event:: ctypes.call_function func_pointer,arguments foreign-functions

‎Doc/library/datetime.rst

Copy file name to clipboardExpand all lines: Doc/library/datetime.rst
+4-5Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -982,12 +982,11 @@ Other constructors, all class methods:
982982
are equal to the given :class:`.time` object's. If the *tzinfo*
983983
argument is provided, its value is used to set the :attr:`.tzinfo` attribute
984984
of the result, otherwise the :attr:`~.time.tzinfo` attribute of the *time* argument
985-
is used.
985+
is used. If the *date* argument is a :class:`.datetime` object, its time components
986+
and :attr:`.tzinfo` attributes are ignored.
986987

987988
For any :class:`.datetime` object *d*,
988-
``d == datetime.combine(d.date(), d.time(), d.tzinfo)``. If date is a
989-
:class:`.datetime` object, its time components and :attr:`.tzinfo` attributes
990-
are ignored.
989+
``d == datetime.combine(d.date(), d.time(), d.tzinfo)``.
991990

992991
.. versionchanged:: 3.6
993992
Added the *tzinfo* argument.
@@ -1351,7 +1350,7 @@ Instance methods:
13511350

13521351
Because naive ``datetime`` objects are treated by many ``datetime`` methods
13531352
as local times, it is preferred to use aware datetimes to represent times
1354-
in UTC; as a result, using ``utcfromtimetuple`` may give misleading
1353+
in UTC; as a result, using :meth:`datetime.utctimetuple` may give misleading
13551354
results. If you have a naive ``datetime`` representing UTC, use
13561355
``datetime.replace(tzinfo=timezone.utc)`` to make it aware, at which point
13571356
you can use :meth:`.datetime.timetuple`.

‎Doc/library/dis.rst

Copy file name to clipboardExpand all lines: Doc/library/dis.rst
+13-1Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,10 @@ iterations of the loop.
700700
Yields ``STACK.pop()`` from a :term:`generator`.
701701

702702
.. versionchanged:: 3.11
703-
oparg set to be the stack depth, for efficient handling on frames.
703+
oparg set to be the stack depth.
704+
705+
.. versionchanged:: 3.12
706+
oparg set to be the exception block depth, for efficient closing of generators.
704707

705708

706709
.. opcode:: SETUP_ANNOTATIONS
@@ -1043,6 +1046,15 @@ iterations of the loop.
10431046
``cmp_op[opname]``.
10441047

10451048

1049+
.. opcode:: COMPARE_AND_BRANCH (opname)
1050+
1051+
Compares the top two values on the stack, popping them, then branches.
1052+
The direction and offset of the jump is embedded as a ``POP_JUMP_IF_TRUE``
1053+
or ``POP_JUMP_IF_FALSE`` instruction immediately following the cache.
1054+
1055+
.. versionadded:: 3.12
1056+
1057+
10461058
.. opcode:: IS_OP (invert)
10471059

10481060
Performs ``is`` comparison, or ``is not`` if ``invert`` is 1.

‎Doc/library/enum.rst

Copy file name to clipboardExpand all lines: Doc/library/enum.rst
+13-13Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ are not normal Python classes. See
5252

5353
.. note:: Nomenclature
5454

55-
- The class :class:`Color` is an *enumeration* (or *enum*)
56-
- The attributes :attr:`Color.RED`, :attr:`Color.GREEN`, etc., are
55+
- The class :class:`!Color` is an *enumeration* (or *enum*)
56+
- The attributes :attr:`!Color.RED`, :attr:`!Color.GREEN`, etc., are
5757
*enumeration members* (or *members*) and are functionally constants.
5858
- The enum members have *names* and *values* (the name of
59-
:attr:`Color.RED` is ``RED``, the value of :attr:`Color.BLUE` is
59+
:attr:`!Color.RED` is ``RED``, the value of :attr:`!Color.BLUE` is
6060
``3``, etc.)
6161

6262
---------------
@@ -165,8 +165,8 @@ Data Types
165165
to subclass *EnumType* -- see :ref:`Subclassing EnumType <enumtype-examples>`
166166
for details.
167167

168-
*EnumType* is responsible for setting the correct :meth:`__repr__`,
169-
:meth:`__str__`, :meth:`__format__`, and :meth:`__reduce__` methods on the
168+
*EnumType* is responsible for setting the correct :meth:`!__repr__`,
169+
:meth:`!__str__`, :meth:`!__format__`, and :meth:`!__reduce__` methods on the
170170
final *enum*, as well as creating the enum members, properly handling
171171
duplicates, providing iteration over the enum class, etc.
172172

@@ -424,9 +424,9 @@ Data Types
424424
Using :class:`auto` with :class:`IntEnum` results in integers of increasing
425425
value, starting with ``1``.
426426

427-
.. versionchanged:: 3.11 :meth:`__str__` is now :func:`int.__str__` to
427+
.. versionchanged:: 3.11 :meth:`~object.__str__` is now :meth:`!int.__str__` to
428428
better support the *replacement of existing constants* use-case.
429-
:meth:`__format__` was already :func:`int.__format__` for that same reason.
429+
:meth:`~object.__format__` was already :meth:`!int.__format__` for that same reason.
430430

431431

432432
.. class:: StrEnum
@@ -617,7 +617,7 @@ Data Types
617617

618618
.. class:: ReprEnum
619619

620-
:class:`!ReprEum` uses the :meth:`repr() <Enum.__repr__>` of :class:`Enum`,
620+
:class:`!ReprEnum` uses the :meth:`repr() <Enum.__repr__>` of :class:`Enum`,
621621
but the :class:`str() <str>` of the mixed-in data type:
622622

623623
* :meth:`!int.__str__` for :class:`IntEnum` and :class:`IntFlag`
@@ -761,11 +761,11 @@ Data Types
761761
Supported ``__dunder__`` names
762762
""""""""""""""""""""""""""""""
763763

764-
:attr:`__members__` is a read-only ordered mapping of ``member_name``:``member``
764+
:attr:`~EnumType.__members__` is a read-only ordered mapping of ``member_name``:``member``
765765
items. It is only available on the class.
766766

767-
:meth:`__new__`, if specified, must create and return the enum members; it is
768-
also a very good idea to set the member's :attr:`_value_` appropriately. Once
767+
:meth:`~object.__new__`, if specified, must create and return the enum members; it is
768+
also a very good idea to set the member's :attr:`!_value_` appropriately. Once
769769
all the members are created it is no longer used.
770770

771771

@@ -804,7 +804,7 @@ Utilities and Decorators
804804
.. class:: auto
805805

806806
*auto* can be used in place of a value. If used, the *Enum* machinery will
807-
call an *Enum*'s :meth:`_generate_next_value_` to get an appropriate value.
807+
call an *Enum*'s :meth:`~Enum._generate_next_value_` to get an appropriate value.
808808
For *Enum* and *IntEnum* that appropriate value will be the last value plus
809809
one; for *Flag* and *IntFlag* it will be the first power-of-two greater
810810
than the highest value; for *StrEnum* it will be the lower-cased version of
@@ -847,7 +847,7 @@ Utilities and Decorators
847847
.. decorator:: unique
848848

849849
A :keyword:`class` decorator specifically for enumerations. It searches an
850-
enumeration's :attr:`__members__`, gathering any aliases it finds; if any are
850+
enumeration's :attr:`~EnumType.__members__`, gathering any aliases it finds; if any are
851851
found :exc:`ValueError` is raised with the details::
852852

853853
>>> from enum import Enum, unique

‎Doc/library/fractions.rst

Copy file name to clipboardExpand all lines: Doc/library/fractions.rst
+28Lines 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

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.