Skip to content

Commit baf4722

Browse files
committed
Merge branch 'main' into specialize-for-iter-range
2 parents 7553e10 + b150b6a commit baf4722

Some content is hidden

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

42 files changed

+1351
-866
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ Tools/unicode/data/
131131
/autom4te.cache
132132
/build/
133133
/builddir/
134+
/compile_commands.json
134135
/config.cache
135136
/config.log
136137
/config.status

Doc/c-api/exceptions.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,7 @@ the variables:
982982
983983
.. index::
984984
single: PyExc_BaseException (C var)
985+
single: PyExc_BaseExceptionGroup (C var)
985986
single: PyExc_Exception (C var)
986987
single: PyExc_ArithmeticError (C var)
987988
single: PyExc_AssertionError (C var)
@@ -1041,6 +1042,8 @@ the variables:
10411042
+=========================================+=================================+==========+
10421043
| :c:data:`PyExc_BaseException` | :exc:`BaseException` | [1]_ |
10431044
+-----------------------------------------+---------------------------------+----------+
1045+
| :c:data:`PyExc_BaseExceptionGroup` | :exc:`BaseExceptionGroup` | [1]_ |
1046+
+-----------------------------------------+---------------------------------+----------+
10441047
| :c:data:`PyExc_Exception` | :exc:`Exception` | [1]_ |
10451048
+-----------------------------------------+---------------------------------+----------+
10461049
| :c:data:`PyExc_ArithmeticError` | :exc:`ArithmeticError` | [1]_ |
@@ -1164,6 +1167,9 @@ the variables:
11641167
.. versionadded:: 3.6
11651168
:c:data:`PyExc_ModuleNotFoundError`.
11661169
1170+
.. versionadded:: 3.11
1171+
:c:data:`PyExc_BaseExceptionGroup`.
1172+
11671173
These are compatibility aliases to :c:data:`PyExc_OSError`:
11681174
11691175
.. index::
@@ -1207,6 +1213,7 @@ the variables:
12071213
single: PyExc_Warning (C var)
12081214
single: PyExc_BytesWarning (C var)
12091215
single: PyExc_DeprecationWarning (C var)
1216+
single: PyExc_EncodingWarning (C var)
12101217
single: PyExc_FutureWarning (C var)
12111218
single: PyExc_ImportWarning (C var)
12121219
single: PyExc_PendingDeprecationWarning (C var)
@@ -1225,6 +1232,8 @@ the variables:
12251232
+------------------------------------------+---------------------------------+----------+
12261233
| :c:data:`PyExc_DeprecationWarning` | :exc:`DeprecationWarning` | |
12271234
+------------------------------------------+---------------------------------+----------+
1235+
| :c:data:`PyExc_EncodingWarning` | :exc:`EncodingWarning` | |
1236+
+------------------------------------------+---------------------------------+----------+
12281237
| :c:data:`PyExc_FutureWarning` | :exc:`FutureWarning` | |
12291238
+------------------------------------------+---------------------------------+----------+
12301239
| :c:data:`PyExc_ImportWarning` | :exc:`ImportWarning` | |
@@ -1245,6 +1254,9 @@ the variables:
12451254
.. versionadded:: 3.2
12461255
:c:data:`PyExc_ResourceWarning`.
12471256
1257+
.. versionadded:: 3.10
1258+
:c:data:`PyExc_EncodingWarning`.
1259+
12481260
Notes:
12491261
12501262
.. [3]

Doc/c-api/typeobj.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,26 @@ and :c:data:`PyType_Type` effectively act as defaults.)
686686
instance, and call the type's :c:member:`~PyTypeObject.tp_free` function to
687687
free the object itself.
688688

689+
If you may call functions that may set the error indicator, you must use
690+
:c:func:`PyErr_GetRaisedException` and :c:func:`PyErr_SetRaisedException`
691+
to ensure you don't clobber a preexisting error indicator (the deallocation
692+
could have occurred while processing a different error):
693+
694+
.. code-block:: c
695+
696+
static void
697+
foo_dealloc(foo_object *self)
698+
{
699+
PyObject *et, *ev, *etb;
700+
PyObject *exc = PyErr_GetRaisedException();
701+
...
702+
PyErr_SetRaisedException(exc);
703+
}
704+
705+
The dealloc handler itself must not raise an exception; if it hits an error
706+
case it should call :c:func:`PyErr_FormatUnraisable` to log (and clear) an
707+
unraisable exception.
708+
689709
No guarantees are made about when an object is destroyed, except:
690710

691711
* Python will destroy an object immediately or some time after the final

Doc/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@
234234
('c:data', 'PyExc_AssertionError'),
235235
('c:data', 'PyExc_AttributeError'),
236236
('c:data', 'PyExc_BaseException'),
237+
('c:data', 'PyExc_BaseExceptionGroup'),
237238
('c:data', 'PyExc_BlockingIOError'),
238239
('c:data', 'PyExc_BrokenPipeError'),
239240
('c:data', 'PyExc_BufferError'),
@@ -287,6 +288,7 @@
287288
# C API: Standard Python warning classes
288289
('c:data', 'PyExc_BytesWarning'),
289290
('c:data', 'PyExc_DeprecationWarning'),
291+
('c:data', 'PyExc_EncodingWarning'),
290292
('c:data', 'PyExc_FutureWarning'),
291293
('c:data', 'PyExc_ImportWarning'),
292294
('c:data', 'PyExc_PendingDeprecationWarning'),

Doc/library/csv.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ A slightly more advanced use of the reader --- catching and reporting errors::
609609
for row in reader:
610610
print(row)
611611
except csv.Error as e:
612-
sys.exit('file {}, line {}: {}'.format(filename, reader.line_num, e))
612+
sys.exit(f'file {filename}, line {reader.line_num}: {e}')
613613

614614
And while the module doesn't directly support parsing strings, it can easily be
615615
done::

Doc/library/ctypes.rst

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -714,10 +714,16 @@ item in the :attr:`~Structure._fields_` tuples::
714714
... ("second_16", c_int, 16)]
715715
...
716716
>>> print(Int.first_16)
717-
<Field type=c_long, ofs=0:0, bits=16>
717+
<ctypes.CField 'first_16' type=c_int, ofs=0, bit_size=16, bit_offset=0>
718718
>>> print(Int.second_16)
719-
<Field type=c_long, ofs=0:16, bits=16>
720-
>>>
719+
<ctypes.CField 'second_16' type=c_int, ofs=0, bit_size=16, bit_offset=16>
720+
721+
It is important to note that bit field allocation and layout in memory are not
722+
defined as a C standard; their implementation is compiler-specific.
723+
By default, Python will attempt to match the behavior of a "native" compiler
724+
for the current platform.
725+
See the :attr:`~Structure._layout_` attribute for details on the default
726+
behavior and how to change it.
721727

722728

723729
.. _ctypes-arrays:

Doc/library/stdtypes.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,7 @@ operations have the same priority as the corresponding numeric operations. [3]_
10181018
| ``s * n`` or | equivalent to adding *s* to | (2)(7) |
10191019
| ``n * s`` | itself *n* times | |
10201020
+--------------------------+--------------------------------+----------+
1021-
| ``s[i]`` | *i*\ th item of *s*, origin 0 | \(3) |
1021+
| ``s[i]`` | *i*\ th item of *s*, origin 0 | (3)(9) |
10221022
+--------------------------+--------------------------------+----------+
10231023
| ``s[i:j]`` | slice of *s* from *i* to *j* | (3)(4) |
10241024
+--------------------------+--------------------------------+----------+
@@ -1150,6 +1150,9 @@ Notes:
11501150
without copying any data and with the returned index being relative to
11511151
the start of the sequence rather than the start of the slice.
11521152

1153+
(9)
1154+
An :exc:`IndexError` is raised if *i* is outside the sequence range.
1155+
11531156

11541157
.. _typesseq-immutable:
11551158

Doc/library/token.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ The token constants are:
5151
.. data:: NAME
5252

5353
Token value that indicates an :ref:`identifier <identifiers>`.
54-
Note that keywords are also initially tokenized an ``NAME`` tokens.
54+
Note that keywords are also initially tokenized as ``NAME`` tokens.
5555

5656
.. data:: NUMBER
5757

Doc/library/uuid.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,10 @@ The :mod:`uuid` module defines the following functions:
257257
non-specified arguments are substituted for a pseudo-random integer of
258258
appropriate size.
259259

260+
By default, *a*, *b* and *c* are generated by a non-cryptographically
261+
secure pseudo-random number generator (CSPRNG). Use :func:`uuid4` when
262+
a UUID needs to be used in a security-sensitive context.
263+
260264
.. versionadded:: 3.14
261265

262266

Doc/tutorial/introduction.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ end a multi-line command.
1313

1414
.. only:: html
1515

16-
You can toggle the display of prompts and output by clicking on ``>>>``
17-
in the upper-right corner of an example box. If you hide the prompts
18-
and output for an example, then you can easily copy and paste the input
19-
lines into your interpreter.
16+
You can use the "Copy" button (it appears in the upper-right corner
17+
when hovering over or tapping a code example), which strips prompts
18+
and omits output, to copy and paste the input lines into your interpreter.
2019

2120
.. index:: single: # (hash); comment
2221

0 commit comments

Comments
 (0)