8000 Merge branch 'main' into gh-101000-splitroot · barneygale/cpython@df17269 · GitHub
[go: up one dir, main page]

Skip to content

Commit df17269

Browse files
authored
Merge branch 'main' into pythongh-101000-splitroot
2 parents 1c522c9 + 997073c commit df17269

File tree

152 files changed

+4684
-2311
lines changed

Some content is hidden

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

152 files changed

+4684
-2311
lines changed

.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/howto/logging-cookbook.rst

Lines 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-eventloop.rst

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ an event loop:
4848
running event loop.
4949

5050
If there is no running event loop set, the function will return
51-
the result of calling ``get_event_loop_policy().get_event_loop()``.
51+
the result of the ``get_event_loop_policy().get_event_loop()`` call.
5252

5353
Because this function has rather complex behavior (especially
5454
when custom event loop policies are in use), using the
@@ -59,11 +59,9 @@ an event loop:
5959
instead of using these lower level functions to manually create and close an
6060
event loop.
6161

62-
.. note::
63-
In Python versions 3.10.0--3.10.8 and 3.11.0 this function
64-
(and other functions which used it implicitly) emitted a
65-
:exc:`DeprecationWarning` if there was no running event loop, even if
66-
the current loop was set.
62+
.. deprecated:: 3.12
63+
Deprecation warning is emitted if there is no current event loop.
64+
In some future Python release this will become an error.
6765

6866
.. function:: set_event_loop(loop)
6967

Doc/library/asyncio-policy.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,11 @@ asyncio ships with the following built-in policies:
116116

117117
On Windows, :class:`ProactorEventLoop` is now used by default.
118118

119-
.. versionchanged:: 3.12
120-
:meth:`get_event_loop` now raises a :exc:`RuntimeError` if there is no
121-
current event loop set.
119+
.. deprecated:: 3.12
120+
The :meth:`get_event_loop` method of the default asyncio policy now emits
121+
a :exc:`DeprecationWarning` if there is no current event loop set and it
122+
decides to create one.
123+
In some future Python release this will become an error.
122124

123125

124126
.. class:: WindowsSelectorEventLoopPolicy

Doc/library/ctypes.rst

Lines 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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1351,7 +1351,7 @@ Instance methods:
13511351

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

Doc/library/dis.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,6 +1043,15 @@ iterations of the loop.
10431043
``cmp_op[opname]``.
10441044

10451045

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

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

Doc/library/email.mime.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ Here are the classes:
114114

115115
A subclass of :class:`~email.mime.nonmultipart.MIMENonMultipart`, the
116116
:class:`MIMEApplication` class is used to represent MIME message objects of
117-
major type :mimetype:`application`. *_data* is a string containing the raw
118-
byte data. Optional *_subtype* specifies the MIME subtype and defaults to
119-
:mimetype:`octet-stream`.
117+
major type :mimetype:`application`. *_data* contains the bytes for the raw
118+
application data. Optional *_subtype* specifies the MIME subtype and defaults
119+
to :mimetype:`octet-stream`.
120120

121121
Optional *_encoder* is a callable (i.e. function) which will perform the actual
122122
encoding of the data for transport. This callable takes one argument, which is
@@ -145,7 +145,7 @@ Here are the classes:
145145

146146
A subclass of :class:`~email.mime.nonmultipart.MIMENonMultipart`, the
147147
:class:`MIMEAudio` class is used to create MIME message objects of major type
148-
:mimetype:`audio`. *_audiodata* is a string containing the raw audio data. If
148+
:mimetype:`audio`. *_audiodata* contains the bytes for the raw audio data. If
149149
this data can be decoded as au, wav, aiff, or aifc, then the
150150
subtype will be automatically included in the :mailheader:`Content-Type` header.
151151
Otherwise you can explicitly specify the audio subtype via the *_subtype*
@@ -179,7 +179,7 @@ Here are the classes:
179179

180180
A subclass of :class:`~email.mime.nonmultipart.MIMENonMultipart`, the
181181
:class:`MIMEImage` class is used to create MIME message objects of major type
182-
:mimetype:`image`. *_imagedata* is a string containing the raw image data. If
182+
:mimetype:`image`. *_imagedata* contains the bytes for the raw image data. If
183183
this data type can be detected (jpeg, png, gif, tiff, rgb, pbm, pgm, ppm,
184184
rast, xbm, bmp, webp, and exr attempted), then the subtype will be
185185
automatically included in the :mailheader:`Content-Type` header. Otherwise

0 commit comments

Comments
 (0)
0