Skip to content

Commit c6170eb

Browse files
authored
Merge branch 'main' into gh-130614-test-copy
2 parents 4d81bd3 + 1a8e574 commit c6170eb

File tree

133 files changed

+1229
-611
lines changed

Some content is hidden

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

133 files changed

+1229
-611
lines changed

Doc/c-api/init_config.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,10 @@ Configuration Options
505505
- :c:member:`use_hash_seed <PyConfig.use_hash_seed>`
506506
- ``bool``
507507
- Read-only
508+
* - ``"use_system_logger"``
509+
- :c:member:`use_system_logger <PyConfig.use_system_logger>`
510+
- ``bool``
511+
- Read-only
508512
* - ``"user_site_directory"``
509513
- :c:member:`user_site_directory <PyConfig.user_site_directory>`
510514
- ``bool``
@@ -1927,9 +1931,10 @@ PyConfig
19271931
19281932
Only available on macOS 10.12 and later, and on iOS.
19291933
1930-
Default: ``0`` (don't use system log).
1934+
Default: ``0`` (don't use the system log) on macOS; ``1`` on iOS (use the
1935+
system log).
19311936
1932-
.. versionadded:: 3.13.2
1937+
.. versionadded:: 3.14
19331938
19341939
.. c:member:: int user_site_directory
19351940

Doc/data/stable_abi.dat

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Doc/library/cmdline.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ The following modules have a command-line interface.
1111
* :mod:`code`
1212
* :ref:`compileall <compileall-cli>`
1313
* :mod:`cProfile`: see :ref:`profile <profile-cli>`
14-
* :ref:`difflib <difflib-interface>`
1514
* :ref:`dis <dis-cli>`
1615
* :mod:`doctest`
1716
* :mod:`!encodings.rot_13`
@@ -24,7 +23,7 @@ The following modules have a command-line interface.
2423
* :mod:`!idlelib`
2524
* :ref:`inspect <inspect-module-cli>`
2625
* :ref:`json <json-commandline>`
27-
* :mod:`mimetypes`
26+
* :ref:`mimetypes <mimetypes-cli>`
2827
* :mod:`pdb`
2928
* :mod:`pickle`
3029
* :ref:`pickletools <pickletools-cli>`

Doc/library/concurrent.futures.rst

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,14 @@ Executor Objects
4040
future = executor.submit(pow, 323, 1235)
4141
print(future.result())
4242

43-
.. method:: map(fn, *iterables, timeout=None, chunksize=1)
43+
.. method:: map(fn, *iterables, timeout=None, chunksize=1, buffersize=None)
4444

4545
Similar to :func:`map(fn, *iterables) <map>` except:
4646

47-
* the *iterables* are collected immediately rather than lazily;
47+
* The *iterables* are collected immediately rather than lazily, unless a
48+
*buffersize* is specified to limit the number of submitted tasks whose
49+
results have not yet been yielded. If the buffer is full, iteration over
50+
the *iterables* pauses until a result is yielded from the buffer.
4851

4952
* *fn* is executed asynchronously and several calls to
5053
*fn* may be made concurrently.
@@ -68,7 +71,10 @@ Executor Objects
6871
*chunksize* has no effect.
6972

7073
.. versionchanged:: 3.5
71-
Added the *chunksize* argument.
74+
Added the *chunksize* parameter.
75+
76+
.. versionchanged:: next
77+
Added the *buffersize* parameter.
7278

7379
.. method:: shutdown(wait=True, *, cancel_futures=False)
7480

Doc/library/mimetypes.rst

Lines changed: 95 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ An example usage of the module::
191191

192192
.. _mimetypes-objects:
193193

194-
MimeTypes Objects
194+
MimeTypes objects
195195
-----------------
196196

197197
The :class:`MimeTypes` class may be useful for applications which may want more
@@ -307,3 +307,97 @@ than one MIME-type database; it provides an interface similar to the one of the
307307

308308
When *strict* is ``True`` (the default), the mapping will be added to the
309309
official MIME types, otherwise to the non-standard ones.
310+
311+
312+
.. _mimetypes-cli:
313+
314+
Command-line usage
315+
------------------
316+
317+
The :mod:`!mimetypes` module can be executed as a script from the command line.
318+
319+
.. code-block:: sh
320+
321+
python -m mimetypes [-h] [-e] [-l] type [type ...]
322+
323+
The following options are accepted:
324+
325+
.. program:: mimetypes
326+
327+
.. cmdoption:: -h
328+
--help
329+
330+
Show the help message and exit.
331+
332+
.. cmdoption:: -e
333+
--extension
334+
335+
Guess extension instead of type.
336+
337+
.. cmdoption:: -l
338+
--lenient
339+
340+
Additionally search for some common, but non-standard types.
341+
342+
By default the script converts MIME types to file extensions.
343+
However, if ``--extension`` is specified,
344+
it converts file extensions to MIME types.
345+
346+
For each ``type`` entry, the script writes a line into the standard output
347+
stream. If an unknown type occurs, it writes an error message into the
348+
standard error stream and exits with the return code ``1``.
349+
350+
351+
.. mimetypes-cli-example:
352+
353+
Command-line example
354+
--------------------
355+
356+
Here are some examples of typical usage of the :mod:`!mimetypes` command-line
357+
interface:
358+
359+
.. code-block:: console
360+
361+
$ # get a MIME type by a file name
362+
$ python -m mimetypes filename.png
363+
type: image/png encoding: None
364+
365+
$ # get a MIME type by a URL
366+
$ python -m mimetypes https://example.com/filename.txt
367+
type: text/plain encoding: None
368+
369+
$ # get a complex MIME type
370+
$ python -m mimetypes filename.tar.gz
371+
type: application/x-tar encoding: gzip
372+
373+
$ # get a MIME type for a rare file extension
374+
$ python -m mimetypes filename.pict
375+
error: unknown extension of filename.pict
376+
377+
$ # now look in the extended database built into Python
378+
$ python -m mimetypes --lenient filename.pict
379+
type: image/pict encoding: None
380+
381+
$ # get a file extension by a MIME type
382+
$ python -m mimetypes --extension text/javascript
383+
.js
384+
385+
$ # get a file extension by a rare MIME type
386+
$ python -m mimetypes --extension text/xul
387+
error: unknown type text/xul
388+
389+
$ # now look in the extended database again
390+
$ python -m mimetypes --extension --lenient text/xul
391+
.xul
392+
393+
$ # try to feed an unknown file extension
394+
$ python -m mimetypes filename.sh filename.nc filename.xxx filename.txt
395+
type: application/x-sh encoding: None
396+
type: application/x-netcdf encoding: None
397+
error: unknown extension of filename.xxx
398+
399+
$ # try to feed an unknown MIME type
400+
$ python -m mimetypes --extension audio/aac audio/opus audio/future audio/x-wav
401+
.aac
402+
.opus
403+
error: unknown type audio/future

Doc/using/ios.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ To add Python to an iOS Xcode project:
297297
* Writing bytecode (:c:member:`PyConfig.write_bytecode`) is *disabled*;
298298
* Signal handlers (:c:member:`PyConfig.install_signal_handlers`) are *enabled*;
299299
* System logging (:c:member:`PyConfig.use_system_logger`) is *enabled*
300-
(optional, but strongly recommended);
300+
(optional, but strongly recommended; this is enabled by default);
301301
* ``PYTHONHOME`` for the interpreter is configured to point at the
302302
``python`` subfolder of your app's bundle; and
303303
* The ``PYTHONPATH`` for the interpreter includes:

Doc/whatsnew/3.14.rst

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,13 @@ contextvars
465465
* Support context manager protocol by :class:`contextvars.Token`.
466466
(Contributed by Andrew Svetlov in :gh:`129889`.)
467467

468+
* Add the optional ``buffersize`` parameter to
469+
:meth:`concurrent.futures.Executor.map` to limit the number of submitted
470+
tasks whose results have not yet been yielded. If the buffer is full,
471+
iteration over the *iterables* pauses until a result is yielded from the
472+
buffer.
473+
(Contributed by Enzo Bonnal and Josh Rosenberg in :gh:`74028`.)
474+
468475

469476
ctypes
470477
------
@@ -645,6 +652,13 @@ json
645652
mimetypes
646653
---------
647654

655+
* Document the command-line for :mod:`mimetypes`.
656+
It now exits with ``1`` on failure instead of ``0``
657+
and ``2`` on incorrect command-line parameters instead of ``1``.
658+
Also, errors are printed to stderr instead of stdout and their text is made
659+
tighter.
660+
(Contributed by Oleg Iarygin and Hugo van Kemenade in :gh:`93096`.)
661+
648662
* Add MS and :rfc:`8081` MIME types for fonts:
649663

650664
* Embedded OpenType: ``application/vnd.ms-fontobject``
@@ -1584,9 +1598,10 @@ Limited C API changes
15841598
implementation details.
15851599
(Contributed by Victor Stinner in :gh:`120600` and :gh:`124127`.)
15861600

1587-
* Remove :c:func:`PySequence_Fast` from the limited C API, since this function
1588-
has to be used with :c:macro:`PySequence_Fast_GET_ITEM` which never worked
1589-
in the limited C API.
1601+
* Remove the :c:macro:`PySequence_Fast_GET_SIZE`,
1602+
:c:macro:`PySequence_Fast_GET_ITEM` and :c:macro:`PySequence_Fast_ITEMS`
1603+
macros from the limited C API, since these macros never worked in the limited
1604+
C API. Keep :c:func:`PySequence_Fast` in the limited C API.
15901605
(Contributed by Victor Stinner in :gh:`91417`.)
15911606

15921607

Include/abstract.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,15 @@ PyAPI_FUNC(PyObject *) PySequence_Tuple(PyObject *o);
726726
This is equivalent to the Python expression: list(o) */
727727
PyAPI_FUNC(PyObject *) PySequence_List(PyObject *o);
728728

729+
/* Return the sequence 'o' as a list, unless it's already a tuple or list.
730+
731+
Use PySequence_Fast_GET_ITEM to access the members of this list, and
732+
PySequence_Fast_GET_SIZE to get its length.
733+
734+
Returns NULL on failure. If the object does not support iteration, raises a
735+
TypeError exception with 'm' as the message text. */
736+
PyAPI_FUNC(PyObject *) PySequence_Fast(PyObject *o, const char* m);
737+
729738
/* Return the number of occurrences on value on 'o', that is, return
730739
the number of keys for which o[key] == value.
731740

Include/cpython/abstract.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,6 @@ PyAPI_FUNC(Py_ssize_t) PyObject_LengthHint(PyObject *o, Py_ssize_t);
8686
#define PySequence_ITEM(o, i)\
8787
( Py_TYPE(o)->tp_as_sequence->sq_item((o), (i)) )
8888

89-
/* Return the sequence 'o' as a list, unless it's already a tuple or list.
90-
91-
Use PySequence_Fast_GET_ITEM to access the members of this list, and
92-
PySequence_Fast_GET_SIZE to get its length.
93-
94-
Returns NULL on failure. If the object does not support iteration, raises a
95-
TypeError exception with 'm' as the message text. */
96-
PyAPI_FUNC(PyObject *) PySequence_Fast(PyObject *o, const char* m);
97-
9889
/* Return the size of the sequence 'o', assuming that 'o' was returned by
9990
PySequence_Fast and is not NULL. */
10091
#define PySequence_Fast_GET_SIZE(o) \

Include/internal/pycore_c_array.h

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#ifndef Py_INTERNAL_C_ARRAY_H
2+
#define Py_INTERNAL_C_ARRAY_H
3+
4+
#ifdef __cplusplus
5+
extern "C" {
6+
#endif
7+
8+
#ifndef Py_BUILD_CORE
9+
# error "this header requires Py_BUILD_CORE define"
10+
#endif
11+
12+
13+
/* Utility for a number of growing arrays */
14+
15+
typedef struct {
16+
void *array; /* pointer to the array */
17+
int allocated_entries; /* pointer to the capacity of the array */
18+
size_t item_size; /* size of each element */
19+
int initial_num_entries; /* initial allocation size */
20+
} _Py_c_array_t;
21+
22+
23+
int _Py_CArray_Init(_Py_c_array_t* array, int item_size, int initial_num_entries);
24+
void _Py_CArray_Fini(_Py_c_array_t* array);
25+
26+
/* If idx is out of bounds:
27+
* If arr->array is NULL, allocate arr->initial_num_entries slots.
28+
* Otherwise, double its size.
29+
*
30+
* Return 0 if successful and -1 (with exception set) otherwise.
31+
*/
32+
int _Py_CArray_EnsureCapacity(_Py_c_array_t *c_array, int idx);
33+
34+
35+
#ifdef __cplusplus
36+
}
37+
#endif
38+
39+
#endif /* !Py_INTERNAL_C_ARRAY_H */

0 commit comments

Comments
 (0)