Skip to content

Commit c4342e3

Browse files
committed
Merge branch 'main' into subprocess-fast-wait
2 parents 97cc3be + f84ea11 commit c4342e3

Some content is hidden

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

46 files changed

+630
-179
lines changed

.github/CODEOWNERS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@
6363
.azure-pipelines/ @AA-Turner
6464

6565
# GitHub & related scripts
66-
.github/ @ezio-melotti @hugovk @AA-Turner
67-
Tools/build/compute-changes.py @AA-Turner
66+
.github/ @ezio-melotti @hugovk @AA-Turner @webknjaz
67+
Tools/build/compute-changes.py @AA-Turner @hugovk @webknjaz
6868
Tools/build/verify_ensurepip_wheels.py @AA-Turner @pfmoore @pradyunsg
6969

7070
# Pre-commit

Doc/c-api/lifecycle.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,8 @@ To allocate and free memory, see :ref:`allocating-objects`.
256256
collection (i.e., the :c:macro:`Py_TPFLAGS_HAVE_GC` flag is set); this may
257257
change in the future.
258258
259+
.. versionadded:: 3.4
260+
259261
260262
.. c:function:: int PyObject_CallFinalizerFromDealloc(PyObject *op)
261263
@@ -266,6 +268,8 @@ To allocate and free memory, see :ref:`allocating-objects`.
266268
should happen. Otherwise, this function returns 0 and destruction can
267269
continue normally.
268270
271+
.. versionadded:: 3.4
272+
269273
.. seealso::
270274
271275
:c:member:`~PyTypeObject.tp_dealloc` for example code.

Doc/library/multiprocessing.rst

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,22 +1234,32 @@ Miscellaneous
12341234
.. versionchanged:: 3.11
12351235
Accepts a :term:`path-like object`.
12361236

1237-
.. function:: set_forkserver_preload(module_names)
1237+
.. function:: set_forkserver_preload(module_names, *, on_error='ignore')
12381238

12391239
Set a list of module names for the forkserver main process to attempt to
12401240
import so that their already imported state is inherited by forked
1241-
processes. Any :exc:`ImportError` when doing so is silently ignored.
1242-
This can be used as a performance enhancement to avoid repeated work
1243-
in every process.
1241+
processes. This can be used as a performance enhancement to avoid repeated
1242+
work in every process.
12441243

12451244
For this to work, it must be called before the forkserver process has been
12461245
launched (before creating a :class:`Pool` or starting a :class:`Process`).
12471246

1247+
The *on_error* parameter controls how :exc:`ImportError` exceptions during
1248+
module preloading are handled: ``"ignore"`` (default) silently ignores
1249+
failures, ``"warn"`` causes the forkserver subprocess to emit an
1250+
:exc:`ImportWarning` to stderr, and ``"fail"`` causes the forkserver
1251+
subprocess to exit with the exception traceback on stderr, making
1252+
subsequent process creation fail with :exc:`EOFError` or
1253+
:exc:`ConnectionError`.
1254+
12481255
Only meaningful when using the ``'forkserver'`` start method.
12491256
See :ref:`multiprocessing-start-methods`.
12501257

12511258
.. versionadded:: 3.4
12521259

1260+
.. versionchanged:: next
1261+
Added the *on_error* parameter.
1262+
12531263
.. function:: set_start_method(method, force=False)
12541264

12551265
Set the method which should be used to start child processes.

Doc/library/stdtypes.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2562,6 +2562,19 @@ expression support in the :mod:`re` module).
25622562
after the separator. If the separator is not found, return a 3-tuple containing
25632563
two empty strings, followed by the string itself.
25642564

2565+
For example:
2566+
2567+
.. doctest::
2568+
2569+
>>> 'Monty Python'.rpartition(' ')
2570+
('Monty', ' ', 'Python')
2571+
>>> "Monty Python's Flying Circus".rpartition(' ')
2572+
("Monty Python's Flying", ' ', 'Circus')
2573+
>>> 'Monty Python'.rpartition('-')
2574+
('', '', 'Monty Python')
2575+
2576+
See also :meth:`partition`.
2577+
25652578

25662579
.. method:: str.rsplit(sep=None, maxsplit=-1)
25672580

Doc/library/tkinter.rst

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,12 @@ the modern themed widget set and API::
177177
.. attribute:: master
178178

179179
The widget object that contains this widget. For :class:`Tk`, the
180-
*master* is :const:`None` because it is the main window. The terms
180+
:attr:`!master` is :const:`None` because it is the main window. The terms
181181
*master* and *parent* are similar and sometimes used interchangeably
182182
as argument names; however, calling :meth:`winfo_parent` returns a
183-
string of the widget name whereas :attr:`master` returns the object.
183+
string of the widget name whereas :attr:`!master` returns the object.
184184
*parent*/*child* reflects the tree-like relationship while
185-
*master*/*slave* reflects the container structure.
185+
*master* (or *container*)/*content* reflects the container structure.
186186

187187
.. attribute:: children
188188

@@ -638,15 +638,15 @@ The Packer
638638
.. index:: single: packing (widgets)
639639

640640
The packer is one of Tk's geometry-management mechanisms. Geometry managers
641-
are used to specify the relative positioning of widgets within their container -
642-
their mutual *master*. In contrast to the more cumbersome *placer* (which is
641+
are used to specify the relative positioning of widgets within their container.
642+
In contrast to the more cumbersome *placer* (which is
643643
used less commonly, and we do not cover here), the packer takes qualitative
644644
relationship specification - *above*, *to the left of*, *filling*, etc - and
645645
works everything out to determine the exact placement coordinates for you.
646646

647-
The size of any *master* widget is determined by the size of the "slave widgets"
648-
inside. The packer is used to control where slave widgets appear inside the
649-
master into which they are packed. You can pack widgets into frames, and frames
647+
The size of any container widget is determined by the size of the "content widgets"
648+
inside. The packer is used to control where content widgets appear inside the
649+
container into which they are packed. You can pack widgets into frames, and frames
650650
into other frames, in order to achieve the kind of layout you desire.
651651
Additionally, the arrangement is dynamically adjusted to accommodate incremental
652652
changes to the configuration, once it is packed.
@@ -673,7 +673,7 @@ For more extensive information on the packer and the options that it can take,
673673
see the man pages and page 183 of John Ousterhout's book.
674674

675675
anchor
676-
Anchor type. Denotes where the packer is to place each slave in its parcel.
676+
Anchor type. Denotes where the packer is to place each content in its parcel.
677677

678678
expand
679679
Boolean, ``0`` or ``1``.
@@ -682,10 +682,10 @@ fill
682682
Legal values: ``'x'``, ``'y'``, ``'both'``, ``'none'``.
683683

684684
ipadx and ipady
685-
A distance - designating internal padding on each side of the slave widget.
685+
A distance - designating internal padding on each side of the content.
686686

687687
padx and pady
688-
A distance - designating external padding on each side of the slave widget.
688+
A distance - designating external padding on each side of the content.
689689

690690
side
691691
Legal values are: ``'left'``, ``'right'``, ``'top'``, ``'bottom'``.
@@ -758,8 +758,8 @@ subclassed from the :class:`Wm` class, and so can call the :class:`Wm` methods
758758
directly.
759759

760760
To get at the toplevel window that contains a given widget, you can often just
761-
refer to the widget's master. Of course if the widget has been packed inside of
762-
a frame, the master won't represent a toplevel window. To get at the toplevel
761+
refer to the widget's :attr:`master`. Of course if the widget has been packed inside of
762+
a frame, the :attr:`!master` won't represent a toplevel window. To get at the toplevel
763763
window that contains an arbitrary widget, you can call the :meth:`_root` method.
764764
This method begins with an underscore to denote the fact that this function is
765765
part of the implementation, and not an interface to Tk functionality.

Include/internal/pycore_opcode_metadata.h

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

Include/internal/pycore_uop_metadata.h

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

Lib/annotationlib.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,13 @@ def __eq__(self, other):
279279
# because dictionaries are not hashable.
280280
and self.__globals__ is other.__globals__
281281
and self.__forward_is_class__ == other.__forward_is_class__
282-
and self.__cell__ == other.__cell__
282+
# Two separate cells are always considered unequal in forward refs.
283+
and (
284+
{name: id(cell) for name, cell in self.__cell__.items()}
285+
== {name: id(cell) for name, cell in other.__cell__.items()}
286+
if isinstance(self.__cell__, dict) and isinstance(other.__cell__, dict)
287+
else self.__cell__ is other.__cell__
288+
)
283289
and self.__owner__ == other.__owner__
284290
and (
285291
(tuple(sorted(self.__extra_names__.items())) if self.__extra_names__ else None) ==
@@ -293,7 +299,10 @@ def __hash__(self):
293299
self.__forward_module__,
294300
id(self.__globals__), # dictionaries are not hashable, so hash by identity
295301
self.__forward_is_class__,
296-
tuple(sorted(self.__cell__.items())) if isinstance(self.__cell__, dict) else self.__cell__,
302+
( # cells are not hashable as well
303+
tuple(sorted([(name, id(cell)) for name, cell in self.__cell__.items()]))
304+
if isinstance(self.__cell__, dict) else id(self.__cell__),
305+
),
297306
self.__owner__,
298307
tuple(sorted(self.__extra_names__.items())) if self.__extra_names__ else None,
299308
))

Lib/email/_header_value_parser.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ def make_quoted_pairs(value):
101101
return str(value).replace('\\', '\\\\').replace('"', '\\"')
102102

103103

104+
def make_parenthesis_pairs(value):
105+
"""Escape parenthesis and backslash for use within a comment."""
106+
return str(value).replace('\\', '\\\\') \
107+
.replace('(', '\\(').replace(')', '\\)')
108+
109+
104110
def quote_string(value):
105111
escaped = make_quoted_pairs(value)
106112
return f'"{escaped}"'
@@ -943,7 +949,7 @@ def value(self):
943949
return ' '
944950

945951
def startswith_fws(self):
946-
return True
952+
return self and self[0] in WSP
947953

948954

949955
class ValueTerminal(Terminal):
@@ -2963,6 +2969,13 @@ def _refold_parse_tree(parse_tree, *, policy):
29632969
[ValueTerminal(make_quoted_pairs(p), 'ptext')
29642970
for p in newparts] +
29652971
[ValueTerminal('"', 'ptext')])
2972+
if part.token_type == 'comment':
2973+
newparts = (
2974+
[ValueTerminal('(', 'ptext')] +
2975+
[ValueTerminal(make_parenthesis_pairs(p), 'ptext')
2976+
if p.token_type == 'ptext' else p
2977+
for p in newparts] +
2978+
[ValueTerminal(')', 'ptext')])
29662979
if not part.as_ew_allowed:
29672980
wrap_as_ew_blocked += 1
29682981
newparts.append(end_ew_not_allowed)

Lib/multiprocessing/context.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,15 @@ def set_executable(self, executable):
177177
from .spawn import set_executable
178178
set_executable(executable)
179179

180-
def set_forkserver_preload(self, module_names):
180+
def set_forkserver_preload(self, module_names, *, on_error='ignore'):
181181
'''Set list of module names to try to load in forkserver process.
182-
This is really just a hint.
182+
183+
The on_error parameter controls how import failures are handled:
184+
"ignore" (default) silently ignores failures, "warn" emits warnings,
185+
and "fail" raises exceptions breaking the forkserver context.
183186
'''
184187
from .forkserver import set_forkserver_preload
185-
set_forkserver_preload(module_names)
188+
set_forkserver_preload(module_names, on_error=on_error)
186189

187190
def get_context(self, method=None):
188191
if method is None:

0 commit comments

Comments
 (0)