Skip to content

Commit b05720a

Browse files
committed
Merge branch 'master' into fix-nan-packing/130317
2 parents 971fd98 + 3a555f0 commit b05720a

File tree

98 files changed

+2792
-1772
lines changed

Some content is hidden

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

98 files changed

+2792
-1772
lines changed

Doc/c-api/exceptions.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,11 @@ because the :ref:`call protocol <call>` takes care of recursion handling.
921921
922922
Marks a point where a recursive C-level call is about to be performed.
923923
924-
The function then checks if the stack limit is reached. If this is the
924+
If :c:macro:`!USE_STACKCHECK` is defined, this function checks if the OS
925+
stack overflowed using :c:func:`PyOS_CheckStack`. If this is the case, it
926+
sets a :exc:`MemoryError` and returns a nonzero value.
927+
928+
The function then checks if the recursion limit is reached. If this is the
925929
case, a :exc:`RecursionError` is set and a nonzero value is returned.
926930
Otherwise, zero is returned.
927931

Doc/c-api/module.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ The available slot types are:
415415
in one module definition.
416416
417417
If ``Py_mod_multiple_interpreters`` is not specified, the import
418-
machinery defaults to ``Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED``.
418+
machinery defaults to ``Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED``.
419419
420420
.. versionadded:: 3.12
421421

Doc/c-api/unicode.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,15 @@ APIs:
607607
decref'ing the returned objects.
608608
609609
610+
.. c:function:: const char* PyUnicode_GetDefaultEncoding(void)
611+
612+
Return the name of the default string encoding, ``"utf-8"``.
613+
See :func:`sys.getdefaultencoding`.
614+
615+
The returned string does not need to be freed, and is valid
616+
until interpreter shutdown.
617+
618+
610619
.. c:function:: Py_ssize_t PyUnicode_GetLength(PyObject *unicode)
611620
612621
Return the length of the Unicode object, in code points.

Doc/data/refcounts.dat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2770,6 +2770,9 @@ PyUnicode_FromFormatV:PyObject*::+1:
27702770
PyUnicode_FromFormatV:const char*:format::
27712771
PyUnicode_FromFormatV:va_list:args::
27722772

2773+
PyUnicode_GetDefaultEncoding:const char*:::
2774+
PyUnicode_GetDefaultEncoding::void::
2775+
27732776
PyUnicode_GetLength:Py_ssize_t:::
27742777
PyUnicode_GetLength:PyObject*:unicode:0:
27752778

Doc/library/configparser.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,6 +1244,10 @@ ConfigParser Objects
12441244
*space_around_delimiters* is true, delimiters between
12451245
keys and values are surrounded by spaces.
12461246

1247+
.. versionchanged:: 3.14
1248+
Raises InvalidWriteError if this would write a representation which cannot
1249+
be accurately parsed by a future :meth:`read` call from this parser.
1250+
12471251
.. note::
12481252

12491253
Comments in the original configuration file are not preserved when
@@ -1459,6 +1463,17 @@ Exceptions
14591463

14601464
.. versionadded:: 3.14
14611465

1466+
.. exception:: InvalidWriteError
1467+
1468+
Exception raised when an attempted :meth:`ConfigParser.write` would not be parsed
1469+
accurately with a future :meth:`ConfigParser.read` call.
1470+
1471+
Ex: Writing a key beginning with the :attr:`ConfigParser.SECTCRE` pattern
1472+
would parse as a section header when read. Attempting to write this will raise
1473+
this exception.
1474+
1475+
.. versionadded:: 3.14
1476+
14621477
.. rubric:: Footnotes
14631478

14641479
.. [1] Config parsers allow for heavy customization. If you are interested in

Doc/library/idle.rst

Lines changed: 50 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -660,29 +660,61 @@ functions to be used from IDLE's Python shell.
660660
Command line usage
661661
^^^^^^^^^^^^^^^^^^
662662

663-
.. code-block:: none
663+
.. program:: idle
664664

665-
idle.py [-c command] [-d] [-e] [-h] [-i] [-r file] [-s] [-t title] [-] [arg] ...
665+
IDLE can be invoked from the command line with various options. The general syntax is:
666666

667-
-c command run command in the shell window
668-
-d enable debugger and open shell window
669-
-e open editor window
670-
-h print help message with legal combinations and exit
671-
-i open shell window
672-
-r file run file in shell window
673-
-s run $IDLESTARTUP or $PYTHONSTARTUP first, in shell window
674-
-t title set title of shell window
675-
- run stdin in shell (- must be last option before args)
667+
.. code-block:: bash
676668
677-
If there are arguments:
669+
python -m idlelib [options] [file ...]
678670
679-
* If ``-``, ``-c``, or ``r`` is used, all arguments are placed in
680-
``sys.argv[1:...]`` and ``sys.argv[0]`` is set to ``''``, ``'-c'``,
681-
or ``'-r'``. No editor window is opened, even if that is the default
682-
set in the Options dialog.
671+
The following options are available:
672+
673+
.. option:: -c <command>
674+
675+
Run the specified Python command in the shell window.
676+
For example, pass ``-c "print('Hello, World!')"``.
677+
On Windows, the outer quotes must be double quotes as shown.
678+
679+
.. option:: -d
680+
681+
Enable the debugger and open the shell window.
682+
683+
.. option:: -e
684+
685+
Open an editor window.
686+
687+
.. option:: -h
688+
689+
Print a help message with legal combinations of options and exit.
690+
691+
.. option:: -i
692+
693+
Open a shell window.
694+
695+
.. option:: -r <file>
696+
697+
Run the specified file in the shell window.
698+
699+
.. option:: -s
700+
701+
Run the startup file (as defined by the environment variables :envvar:`IDLESTARTUP` or :envvar:`PYTHONSTARTUP`) before opening the shell window.
702+
703+
.. option:: -t <title>
704+
705+
Set the title of the shell window.
706+
707+
.. option:: -
708+
709+
Read and execute standard input in the shell window. This option must be the last one before any arguments.
710+
711+
If arguments are provided:
712+
713+
- If ``-``, ``-c``, or ``-r`` is used, all arguments are placed in ``sys.argv[1:]``,
714+
and ``sys.argv[0]`` is set to ``''``, ``'-c'``, or ``'-r'`` respectively.
715+
No editor window is opened, even if that is the default set in the *Options* dialog.
716+
- Otherwise, arguments are treated as files to be opened for editing, and ``sys.argv`` reflects the arguments passed to IDLE itself.
683717

684-
* Otherwise, arguments are files opened for editing and
685-
``sys.argv`` reflects the arguments passed to IDLE itself.
686718

687719
Startup failure
688720
^^^^^^^^^^^^^^^

Doc/library/multiprocessing.rst

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ Contexts and start methods
107107
Depending on the platform, :mod:`multiprocessing` supports three ways
108108
to start a process. These *start methods* are
109109

110+
.. _multiprocessing-start-method-spawn:
111+
110112
*spawn*
111113
The parent process starts a fresh Python interpreter process. The
112114
child process will only inherit those resources necessary to run
@@ -117,6 +119,8 @@ to start a process. These *start methods* are
117119

118120
Available on POSIX and Windows platforms. The default on Windows and macOS.
119121

122+
.. _multiprocessing-start-method-fork:
123+
120124
*fork*
121125
The parent process uses :func:`os.fork` to fork the Python
122126
interpreter. The child process, when it begins, is effectively
@@ -137,6 +141,8 @@ to start a process. These *start methods* are
137141
raise a :exc:`DeprecationWarning`. Use a different start method.
138142
See the :func:`os.fork` documentation for further explanation.
139143

144+
.. _multiprocessing-start-method-forkserver:
145+
140146
*forkserver*
141147
When the program starts and selects the *forkserver* start method,
142148
a server process is spawned. From then on, whenever a new process
@@ -374,35 +380,40 @@ However, if you really do need to use some shared data then
374380
proxies.
375381

376382
A manager returned by :func:`Manager` will support types
377-
:class:`list`, :class:`dict`, :class:`~managers.Namespace`, :class:`Lock`,
383+
:class:`list`, :class:`dict`, :class:`set`, :class:`~managers.Namespace`, :class:`Lock`,
378384
:class:`RLock`, :class:`Semaphore`, :class:`BoundedSemaphore`,
379385
:class:`Condition`, :class:`Event`, :class:`Barrier`,
380386
:class:`Queue`, :class:`Value` and :class:`Array`. For example, ::
381387

382388
from multiprocessing import Process, Manager
383389

384-
def f(d, l):
390+
def f(d, l, s):
385391
d[1] = '1'
386392
d['2'] = 2
387393
d[0.25] = None
388394
l.reverse()
395+
s.add('a')
396+
s.add('b')
389397

390398
if __name__ == '__main__':
391399
with Manager() as manager:
392400
d = manager.dict()
393401
l = manager.list(range(10))
402+
s = manager.set()
394403

395-
p = Process(target=f, args=(d, l))
404+
p = Process(target=f, args=(d, l, s))
396405
p.start()
397406
p.join()
398407

399408
print(d)
400409
print(l)
410+
print(s)
401411

402412
will print ::
403413

404414
{0.25: None, 1: '1', '2': 2}
405415
[9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
416+
{'a', 'b'}
406417

407418
Server process managers are more flexible than using shared memory objects
408419
because they can be made to support arbitrary object types. Also, a single
@@ -1936,6 +1947,15 @@ their parent process exits. The manager classes are defined in the
19361947

19371948
Create a shared :class:`list` object and return a proxy for it.
19381949

1950+
.. method:: set()
1951+
set(sequence)
1952+
set(mapping)
1953+
1954+
Create a shared :class:`set` object and return a proxy for it.
1955+
1956+
.. versionadded:: next
1957+
:class:`set` support was added.
1958+
19391959
.. versionchanged:: 3.6
19401960
Shared objects are capable of being nested. For example, a shared
19411961
container object such as a shared list can contain other shared objects
@@ -2987,6 +3007,9 @@ Beware of replacing :data:`sys.stdin` with a "file like object"
29873007

29883008
For more information, see :issue:`5155`, :issue:`5313` and :issue:`5331`
29893009

3010+
.. _multiprocessing-programming-spawn:
3011+
.. _multiprocessing-programming-forkserver:
3012+
29903013
The *spawn* and *forkserver* start methods
29913014
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
29923015

Doc/library/sys.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -771,8 +771,8 @@ always available. Unless explicitly noted otherwise, all variables are read-only
771771

772772
.. function:: getdefaultencoding()
773773

774-
Return the name of the current default string encoding used by the Unicode
775-
implementation.
774+
Return ``'utf-8'``. This is the name of the default string encoding, used
775+
in methods like :meth:`str.encode`.
776776

777777

778778
.. function:: getdlopenflags()

Doc/library/wsgiref.rst

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ in type annotations.
119119
applications to set up dummy environments. It should NOT be used by actual WSGI
120120
servers or applications, since the data is fake!
121121

122-
Example usage::
122+
Example usage (see also :func:`~wsgiref.simple_server.demo_app`
123+
for another example)::
123124

124125
from wsgiref.util import setup_testing_defaults
125126
from wsgiref.simple_server import make_server
@@ -312,6 +313,8 @@ request. (E.g., using the :func:`shift_path_info` function from
312313
as :mod:`wsgiref.simple_server`) is able to run a simple WSGI application
313314
correctly.
314315

316+
The *start_response* callable should follow the :class:`.StartResponse` protocol.
317+
315318

316319
.. class:: WSGIServer(server_address, RequestHandlerClass)
317320

@@ -679,7 +682,9 @@ input, output, and error streams.
679682

680683
This method can access the current error using ``sys.exception()``,
681684
and should pass that information to *start_response* when calling it (as
682-
described in the "Error Handling" section of :pep:`3333`).
685+
described in the "Error Handling" section of :pep:`3333`). In particular,
686+
the *start_response* callable should follow the :class:`.StartResponse`
687+
protocol.
683688

684689
The default implementation just uses the :attr:`error_status`,
685690
:attr:`error_headers`, and :attr:`error_body` attributes to generate an output
@@ -781,7 +786,7 @@ in :pep:`3333`.
781786
.. versionadded:: 3.11
782787

783788

784-
.. class:: StartResponse()
789+
.. class:: StartResponse
785790

786791
A :class:`typing.Protocol` describing :pep:`start_response()
787792
<3333#the-start-response-callable>`
@@ -816,7 +821,8 @@ in :pep:`3333`.
816821
Examples
817822
--------
818823

819-
This is a working "Hello World" WSGI application::
824+
This is a working "Hello World" WSGI application, where the *start_response*
825+
callable should follow the :class:`.StartResponse` protocol::
820826

821827
"""
822828
Every WSGI application must have an application object - a callable

0 commit comments

Comments
 (0)