Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c796cfa

Browse files
Merge branch 'main' into hide-legacy-subinterpreters
2 parents 2274d6e + f268e32 commit c796cfa

39 files changed

Lines changed: 1611 additions & 1178 deletions

Doc/library/asyncio-stream.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ StreamReader
260260
buffer is reset. The :attr:`IncompleteReadError.partial` attribute
261261
may contain a portion of the separator.
262262

263-
The *separator* may also be an :term:`iterable` of separators. In this
263+
The *separator* may also be a tuple of separators. In this
264264
case the return value will be the shortest possible that has any
265265
separator as the suffix. For the purposes of :exc:`LimitOverrunError`,
266266
the shortest possible separator is considered to be the one that
@@ -270,7 +270,7 @@ StreamReader
270270

271271
.. versionchanged:: 3.13
272272

273-
The *separator* parameter may now be an :term:`iterable` of
273+
The *separator* parameter may now be a :class:`tuple` of
274274
separators.
275275

276276
.. method:: at_eof()

Doc/library/glob.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ The :mod:`glob` module defines the following functions:
7575
Using the "``**``" pattern in large directory trees may consume
7676
an inordinate amount of time.
7777

78+
.. note::
79+
This function may return duplicate path names if *pathname*
80+
contains multiple "``**``" patterns and *recursive* is true.
81+
7882
.. versionchanged:: 3.5
7983
Support for recursive globs using "``**``".
8084

@@ -94,6 +98,10 @@ The :mod:`glob` module defines the following functions:
9498
.. audit-event:: glob.glob pathname,recursive glob.iglob
9599
.. audit-event:: glob.glob/2 pathname,recursive,root_dir,dir_fd glob.iglob
96100

101+
.. note::
102+
This function may return duplicate path names if *pathname*
103+
contains multiple "``**``" patterns and *recursive* is true.
104+
97105
.. versionchanged:: 3.5
98106
Support for recursive globs using "``**``".
99107

Doc/library/platform.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,8 @@ Windows Platform
219219
default to an empty string).
220220

221221
As a hint: *ptype* is ``'Uniprocessor Free'`` on single processor NT machines
222-
and ``'Multiprocessor Free'`` on multi processor machines. The *'Free'* refers
223-
to the OS version being free of debugging code. It could also state *'Checked'*
222+
and ``'Multiprocessor Free'`` on multi processor machines. The ``'Free'`` refers
223+
to the OS version being free of debugging code. It could also state ``'Checked'``
224224
which means the OS version uses debugging code, i.e. code that checks arguments,
225225
ranges, etc.
226226

Doc/library/xml.etree.elementtree.rst

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -840,33 +840,28 @@ Functions
840840

841841
.. module:: xml.etree.ElementInclude
842842

843-
.. function:: xml.etree.ElementInclude.default_loader( href, parse, encoding=None)
844-
:module:
843+
.. function:: default_loader(href, parse, encoding=None)
845844

846-
Default loader. This default loader reads an included resource from disk. *href* is a URL.
847-
*parse* is for parse mode either "xml" or "text". *encoding*
848-
is an optional text encoding. If not given, encoding is ``utf-8``. Returns the
849-
expanded resource. If the parse mode is ``"xml"``, this is an ElementTree
850-
instance. If the parse mode is "text", this is a Unicode string. If the
851-
loader fails, it can return None or raise an exception.
845+
Default loader. This default loader reads an included resource from disk.
846+
*href* is a URL. *parse* is for parse mode either "xml" or "text".
847+
*encoding* is an optional text encoding. If not given, encoding is ``utf-8``.
848+
Returns the expanded resource.
849+
If the parse mode is ``"xml"``, this is an :class:`~xml.etree.ElementTree.Element` instance.
850+
If the parse mode is ``"text"``, this is a string.
851+
If the loader fails, it can return ``None`` or raise an exception.
852852

853853

854-
.. function:: xml.etree.ElementInclude.include( elem, loader=None, base_url=None, \
855-
max_depth=6)
856-
:module:
854+
.. function:: include(elem, loader=None, base_url=None, max_depth=6)
857855

858-
This function expands XInclude directives. *elem* is the root element. *loader* is
859-
an optional resource loader. If omitted, it defaults to :func:`default_loader`.
856+
This function expands XInclude directives in-place in tree pointed by *elem*.
857+
*elem* is either the root :class:`~xml.etree.ElementTree.Element` or an
858+
:class:`~xml.etree.ElementTree.ElementTree` instance to find such element.
859+
*loader* is an optional resource loader. If omitted, it defaults to :func:`default_loader`.
860860
If given, it should be a callable that implements the same interface as
861861
:func:`default_loader`. *base_url* is base URL of the original file, to resolve
862862
relative include file references. *max_depth* is the maximum number of recursive
863-
inclusions. Limited to reduce the risk of malicious content explosion. Pass a
864-
negative value to disable the limitation.
865-
866-
Returns the expanded resource. If the parse mode is
867-
``"xml"``, this is an ElementTree instance. If the parse mode is "text",
868-
this is a Unicode string. If the loader fails, it can return None or
869-
raise an exception.
863+
inclusions. Limited to reduce the risk of malicious content explosion.
864+
Pass ``None`` to disable the limitation.
870865

871866
.. versionchanged:: 3.9
872867
Added the *base_url* and *max_depth* parameters.

Doc/whatsnew/3.13.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,10 @@ asyncio
324324
:exc:`asyncio.QueueShutDown`) for queue termination.
325325
(Contributed by Laurie Opperman and Yves Duprat in :gh:`104228`.)
326326

327+
* Accept a tuple of separators in :meth:`asyncio.StreamReader.readuntil`,
328+
stopping when one of them is encountered.
329+
(Contributed by Bruce Merry in :gh:`81322`.)
330+
327331
base64
328332
------
329333

Include/Python.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@
4545
# endif
4646
#endif
4747

48+
// gh-111506: The free-threaded build is not compatible with the limited API
49+
// or the stable ABI.
50+
#if defined(Py_LIMITED_API) && defined(Py_GIL_DISABLED)
51+
# error "The limited API is not currently supported in the free-threaded build"
52+
#endif
4853

4954
// Include Python header files
5055
#include "pyport.h"

Include/cpython/pylifecycle.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,23 @@ typedef struct {
6363
.gil = PyInterpreterConfig_OWN_GIL, \
6464
}
6565

66+
// gh-117649: The free-threaded build does not currently support single-phase
67+
// init extensions in subinterpreters. For now, we ensure that
68+
// `check_multi_interp_extensions` is always `1`, even in the legacy config.
69+
#ifdef Py_GIL_DISABLED
70+
# define _PyInterpreterConfig_LEGACY_CHECK_MULTI_INTERP_EXTENSIONS 1
71+
#else
72+
# define _PyInterpreterConfig_LEGACY_CHECK_MULTI_INTERP_EXTENSIONS 0
73+
#endif
74+
6675
#define _PyInterpreterConfig_LEGACY_INIT \
6776
{ \
6877
.use_main_obmalloc = 1, \
6978
.allow_fork = 1, \
7079
.allow_exec = 1, \
7180
.allow_threads = 1, \
7281
.allow_daemon_threads = 1, \
73-
.check_multi_interp_extensions = 0, \
82+
.check_multi_interp_extensions = _PyInterpreterConfig_LEGACY_CHECK_MULTI_INTERP_EXTENSIONS, \
7483
.gil = PyInterpreterConfig_SHARED_GIL, \
7584
}
7685

Include/internal/pycore_typeobject.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,18 @@ PyAPI_FUNC(PyObject*) _PySuper_Lookup(PyTypeObject *su_type, PyObject *su_obj,
152152

153153
extern PyObject* _PyType_GetFullyQualifiedName(PyTypeObject *type, char sep);
154154

155+
// Perform the following operation, in a thread-safe way when required by the
156+
// build mode.
157+
//
158+
// self->tp_flags = (self->tp_flags & ~mask) | flags;
159+
extern void _PyType_SetFlags(PyTypeObject *self, unsigned long mask,
160+
unsigned long flags);
161+
162+
// Like _PyType_SetFlags(), but apply the operation to self and any of its
163+
// subclasses without Py_TPFLAGS_IMMUTABLETYPE set.
164+
extern void _PyType_SetFlagsRecursive(PyTypeObject *self, unsigned long mask,
165+
unsigned long flags);
166+
155167

156168
#ifdef __cplusplus
157169
}

Lib/asyncio/streams.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -591,17 +591,17 @@ async def readuntil(self, separator=b'\n'):
591591
LimitOverrunError exception will be raised, and the data
592592
will be left in the internal buffer, so it can be read again.
593593
594-
The ``separator`` may also be an iterable of separators. In this
594+
The ``separator`` may also be a tuple of separators. In this
595595
case the return value will be the shortest possible that has any
596596
separator as the suffix. For the purposes of LimitOverrunError,
597597
the shortest possible separator is considered to be the one that
598598
matched.
599599
"""
600-
if isinstance(separator, bytes):
601-
separator = [separator]
602-
else:
603-
# Makes sure shortest matches wins, and supports arbitrary iterables
600+
if isinstance(separator, tuple):
601+
# Makes sure shortest matches wins
604602
separator = sorted(separator, key=len)
603+
else:
604+
separator = [separator]
605605
if not separator:
606606
raise ValueError('Separator should contain at least one element')
607607
min_seplen = len(separator[0])

Lib/test/support/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,12 @@ def requires_gil_enabled(msg="needs the GIL enabled"):
842842
"""Decorator for skipping tests on the free-threaded build."""
843843
return unittest.skipIf(Py_GIL_DISABLED, msg)
844844

845+
def expected_failure_if_gil_disabled():
846+
"""Expect test failure if the GIL is disabled."""
847+
if Py_GIL_DISABLED:
848+
return unittest.expectedFailure
849+
return lambda test_case: test_case
850+
845851
if Py_GIL_DISABLED:
846852
_header = 'PHBBInP'
847853
else:

0 commit comments

Comments
 (0)