Skip to content

Commit c478cd6

Browse files
authored
Merge branch 'main' into dependabot-npm-emscripten
2 parents 562dd39 + 0768eed commit c478cd6

30 files changed

Lines changed: 486 additions & 172 deletions

File tree

‎.github/dependabot.yml‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -129,18 +129,6 @@ updates:
129129
cooldown:
130130
default-days: 14
131131

132-
- package-ecosystem: "pip"
133-
target-branch: "3.13"
134-
directory: "/Tools/"
135-
schedule:
136-
interval: "quarterly"
137-
labels: ["skip issue", "skip news"]
138-
groups:
139-
pip:
140-
patterns: ["*"]
141-
cooldown:
142-
default-days: 14
143-
144132
# Only bump bugfix branches for npm. Remove
145133
# the entry when branch goes security-only.
146134
- package-ecosystem: "npm"

‎Doc/library/concurrent.interpreters.rst‎

Lines changed: 69 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -224,11 +224,15 @@ This module defines the following functions:
224224
Initialize a new (idle) Python interpreter
225225
and return a :class:`Interpreter` object for it.
226226

227-
.. function:: create_queue()
227+
.. function:: create_queue(maxsize=0)
228228

229229
Initialize a new cross-interpreter queue and return a :class:`Queue`
230230
object for it.
231231

232+
*maxsize* is an integer that sets the upperbound limit on the number of
233+
items that can be placed in the queue. Insertion will be blocked once this
234+
size has been reached, until queue items are consumed. If *maxsize* is
235+
less than or equal to zero, the queue size is infinite.
232236

233237
Interpreter objects
234238
^^^^^^^^^^^^^^^^^^^
@@ -268,7 +272,7 @@ Interpreter objects
268272
Some objects are actually shared and some are copied efficiently,
269273
but most are copied via :mod:`pickle`. See :ref:`interp-object-sharing`.
270274

271-
.. method:: exec(code, /, dedent=True)
275+
.. method:: exec(code, /)
272276

273277
Run the given source code in the interpreter (in the current thread).
274278

@@ -319,7 +323,9 @@ Communicating Between Interpreters
319323
.. class:: Queue(id)
320324

321325
A wrapper around a low-level, cross-interpreter queue, which
322-
implements the :class:`queue.Queue` interface. The underlying queue
326+
implements all the methods of :class:`queue.Queue` except for
327+
:meth:`~queue.Queue.task_done`, :meth:`~queue.Queue.join`
328+
and :meth:`~queue.Queue.shutdown`. The underlying queue
323329
can only be created through :func:`create_queue`.
324330

325331
Some objects are actually shared and some are copied efficiently,
@@ -331,17 +337,59 @@ Communicating Between Interpreters
331337

332338
The queue's ID.
333339

340+
.. method:: qsize()
334341

335-
.. exception:: QueueEmptyError
342+
Return the number of items in the queue.
343+
344+
.. method:: empty()
345+
346+
Return ``True`` if the queue is empty, ``False`` otherwise.
347+
348+
.. method:: full()
349+
350+
Return ``True`` if the queue is full, ``False`` otherwise.
351+
352+
.. method:: put(obj, block=True, timeout=None)
353+
354+
Put *obj* into the queue. If optional args *block* is true and
355+
*timeout* is ``None`` (the default), block if necessary until a free
356+
slot is available. If *timeout* is a positive number, it blocks at
357+
most *timeout* seconds and raises the :exc:`QueueFull` exception if
358+
no free slot was available within that time. Otherwise (*block* is
359+
false), put an object on the queue if a free slot is immediately
360+
available, else raise the :exc:`QueueFull` exception (*timeout* is
361+
ignored in that case).
362+
363+
.. method:: put_nowait(obj)
364+
365+
Equivalent to ``put(obj, block=False)``.
366+
367+
.. method:: get(block=True, timeout=None)
368+
369+
Remove and return an object from the queue. If optional args *block*
370+
is true and *timeout* is ``None`` (the default), block if necessary
371+
until an object is available. If *timeout* is a positive number, it
372+
blocks at most *timeout* seconds and raises the :exc:`QueueEmpty`
373+
exception if no object was available within that time. Otherwise
374+
(*block* is false), return an object if one is immediately available,
375+
else raise the :exc:`QueueEmpty` exception (*timeout* is ignored in
376+
that case).
377+
378+
.. method:: get_nowait()
379+
380+
Equivalent to ``get(block=False)``.
381+
382+
383+
.. exception:: QueueEmpty
336384

337385
This exception, a subclass of :exc:`queue.Empty`, is raised from
338-
:meth:`!Queue.get` and :meth:`!Queue.get_nowait` when the queue
386+
:meth:`Queue.get` and :meth:`Queue.get_nowait` when the queue
339387
is empty.
340388

341-
.. exception:: QueueFullError
389+
.. exception:: QueueFull
342390

343391
This exception, a subclass of :exc:`queue.Full`, is raised from
344-
:meth:`!Queue.put` and :meth:`!Queue.put_nowait` when the queue
392+
:meth:`Queue.put` and :meth:`Queue.put_nowait` when the queue
345393
is full.
346394

347395

@@ -382,3 +430,17 @@ Creating an interpreter and running code in it::
382430

383431
t = interp.call_in_thread(run)
384432
t.join()
433+
434+
Communicating between interpreters with a queue::
435+
436+
from concurrent import interpreters
437+
438+
interp = interpreters.create()
439+
queue = interpreters.create_queue()
440+
441+
def worker(queue):
442+
queue.put('spam!')
443+
444+
t = interp.call_in_thread(worker, queue)
445+
print(queue.get())
446+
t.join()

‎Doc/library/ctypes.rst‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1579,7 +1579,10 @@ way is to instantiate :py:class:`CDLL` or one of its subclasses:
15791579
:mod:`!ctypes` maintains a thread-local copy of the system's :data:`errno`
15801580
variable; if you call foreign functions created with ``use_errno=True`` then the
15811581
:data:`errno` value before the function call is swapped with the ctypes private
1582-
copy, the same happens immediately after the function call.
1582+
copy, the same happens immediately after the function call. This mechanism only
1583+
works for libraries that use the same C runtime library as the interpreter itself.
1584+
A library linked against a different C runtime (for example, a different CRT on
1585+
Windows) has its own :data:`errno`, which :mod:`!ctypes` cannot observe.
15831586

15841587
The function :func:`ctypes.get_errno` returns the value of the ctypes private
15851588
copy, and the function :func:`ctypes.set_errno` changes the ctypes private copy

‎Doc/library/tarfile.rst‎

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,17 @@ Some facts and figures:
123123
:exc:`ReadError` is raised. Use *mode* ``'r'`` to avoid this. If a
124124
compression method is not supported, :exc:`CompressionError` is raised.
125125

126+
.. note::
127+
128+
Compressed archives opened with modes like ``'r:gz'``, ``'r:bz2'``,
129+
``'r:xz'``, or ``'r:zst'`` support random access, but seeking backwards
130+
in the underlying compressed stream requires re-decompressing from the
131+
beginning. Extracting members in a different order than they appear in
132+
the archive can therefore be significantly slower — proportional to the
133+
total compressed data read rather than just the target member's size. For
134+
best performance, extract members in archive order or use
135+
:meth:`TarFile.extractall`.
136+
126137
If *fileobj* is specified, it is used as an alternative to a :term:`file object`
127138
opened in binary mode for *name*. It is supposed to be at position 0.
128139

@@ -1056,7 +1067,8 @@ can be:
10561067

10571068
* the string ``'tar'``: Honor most *tar*-specific features (i.e. features of
10581069
UNIX-like filesystems), but block features that are very likely to be
1059-
surprising or malicious. See :func:`tar_filter` for details.
1070+
surprising or malicious. Note that this filter does not limit the targets of
1071+
symbolic links. See :func:`tar_filter` for details.
10601072

10611073
* the string ``'data'``: Ignore or block most features specific to UNIX-like
10621074
filesystems. Intended for extracting cross-platform data archives.
@@ -1124,6 +1136,17 @@ reused in custom filters:
11241136

11251137
Return the modified ``TarInfo`` member.
11261138

1139+
.. warning::
1140+
This filter does not check :attr:`TarInfo.linkname`. This means it does
1141+
not limit where a symbolic link member points. An absolute symbolic-link
1142+
target will remain absolute, and a relative target may resolve outside the
1143+
extraction destination. The destination path protection described above
1144+
concerns only where the archive member itself is written, not where a
1145+
symbolic link resolves. The stricter :func:`data_filter` rejects these
1146+
unsafe link targets, raising :class:`~tarfile.AbsoluteLinkError` for
1147+
absolute link targets or :class:`~tarfile.LinkOutsideDestinationError`
1148+
for link targets outside the destination.
1149+
11271150
.. versionchanged:: next
11281151

11291152
Filenames containing ``..`` components are now normalized.

‎Doc/tools/removed-ids.txt‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,7 @@ library/turtle.html: changes-since-python-3-0
114114
# 'turtle' documentation reorganisation (gh-157847)
115115
library/turtle.html: note
116116
library/turtle.html: introduction
117+
118+
# Wrong exception names in 'concurrent.interpreters' docs (gh-136563)
119+
library/concurrent.interpreters.html: concurrent.interpreters.QueueEmptyError
120+
library/concurrent.interpreters.html: concurrent.interpreters.QueueFullError

‎Doc/whatsnew/3.16.rst‎

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ Other language changes
9898
they reference) alive indefinitely.
9999
(Contributed by Łukasz Langa in :gh:`102960`.)
100100

101+
* :exc:`TypeError` messages for some instance methods called with too many
102+
positional arguments now suggest checking whether the method definition is
103+
missing the ``self`` parameter. (Contributed by Suren Nihalani in
104+
:gh:`152315`.)
105+
101106

102107
New modules
103108
===========
@@ -180,6 +185,7 @@ ctypes
180185
from an annotation-based syntax, similar to how the :mod:`dataclasses` module
181186
is used.
182187
(Contributed by Peter Bierma in :gh:`104533`.)
188+
183189
* Add :func:`ctypes.util.wrap_dll_function` for generating function pointers
184190
through a function signature.
185191
(Contributed by Peter Bierma in :gh:`153903`.)
@@ -326,27 +332,6 @@ curses
326332
(Contributed by Serhiy Storchaka in :gh:`133031`.)
327333

328334

329-
ctypes
330-
------
331-
332-
* Add :func:`ctypes.util.struct` for generating :class:`~ctypes.Structure` types
333-
from an annotation-based syntax, similar to how the :mod:`dataclasses` module
334-
is used.
335-
(Contributed by Peter Bierma in :gh:`104533`.)
336-
* Add :func:`ctypes.util.wrap_dll_function` for generating function pointers
337-
through a function signature.
338-
(Contributed by Peter Bierma in :gh:`153903`.)
339-
340-
341-
concurrent.futures
342-
------------------
343-
344-
* The iterator returned by :meth:`concurrent.futures.Executor.map` is no longer
345-
automatically closed if a function call raises an exception.
346-
Use method :meth:`!close` to explicitly close the iterator.
347-
(Contributed by xzmeng and Serhiy Storchaka in :gh:`108518`.)
348-
349-
350335
decimal
351336
-------
352337

‎Include/internal/pycore_modsupport.h‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,6 @@ extern PyObject ** _Py_VaBuildStack(
4141

4242
extern PyObject* _PyModule_CreateInitialized(PyModuleDef*, int apiver);
4343

44-
// Export for '_curses' shared extension
45-
PyAPI_FUNC(int) _PyArg_ParseStack(
46-
PyObject *const *args,
47-
Py_ssize_t nargs,
48-
const char *format,
49-
...);
50-
5144
extern int _PyArg_UnpackStack(
5245
PyObject *const *args,
5346
Py_ssize_t nargs,
@@ -65,7 +58,9 @@ PyAPI_FUNC(void) _PyArg_BadArgument(
6558

6659
// --- _PyArg_Parser API ---------------------------------------------------
6760

68-
// Export for '_dbm' shared extension
61+
// Similar to public PyArg_ParseArrayAndKeywords(), but faster thanks
62+
// to "struct _PyArg_Parser *parser" cache.
63+
// Export for '_dbm' shared extension.
6964
PyAPI_FUNC(int) _PyArg_ParseStackAndKeywords(
7065
PyObject *const *args,
7166
Py_ssize_t nargs,

‎Lib/test/clinic.test.c‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2049,7 +2049,7 @@ test_str_converter(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
20492049
const char *h = "mn";
20502050
Py_ssize_t h_length;
20512051

2052-
if (!_PyArg_ParseStack(args, nargs, "|sssyzy#s#z#:test_str_converter",
2052+
if (!PyArg_ParseArray(args, nargs, "|sssyzy#s#z#:test_str_converter",
20532053
&a, &b, &c, &d, &e, &f, &f_length, &g, &g_length, &h, &h_length)) {
20542054
goto exit;
20552055
}
@@ -2065,7 +2065,7 @@ test_str_converter_impl(PyObject *module, const char *a, const char *b,
20652065
const char *f, Py_ssize_t f_length, const char *g,
20662066
Py_ssize_t g_length, const char *h,
20672067
Py_ssize_t h_length)
2068-
/*[clinic end generated code: output=82cb06d5237ef062 input=8afe9da8185cd38c]*/
2068+
/*[clinic end generated code: output=58dc0fad26cd4c5d input=8afe9da8185cd38c]*/
20692069

20702070

20712071
/*[clinic input]
@@ -2105,7 +2105,7 @@ test_str_converter_encoding(PyObject *module, PyObject *const *args, Py_ssize_t
21052105
char *e = NULL;
21062106
Py_ssize_t e_length;
21072107

2108-
if (!_PyArg_ParseStack(args, nargs, "esesetes#et#:test_str_converter_encoding",
2108+
if (!PyArg_ParseArray(args, nargs, "esesetes#et#:test_str_converter_encoding",
21092109
"idna", &a, "idna", &b, "idna", &c, "idna", &d, &d_length, "idna", &e, &e_length)) {
21102110
goto exit;
21112111
}
@@ -2129,7 +2129,7 @@ static PyObject *
21292129
test_str_converter_encoding_impl(PyObject *module, char *a, char *b, char *c,
21302130
char *d, Py_ssize_t d_length, char *e,
21312131
Py_ssize_t e_length)
2132-
/*[clinic end generated code: output=999c1deecfa15b0a input=eb4c38e1f898f402]*/
2132+
/*[clinic end generated code: output=5bab02bfd6a20cf4 input=eb4c38e1f898f402]*/
21332133

21342134

21352135
/*[clinic input]
@@ -2170,7 +2170,7 @@ test_Py_UNICODE_converter(PyObject *module, PyObject *const *args, Py_ssize_t na
21702170
const wchar_t *e = NULL;
21712171
Py_ssize_t e_length;
21722172

2173-
if (!_PyArg_ParseStack(args, nargs, "O&O&O&u#Z#:test_Py_UNICODE_converter",
2173+
if (!PyArg_ParseArray(args, nargs, "O&O&O&u#Z#:test_Py_UNICODE_converter",
21742174
_PyUnicode_WideCharString_Converter, &a, _PyUnicode_WideCharString_Converter, &b, _PyUnicode_WideCharString_Opt_Converter, &c, &d, &d_length, &e, &e_length)) {
21752175
goto exit;
21762176
}
@@ -2192,7 +2192,7 @@ test_Py_UNICODE_converter_impl(PyObject *module, const wchar_t *a,
21922192
const wchar_t *b, const wchar_t *c,
21932193
const wchar_t *d, Py_ssize_t d_length,
21942194
const wchar_t *e, Py_ssize_t e_length)
2195-
/*[clinic end generated code: output=529af9cda2a20349 input=064a3b68ad7f04b0]*/
2195+
/*[clinic end generated code: output=020370db41973be0 input=064a3b68ad7f04b0]*/
21962196

21972197

21982198
/*[clinic input]
@@ -2229,7 +2229,7 @@ test_Py_buffer_converter(PyObject *module, PyObject *const *args, Py_ssize_t nar
22292229
Py_buffer d = {NULL, NULL};
22302230
Py_buffer e = {NULL, NULL};
22312231

2232-
if (!_PyArg_ParseStack(args, nargs, "y*y*s*z*w*:test_Py_buffer_converter",
2232+
if (!PyArg_ParseArray(args, nargs, "y*y*s*z*w*:test_Py_buffer_converter",
22332233
&a, &b, &c, &d, &e)) {
22342234
goto exit;
22352235
}
@@ -2263,7 +2263,7 @@ test_Py_buffer_converter(PyObject *module, PyObject *const *args, Py_ssize_t nar
22632263
static PyObject *
22642264
test_Py_buffer_converter_impl(PyObject *module, Py_buffer *a, Py_buffer *b,
22652265
Py_buffer *c, Py_buffer *d, Py_buffer *e)
2266-
/*[clinic end generated code: output=a153b71b4f45f952 input=6a9da0f56f9525fd]*/
2266+
/*[clinic end generated code: output=14bb6138c13c4085 input=6a9da0f56f9525fd]*/
22672267

22682268

22692269
/*[clinic input]
@@ -6038,7 +6038,7 @@ Test__pyarg_parsestackandkeywords(PyObject *self, PyTypeObject *cls, PyObject *c
60386038
if (!_PyArg_NoKwnames("_pyarg_parsestackandkeywords", kwnames)) {
60396039
goto exit;
60406040
}
6041-
if (!_PyArg_ParseStack(args, nargs, "s#:_pyarg_parsestackandkeywords",
6041+
if (!PyArg_ParseArray(args, nargs, "s#:_pyarg_parsestackandkeywords",
60426042
&key, &key_length)) {
60436043
goto exit;
60446044
}
@@ -6052,7 +6052,7 @@ static PyObject *
60526052
Test__pyarg_parsestackandkeywords_impl(TestObj *self, PyTypeObject *cls,
60536053
const char *key,
60546054
Py_ssize_t key_length)
6055-
/*[clinic end generated code: output=21bbb9a8d0100d72 input=fc72ef4b4cfafabc]*/
6055+
/*[clinic end generated code: output=4acb456c0ebbbd40 input=fc72ef4b4cfafabc]*/
60566056

60576057

60586058
/*[clinic input]

0 commit comments

Comments
 (0)