Skip to content

Commit 4b7c218

Browse files
authored
Merge branch 'main' into gh-134869
2 parents 770e5fc + 49d7236 commit 4b7c218

File tree

120 files changed

+3656
-2162
lines changed

Some content is hidden

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

120 files changed

+3656
-2162
lines changed

.github/workflows/posix-deps-apt.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ apt-get -yq install \
1717
libreadline6-dev \
1818
libsqlite3-dev \
1919
libssl-dev \
20+
libzstd-dev \
2021
lzma \
2122
lzma-dev \
2223
strace \

.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/arg.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,7 @@ Building values
685685
686686
``p`` (:class:`bool`) [int]
687687
Convert a C :c:expr:`int` to a Python :class:`bool` object.
688+
688689
.. versionadded:: 3.14
689690
690691
``c`` (:class:`bytes` of length 1) [char]

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/c-api/unicode.rst

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,22 @@ access to internal read-only data of Unicode objects:
191191
.. versionadded:: 3.2
192192
193193
194+
.. c:function:: Py_hash_t PyUnstable_Unicode_GET_CACHED_HASH(PyObject *str)
195+
196+
If the hash of *str*, as returned by :c:func:`PyObject_Hash`, has been
197+
cached and is immediately available, return it.
198+
Otherwise, return ``-1`` *without* setting an exception.
199+
200+
If *str* is not a string (that is, if ``PyUnicode_Check(obj)``
201+
is false), the behavior is undefined.
202+
203+
This function never fails with an exception.
204+
205+
Note that there are no guarantees on when an object's hash is cached,
206+
and the (non-)existence of a cached hash does not imply that the string has
207+
any other properties.
208+
209+
194210
Unicode Character Properties
195211
""""""""""""""""""""""""""""
196212
@@ -1811,7 +1827,7 @@ object.
18111827
On success, return ``0``.
18121828
On error, set an exception, leave the writer unchanged, and return ``-1``.
18131829
1814-
.. versionadded:: next
1830+
.. versionadded:: 3.14
18151831
18161832
.. c:function:: int PyUnicodeWriter_WriteWideChar(PyUnicodeWriter *writer, const wchar_t *str, Py_ssize_t size)
18171833

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/calendar.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is
251251
3) specifies the number of months per row. *css* is the name for the
252252
cascading style sheet to be used. :const:`None` can be passed if no style
253253
sheet should be used. *encoding* specifies the encoding to be used for the
254-
output (defaulting to the system default encoding).
254+
output (defaulting to ``'utf-8'``).
255255

256256

257257
.. method:: formatmonthname(theyear, themonth, withyear=True)

Doc/library/compression.zstd.rst

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,27 @@ Compressing and decompressing data in memory
247247
The *mode* argument is a :class:`ZstdCompressor` attribute, either
248248
:attr:`~.FLUSH_BLOCK`, or :attr:`~.FLUSH_FRAME`.
249249

250+
.. method:: set_pledged_input_size(size)
251+
252+
Specify the amount of uncompressed data *size* that will be provided for
253+
the next frame. *size* will be written into the frame header of the next
254+
frame unless :attr:`CompressionParameter.content_size_flag` is ``False``
255+
or ``0``. A size of ``0`` means that the frame is empty. If *size* is
256+
``None``, the frame header will omit the frame size. Frames that include
257+
the uncompressed data size require less memory to decompress, especially
258+
at higher compression levels.
259+
260+
If :attr:`last_mode` is not :attr:`FLUSH_FRAME`, a
261+
:exc:`ValueError` is raised as the compressor is not at the start of
262+
a frame. If the pledged size does not match the actual size of data
263+
provided to :meth:`.compress`, future calls to :meth:`!compress` or
264+
:meth:`flush` may raise :exc:`ZstdError` and the last chunk of data may
265+
be lost.
266+
267+
After :meth:`flush` or :meth:`.compress` are called with mode
268+
:attr:`FLUSH_FRAME`, the next frame will not include the frame size into
269+
the header unless :meth:`!set_pledged_input_size` is called again.
270+
250271
.. attribute:: CONTINUE
251272

252273
Collect more data for compression, which may or may not generate output
@@ -266,6 +287,13 @@ Compressing and decompressing data in memory
266287
:meth:`~.compress` will be written into a new frame and
267288
*cannot* reference past data.
268289

290+
.. attribute:: last_mode
291+
292+
The last mode passed to either :meth:`~.compress` or :meth:`~.flush`.
293+
The value can be one of :attr:`~.CONTINUE`, :attr:`~.FLUSH_BLOCK`, or
294+
:attr:`~.FLUSH_FRAME`. The initial value is :attr:`~.FLUSH_FRAME`,
295+
signifying that the compressor is at the start of a new frame.
296+
269297

270298
.. class:: ZstdDecompressor(zstd_dict=None, options=None)
271299

@@ -620,12 +648,17 @@ Advanced parameter control
620648
Write the size of the data to be compressed into the Zstandard frame
621649
header when known prior to compressing.
622650

623-
This flag only takes effect under the following two scenarios:
651+
This flag only takes effect under the following scenarios:
624652

625653
* Calling :func:`compress` for one-shot compression
626654
* Providing all of the data to be compressed in the frame in a single
627655
:meth:`ZstdCompressor.compress` call, with the
628656
:attr:`ZstdCompressor.FLUSH_FRAME` mode.
657+
* Calling :meth:`ZstdCompressor.set_pledged_input_size` with the exact
658+
amount of data that will be provided to the compressor prior to any
659+
calls to :meth:`ZstdCompressor.compress` for the current frame.
660+
:meth:`!ZstdCompressor.set_pledged_input_size` must be called for each
661+
new frame.
629662

630663
All other compression calls may not write the size information into the
631664
frame header.

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::

0 commit comments

Comments
 (0)