Skip to content

Commit e1c9731

Browse files
authored
Merge branch 'main' into pythongh-73435-pathlib-match-recursive
2 parents 0741950 + a99eb5c commit e1c9731

Some content is hidden

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

69 files changed

+1238
-944
lines changed

.github/workflows/build.yml

+10-3
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,19 @@ jobs:
157157
PYTHONSTRICTEXTENSIONBUILD: 1
158158
steps:
159159
- uses: actions/checkout@v3
160-
- name: Prepare homebrew environment variables
160+
- name: Install Homebrew dependencies
161+
run: brew install pkg-config openssl@1.1 xz gdbm tcl-tk
162+
- name: Prepare Homebrew environment variables
161163
run: |
162-
echo "LDFLAGS=-L$(brew --prefix tcl-tk)/lib" >> $GITHUB_ENV
164+
echo "CFLAGS=-I$(brew --prefix gdbm)/include -I$(brew --prefix xz)/include" >> $GITHUB_ENV
165+
echo "LDFLAGS=-L$(brew --prefix gdbm)/lib -I$(brew --prefix xz)/lib" >> $GITHUB_ENV
163166
echo "PKG_CONFIG_PATH=$(brew --prefix openssl@1.1)/lib/pkgconfig:$(brew --prefix tcl-tk)/lib/pkgconfig" >> $GITHUB_ENV
164167
- name: Configure CPython
165-
run: ./configure --with-pydebug --prefix=/opt/python-dev
168+
run: |
169+
./configure \
170+
--with-pydebug \
171+
--prefix=/opt/python-dev \
172+
--with-openssl="$(brew --prefix openssl@1.1)"
166173
- name: Build CPython
167174
run: make -j4
168175
- name: Display build info

Doc/c-api/exceptions.rst

+17-32
Original file line numberDiff line numberDiff line change
@@ -402,51 +402,36 @@ Querying the error indicator
402402
403403
.. c:function:: PyObject *PyErr_GetRaisedException(void)
404404
405-
Returns the exception currently being raised, clearing the exception at
406-
the same time. Do not confuse this with the exception currently being
407-
handled which can be accessed with :c:func:`PyErr_GetHandledException`.
405+
Return the exception currently being raised, clearing the error indicator at
406+
the same time.
408407
409-
.. note::
408+
This function is used by code that needs to catch exceptions,
409+
or code that needs to save and restore the error indicator temporarily.
410410
411-
This function is normally only used by code that needs to catch exceptions or
412-
by code that needs to save and restore the error indicator temporarily, e.g.::
411+
For example::
413412
414-
{
415-
PyObject *exc = PyErr_GetRaisedException();
413+
{
414+
PyObject *exc = PyErr_GetRaisedException();
416415
417-
/* ... code that might produce other errors ... */
416+
/* ... code that might produce other errors ... */
418417
419-
PyErr_SetRaisedException(exc);
420-
}
418+
PyErr_SetRaisedException(exc);
419+
}
420+
421+
.. seealso:: :c:func:`PyErr_GetHandledException`,
422+
to save the exception currently being handled.
421423
422424
.. versionadded:: 3.12
423425
424426
425427
.. c:function:: void PyErr_SetRaisedException(PyObject *exc)
426428
427-
Sets the exception currently being raised ``exc``.
428-
If the exception is already set, it is cleared first.
429-
430-
``exc`` must be a valid exception.
431-
(Violating this rules will cause subtle problems later.)
432-
This call consumes a reference to the ``exc`` object: you must own a
433-
reference to that object before the call and after the call you no longer own
434-
that reference.
435-
(If you don't understand this, don't use this function. I warned you.)
429+
Set *exc* as the exception currently being raised,
430+
clearing the existing exception if one is set.
436431
437-
.. note::
438-
439-
This function is normally only used by code that needs to save and restore the
440-
error indicator temporarily. Use :c:func:`PyErr_GetRaisedException` to save
441-
the current exception, e.g.::
442-
443-
{
444-
PyObject *exc = PyErr_GetRaisedException();
445-
446-
/* ... code that might produce other errors ... */
432+
.. warning::
447433
448-
PyErr_SetRaisedException(exc);
449-
}
434+
This call steals a reference to *exc*, which must be a valid exception.
450435
451436
.. versionadded:: 3.12
452437

Doc/data/refcounts.dat

+3
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,9 @@ PyErr_GetExcInfo:PyObject**:ptype:+1:
606606
PyErr_GetExcInfo:PyObject**:pvalue:+1:
607607
PyErr_GetExcInfo:PyObject**:ptraceback:+1:
608608

609+
PyErr_GetRaisedException:PyObject*::+1:
610+
PyErr_SetRaisedException::::
611+
609612
PyErr_GivenExceptionMatches:int:::
610613
PyErr_GivenExceptionMatches:PyObject*:given:0:
611614
PyErr_GivenExceptionMatches:PyObject*:exc:0:

Doc/library/argparse.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1867,7 +1867,7 @@ Sub-commands
18671867
...
18681868
>>> # create the top-level parser
18691869
>>> parser = argparse.ArgumentParser()
1870-
>>> subparsers = parser.add_subparsers()
1870+
>>> subparsers = parser.add_subparsers(required=True)
18711871
>>>
18721872
>>> # create the parser for the "foo" command
18731873
>>> parser_foo = subparsers.add_parser('foo')

Doc/library/asyncio-stream.rst

+10-2
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,20 @@ StreamReader
206206

207207
.. coroutinemethod:: read(n=-1)
208208

209-
Read up to *n* bytes. If *n* is not provided, or set to ``-1``,
210-
read until EOF and return all read bytes.
209+
Read up to *n* bytes from the stream.
211210

211+
If *n* is not provided or set to ``-1``,
212+
read until EOF, then return all read :class:`bytes`.
212213
If EOF was received and the internal buffer is empty,
213214
return an empty ``bytes`` object.
214215

216+
If *n* is ``0``, return an empty ``bytes`` object immediately.
217+
218+
If *n* is positive, return at most *n* available ``bytes``
219+
as soon as at least 1 byte is available in the internal buffer.
220+
If EOF is received before any byte is read, return an empty
221+
``bytes`` object.
222+
215223
.. coroutinemethod:: readline()
216224

217225
Read one line, where "line" is a sequence of bytes

Doc/library/cmath.rst

+38-28
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,27 @@ the function is then applied to the result of the conversion.
1515

1616
.. note::
1717

18-
On platforms with hardware and system-level support for signed
19-
zeros, functions involving branch cuts are continuous on *both*
20-
sides of the branch cut: the sign of the zero distinguishes one
21-
side of the branch cut from the other. On platforms that do not
22-
support signed zeros the continuity is as specified below.
18+
For functions involving branch cuts, we have the problem of deciding how to
19+
define those functions on the cut itself. Following Kahan's "Branch cuts for
20+
complex elementary functions" paper, as well as Annex G of C99 and later C
21+
standards, we use the sign of zero to distinguish one side of the branch cut
22+
from the other: for a branch cut along (a portion of) the real axis we look
23+
at the sign of the imaginary part, while for a branch cut along the
24+
imaginary axis we look at the sign of the real part.
25+
26+
For example, the :func:`cmath.sqrt` function has a branch cut along the
27+
negative real axis. An argument of ``complex(-2.0, -0.0)`` is treated as
28+
though it lies *below* the branch cut, and so gives a result on the negative
29+
imaginary axis::
30+
31+
>>> cmath.sqrt(complex(-2.0, -0.0))
32+
-1.4142135623730951j
33+
34+
But an argument of ``complex(-2.0, 0.0)`` is treated as though it lies above
35+
the branch cut::
36+
37+
>>> cmath.sqrt(complex(-2.0, 0.0))
38+
1.4142135623730951j
2339

2440

2541
Conversions to and from polar coordinates
@@ -44,14 +60,11 @@ rectangular coordinates to polar coordinates and back.
4460

4561
.. function:: phase(x)
4662

47-
Return the phase of *x* (also known as the *argument* of *x*), as a
48-
float. ``phase(x)`` is equivalent to ``math.atan2(x.imag,
49-
x.real)``. The result lies in the range [-\ *π*, *π*], and the branch
50-
cut for this operation lies along the negative real axis,
51-
continuous from above. On systems with support for signed zeros
52-
(which includes most systems in current use), this means that the
53-
sign of the result is the same as the sign of ``x.imag``, even when
54-
``x.imag`` is zero::
63+
Return the phase of *x* (also known as the *argument* of *x*), as a float.
64+
``phase(x)`` is equivalent to ``math.atan2(x.imag, x.real)``. The result
65+
lies in the range [-\ *π*, *π*], and the branch cut for this operation lies
66+
along the negative real axis. The sign of the result is the same as the
67+
sign of ``x.imag``, even when ``x.imag`` is zero::
5568

5669
>>> phase(complex(-1.0, 0.0))
5770
3.141592653589793
@@ -92,8 +105,8 @@ Power and logarithmic functions
92105
.. function:: log(x[, base])
93106

94107
Returns the logarithm of *x* to the given *base*. If the *base* is not
95-
specified, returns the natural logarithm of *x*. There is one branch cut, from 0
96-
along the negative real axis to -∞, continuous from above.
108+
specified, returns the natural logarithm of *x*. There is one branch cut,
109+
from 0 along the negative real axis to -∞.
97110

98111

99112
.. function:: log10(x)
@@ -112,9 +125,9 @@ Trigonometric functions
112125

113126
.. function:: acos(x)
114127

115-
Return the arc cosine of *x*. There are two branch cuts: One extends right from
116-
1 along the real axis to ∞, continuous from below. The other extends left from
117-
-1 along the real axis to -∞, continuous from above.
128+
Return the arc cosine of *x*. There are two branch cuts: One extends right
129+
from 1 along the real axis to ∞. The other extends left from -1 along the
130+
real axis to -∞.
118131

119132

120133
.. function:: asin(x)
@@ -125,9 +138,8 @@ Trigonometric functions
125138
.. function:: atan(x)
126139

127140
Return the arc tangent of *x*. There are two branch cuts: One extends from
128-
``1j`` along the imaginary axis to ``∞j``, continuous from the right. The
129-
other extends from ``-1j`` along the imaginary axis to ``-∞j``, continuous
130-
from the left.
141+
``1j`` along the imaginary axis to ``∞j``. The other extends from ``-1j``
142+
along the imaginary axis to ``-∞j``.
131143

132144

133145
.. function:: cos(x)
@@ -151,23 +163,21 @@ Hyperbolic functions
151163
.. function:: acosh(x)
152164

153165
Return the inverse hyperbolic cosine of *x*. There is one branch cut,
154-
extending left from 1 along the real axis to -∞, continuous from above.
166+
extending left from 1 along the real axis to -∞.
155167

156168

157169
.. function:: asinh(x)
158170

159171
Return the inverse hyperbolic sine of *x*. There are two branch cuts:
160-
One extends from ``1j`` along the imaginary axis to ``∞j``,
161-
continuous from the right. The other extends from ``-1j`` along
162-
the imaginary axis to ``-∞j``, continuous from the left.
172+
One extends from ``1j`` along the imaginary axis to ``∞j``. The other
173+
extends from ``-1j`` along the imaginary axis to ``-∞j``.
163174

164175

165176
.. function:: atanh(x)
166177

167178
Return the inverse hyperbolic tangent of *x*. There are two branch cuts: One
168-
extends from ``1`` along the real axis to ````, continuous from below. The
169-
other extends from ``-1`` along the real axis to ``-∞``, continuous from
170-
above.
179+
extends from ``1`` along the real axis to ````. The other extends from
180+
``-1`` along the real axis to ``-∞``.
171181

172182

173183
.. function:: cosh(x)

Doc/library/csv.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ Reader objects have the following public attributes:
458458

459459
DictReader objects have the following public attribute:
460460

461-
.. attribute:: csvreader.fieldnames
461+
.. attribute:: DictReader.fieldnames
462462

463463
If not passed as a parameter when creating the object, this attribute is
464464
initialized upon first access or when the first record is read from the

Doc/library/enum.rst

+8-9
Original file line numberDiff line numberDiff line change
@@ -696,10 +696,9 @@ Data Types
696696

697697
.. attribute:: STRICT
698698

699-
Out-of-range values cause a :exc:`ValueError` to be raised. This is the
700-
default for :class:`Flag`::
699+
Out-of-range values cause a :exc:`ValueError` to be raised::
701700

702-
>>> from enum import Flag, STRICT
701+
>>> from enum import Flag, STRICT, auto
703702
>>> class StrictFlag(Flag, boundary=STRICT):
704703
... RED = auto()
705704
... GREEN = auto()
@@ -715,9 +714,9 @@ Data Types
715714
.. attribute:: CONFORM
716715

717716
Out-of-range values have invalid values removed, leaving a valid *Flag*
718-
value::
717+
value. This is the default for :class:`Flag`::
719718

720-
>>> from enum import Flag, CONFORM
719+
>>> from enum import Flag, CONFORM, auto
721720
>>> class ConformFlag(Flag, boundary=CONFORM):
722721
... RED = auto()
723722
... GREEN = auto()
@@ -731,7 +730,7 @@ Data Types
731730
Out-of-range values lose their *Flag* membership and revert to :class:`int`.
732731
This is the default for :class:`IntFlag`::
733732

734-
>>> from enum import Flag, EJECT
733+
>>> from enum import Flag, EJECT, auto
735734
>>> class EjectFlag(Flag, boundary=EJECT):
736735
... RED = auto()
737736
... GREEN = auto()
@@ -742,10 +741,10 @@ Data Types
742741

743742
.. attribute:: KEEP
744743

745-
Out-of-range values are kept, and the *Flag* membership is kept. This is
746-
used for some stdlib flags:
744+
Out-of-range values are kept, and the *Flag* membership is kept. This is
745+
used for some stdlib flags::
747746

748-
>>> from enum import Flag, KEEP
747+
>>> from enum import Flag, KEEP, auto
749748
>>> class KeepFlag(Flag, boundary=KEEP):
750749
... RED = auto()
751750
... GREEN = auto()

Doc/library/functions.rst

+3
Original file line numberDiff line numberDiff line change
@@ -1635,6 +1635,9 @@ are always available. They are listed here in alphabetical order.
16351635
example: ``a[start:stop:step]`` or ``a[start:stop, i]``. See
16361636
:func:`itertools.islice` for an alternate version that returns an iterator.
16371637

1638+
.. versionchanged:: 3.12
1639+
Slice objects are now :term:`hashable` (provided :attr:`~slice.start`,
1640+
:attr:`~slice.stop`, and :attr:`~slice.step` are hashable).
16381641

16391642
.. function:: sorted(iterable, /, *, key=None, reverse=False)
16401643

Doc/library/plistlib.rst

+15-6
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ Examples
159159

160160
Generating a plist::
161161

162+
import datetime
163+
import plistlib
164+
162165
pl = dict(
163166
aString = "Doodah",
164167
aList = ["A", "B", 12, 32.1, [1, 2, 3]],
@@ -172,13 +175,19 @@ Generating a plist::
172175
),
173176
someData = b"<binary gunk>",
174177
someMoreData = b"<lots of binary gunk>" * 10,
175-
aDate = datetime.datetime.fromtimestamp(time.mktime(time.gmtime())),
178+
aDate = datetime.datetime.now()
176179
)
177-
with open(fileName, 'wb') as fp:
178-
dump(pl, fp)
180+
print(plistlib.dumps(pl).decode())
179181

180182
Parsing a plist::
181183

182-
with open(fileName, 'rb') as fp:
183-
pl = load(fp)
184-
print(pl["aKey"])
184+
import plistlib
185+
186+
plist = b"""<plist version="1.0">
187+
<dict>
188+
<key>foo</key>
189+
<string>bar</string>
190+
</dict>
191+
</plist>"""
192+
pl = plistlib.loads(plist)
193+
print(pl["foo"])

Doc/library/urllib.error.rst

+12-1
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,19 @@ The following exceptions are raised by :mod:`urllib.error` as appropriate:
3131
of :exc:`IOError`.
3232

3333

34-
.. exception:: HTTPError
34+
.. exception:: HTTPError(url, code, msg, hdrs, fp)
3535

3636
Though being an exception (a subclass of :exc:`URLError`), an
3737
:exc:`HTTPError` can also function as a non-exceptional file-like return
3838
value (the same thing that :func:`~urllib.request.urlopen` returns). This
3939
is useful when handling exotic HTTP errors, such as requests for
4040
authentication.
4141

42+
.. attribute:: url
43+
44+
Contains the request URL.
45+
An alias for *filename* attribute.
46+
4247
.. attribute:: code
4348

4449
An HTTP status code as defined in :rfc:`2616`. This numeric value corresponds
@@ -48,14 +53,20 @@ The following exceptions are raised by :mod:`urllib.error` as appropriate:
4853
.. attribute:: reason
4954

5055
This is usually a string explaining the reason for this error.
56+
An alias for *msg* attribute.
5157

5258
.. attribute:: headers
5359

5460
The HTTP response headers for the HTTP request that caused the
5561
:exc:`HTTPError`.
62+
An alias for *hdrs* attribute.
5663

5764
.. versionadded:: 3.4
5865

66+
.. attribute:: fp
67+
68+
A file-like object where the HTTP error body can be read from.
69+
5970
.. exception:: ContentTooShortError(msg, content)
6071

6172
This exception is raised when the :func:`~urllib.request.urlretrieve`

0 commit comments

Comments
 (0)