Skip to content

Commit b71383e

Browse files
authored
Merge branch 'main' into gc_count_tsan
2 parents 9908633 + c714b56 commit b71383e

40 files changed

Lines changed: 628 additions & 354 deletions

Doc/library/traceback.rst

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,7 @@ Module-Level Functions
147147
:ref:`traceback object <traceback-objects>` *tb*. It is useful
148148
for alternate formatting of stack traces. The optional *limit* argument has
149149
the same meaning as for :func:`print_tb`. A "pre-processed" stack trace
150-
entry is a :class:`FrameSummary` object containing attributes
151-
:attr:`~FrameSummary.filename`, :attr:`~FrameSummary.lineno`,
152-
:attr:`~FrameSummary.name`, and :attr:`~FrameSummary.line` representing the
150+
entry is a :class:`FrameSummary` object with attributes representing the
153151
information that is usually printed for a stack trace.
154152

155153

@@ -181,7 +179,7 @@ Module-Level Functions
181179
.. function:: format_exception_only(exc, /[, value], *, show_group=False)
182180

183181
Format the exception part of a traceback using an exception value such as
184-
given by :data:`sys.last_value`. The return value is a list of strings, each
182+
given by :data:`sys.last_exc`. The return value is a list of strings, each
185183
ending in a newline. The list contains the exception's message, which is
186184
normally a single string; however, for :exc:`SyntaxError` exceptions, it
187185
contains several lines that (when printed) display detailed information
@@ -347,7 +345,7 @@ the module-level functions described above.
347345

348346
.. attribute:: exc_type
349347

350-
The class of the original traceback.
348+
The class of the original exception.
351349

352350
.. deprecated:: 3.13
353351

@@ -391,7 +389,7 @@ the module-level functions described above.
391389

392390
For syntax errors - the compiler error message.
393391

394-
.. classmethod:: from_exception(exc, *, limit=None, lookup_lines=True, capture_locals=False)
392+
.. classmethod:: from_exception(exc, *, limit=None, lookup_lines=True, capture_locals=False, compact=False, max_group_width=15, max_group_depth=10)
395393

396394
Capture an exception for later rendering. *limit*, *lookup_lines* and
397395
*capture_locals* are as for the :class:`StackSummary` class.

Doc/using/configure.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,15 @@ General Options
473473

474474
.. versionadded:: 3.15
475475

476+
.. option:: --with-build-details-suffix=[yes|SUFFIX]
477+
478+
Rename ``build-details.json`` to permit multiple co-located Python
479+
installs. If a custom ``SUFFIX`` is supplied it is used verbatim,
480+
otherwise one will be generated from the ``MULTIARCH`` tag with
481+
``-free-threading`` and ``-debug``, as appropriate.
482+
483+
.. versionadded:: 3.16
484+
476485

477486
C compiler options
478487
------------------

Doc/whatsnew/3.16.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,12 @@ Build changes
227227

228228
.. _libmpdec: https://www.bytereef.org/mpdecimal/
229229

230+
* Add a :option:`--with-build-details-suffix` configure flag to allow
231+
Linux distributions that co-install multiple versions of Python in the
232+
same tree to avoid ``build-details.json`` clashes.
233+
234+
(Contributed by Stefano Rivera in :gh:`131372`.)
235+
230236

231237
C API changes
232238
=============

Lib/_collections_abc.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -461,8 +461,8 @@ def __subclasshook__(cls, C):
461461
class _CallableGenericAlias(GenericAlias):
462462
""" Represent `Callable[argtypes, resulttype]`.
463463
464-
This sets ``__args__`` to a tuple containing the flattened ``argtypes``
465-
followed by ``resulttype``.
464+
This sets ``__args__`` to a tuple containing the flattened
465+
``argtypes`` followed by ``resulttype``.
466466
467467
Example: ``Callable[[int, str], float]`` sets ``__args__`` to
468468
``(int, str, float)``.
@@ -928,8 +928,9 @@ def __delitem__(self, key):
928928
__marker = object()
929929

930930
def pop(self, key, default=__marker):
931-
'''D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
932-
If key is not found, d is returned if given, otherwise KeyError is raised.
931+
'''D.pop(k[,d]) -> v, remove specified key and return the corresponding
932+
value. If key is not found, d is returned if given, otherwise
933+
KeyError is raised.
933934
'''
934935
try:
935936
value = self[key]
@@ -963,9 +964,12 @@ def clear(self):
963964

964965
def update(self, other=(), /, **kwds):
965966
''' D.update([E, ]**F) -> None. Update D from mapping/iterable E and F.
966-
If E present and has a .keys() method, does: for k in E.keys(): D[k] = E[k]
967-
If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v
968-
In either case, this is followed by: for k, v in F.items(): D[k] = v
967+
If E present and has a .keys() method, does:
968+
for k in E.keys(): D[k] = E[k]
969+
If E present and lacks .keys() method, does:
970+
for (k, v) in E: D[k] = v
971+
In either case, this is followed by:
972+
for k, v in F.items(): D[k] = v
969973
'''
970974
if isinstance(other, Mapping):
971975
for key in other:
@@ -1030,8 +1034,8 @@ def __reversed__(self):
10301034
yield self[i]
10311035

10321036
def index(self, value, start=0, stop=None):
1033-
'''S.index(value, [start, [stop]]) -> integer -- return first index of value.
1034-
Raises ValueError if the value is not present.
1037+
'''S.index(value, [start, [stop]]) -> integer -- return first index of
1038+
value. Raises ValueError if the value is not present.
10351039
10361040
Supporting start and stop arguments is optional, but
10371041
recommended.
@@ -1139,15 +1143,16 @@ def reverse(self):
11391143
self[i], self[n-i-1] = self[n-i-1], self[i]
11401144

11411145
def extend(self, values):
1142-
'S.extend(iterable) -- extend sequence by appending elements from the iterable'
1146+
"""S.extend(iterable) -- extend sequence by appending elements from the
1147+
iterable"""
11431148
if values is self:
11441149
values = list(values)
11451150
for v in values:
11461151
self.append(v)
11471152

11481153
def pop(self, index=-1):
1149-
'''S.pop([index]) -> item -- remove and return item at index (default last).
1150-
Raise IndexError if list is empty or index is out of range.
1154+
'''S.pop([index]) -> item -- remove and return item at index (default
1155+
last). Raise IndexError if list is empty or index is out of range.
11511156
'''
11521157
v = self[index]
11531158
del self[index]

Lib/enum.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -702,26 +702,27 @@ def __call__(cls, value, names=_not_given, *values, module=None, qualname=None,
702702
"""
703703
Either returns an existing member, or creates a new enum class.
704704
705-
This method is used both when an enum class is given a value to match
706-
to an enumeration member (i.e. Color(3)) and for the functional API
707-
(i.e. Color = Enum('Color', names='RED GREEN BLUE')).
705+
This method is used both when an enum class is given a value to
706+
match to an enumeration member (i.e. Color(3)) and for the
707+
functional API (i.e. Color = Enum('Color', names='RED GREEN BLUE')).
708708
709709
The value lookup branch is chosen if the enum is final.
710710
711711
When used for the functional API:
712712
713713
`value` will be the name of the new class.
714714
715-
`names` should be either a string of white-space/comma delimited names
716-
(values will start at `start`), or an iterator/mapping of name, value pairs.
715+
`names` should be either a string of white-space/comma delimited
716+
names (values will start at `start`), or an iterator/mapping of
717+
name, value pairs.
717718
718719
`module` should be set to the module this class is being created in;
719-
if it is not set, an attempt to find that module will be made, but if
720-
it fails the class will not be picklable.
720+
if it is not set, an attempt to find that module will be made, but
721+
if it fails the class will not be picklable.
721722
722-
`qualname` should be set to the actual location this class can be found
723-
at in its module; by default it is set to the global scope. If this is
724-
not correct, unpickling will fail in some circumstances.
723+
`qualname` should be set to the actual location this class can be
724+
found at in its module; by default it is set to the global scope.
725+
If this is not correct, unpickling will fail in some circumstances.
725726
726727
`type`, if set, will be mixed in as the first base class.
727728
"""
@@ -819,8 +820,8 @@ def __members__(cls):
819820
"""
820821
Returns a mapping of member name->value.
821822
822-
This mapping lists all enum members, including aliases. Note that this
823-
is a read-only view of the internal mapping.
823+
This mapping lists all enum members, including aliases. Note that
824+
this is a read-only view of the internal mapping.
824825
"""
825826
return MappingProxyType(cls._member_map_)
826827

Lib/fractions.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -339,24 +339,24 @@ def from_float(cls, f):
339339
Beware that Fraction.from_float(0.3) != Fraction(3, 10).
340340
341341
"""
342+
if isinstance(f, float):
343+
return cls._from_coprime_ints(*f.as_integer_ratio())
342344
if isinstance(f, numbers.Integral):
343345
return cls(f)
344-
elif not isinstance(f, float):
345-
raise TypeError("%s.from_float() only takes floats, not %r (%s)" %
346-
(cls.__name__, f, type(f).__name__))
347-
return cls._from_coprime_ints(*f.as_integer_ratio())
346+
raise TypeError("%s.from_float() only takes floats, not %r (%s)" %
347+
(cls.__name__, f, type(f).__name__))
348348

349349
@classmethod
350350
def from_decimal(cls, dec):
351351
"""Converts a finite Decimal instance to a rational number, exactly."""
352352
from decimal import Decimal
353+
if isinstance(dec, Decimal):
354+
return cls._from_coprime_ints(*dec.as_integer_ratio())
353355
if isinstance(dec, numbers.Integral):
354-
dec = Decimal(int(dec))
355-
elif not isinstance(dec, Decimal):
356-
raise TypeError(
357-
"%s.from_decimal() only takes Decimals, not %r (%s)" %
358-
(cls.__name__, dec, type(dec).__name__))
359-
return cls._from_coprime_ints(*dec.as_integer_ratio())
356+
dec = int(dec)
357+
return cls._from_coprime_ints(*dec.as_integer_ratio())
358+
raise TypeError("%s.from_decimal() only takes Decimals, not %r (%s)" %
359+
(cls.__name__, dec, type(dec).__name__))
360360

361361
@classmethod
362362
def _from_coprime_ints(cls, numerator, denominator, /):

Lib/functools.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -563,16 +563,16 @@ def lru_cache(maxsize=128, typed=False):
563563
If *maxsize* is set to None, the LRU features are disabled and the cache
564564
can grow without bound.
565565
566-
If *typed* is True, arguments of different types will be cached separately.
567-
For example, f(decimal.Decimal("3.0")) and f(3.0) will be treated as
568-
distinct calls with distinct results. Some types such as str and int may
569-
be cached separately even when typed is false.
566+
If *typed* is True, arguments of different types will be cached
567+
separately. For example, f(decimal.Decimal("3.0")) and f(3.0) will be
568+
treated as distinct calls with distinct results. Some types such as
569+
str and int may be cached separately even when typed is false.
570570
571571
Arguments to the cached function must be hashable.
572572
573573
View the cache statistics named tuple (hits, misses, maxsize, currsize)
574-
with f.cache_info(). Clear the cache and statistics with f.cache_clear().
575-
Access the underlying function with f.__wrapped__.
574+
with f.cache_info(). Clear the cache and statistics with
575+
f.cache_clear(). Access the underlying function with f.__wrapped__.
576576
577577
See: https://en.wikipedia.org/wiki/Cache_replacement_policies#Least_recently_used_(LRU)
578578

Lib/glob.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ def glob(pathname, *, root_dir=None, dir_fd=None, recursive=False,
2525
The order of the returned list is undefined. Sort it if you need a
2626
particular order.
2727
28-
If `root_dir` is not None, it should be a path-like object specifying the
29-
root directory for searching. It has the same effect as changing the
30-
current directory before calling it (without actually
31-
changing it). If pathname is relative, the result will contain
32-
paths relative to `root_dir`.
28+
If `root_dir` is not None, it should be a path-like object specifying
29+
the root directory for searching. It has the same effect as changing
30+
the current directory before calling it (without actually changing it).
31+
If pathname is relative, the result will contain paths relative to
32+
`root_dir`.
3333
3434
If `dir_fd` is not None, it should be a file descriptor referring to a
3535
directory, and paths will then be relative to that directory.
3636
37-
If `include_hidden` is true, the patterns '*', '?', '**' will match hidden
38-
directories.
37+
If `include_hidden` is true, the patterns '*', '?', '**' will match
38+
hidden directories.
3939
4040
If `recursive` is true, the pattern '**' will match any files and
4141
zero or more directories and subdirectories.
@@ -56,16 +56,16 @@ def iglob(pathname, *, root_dir=None, dir_fd=None, recursive=False,
5656
particular order.
5757
5858
If `root_dir` is not None, it should be a path-like object specifying
59-
the root directory for searching. It has the same effect as changing
60-
the current directory before calling it (without actually
61-
changing it). If pathname is relative, the result will contain
62-
paths relative to `root_dir`.
59+
the root directory for searching. It has the same effect as changing
60+
the current directory before calling it (without actually changing it).
61+
If pathname is relative, the result will contain paths relative to
62+
`root_dir`.
6363
6464
If `dir_fd` is not None, it should be a file descriptor referring to a
6565
directory, and paths will then be relative to that directory.
6666
67-
If `include_hidden` is true, the patterns '*', '?', '**' will match hidden
68-
directories.
67+
If `include_hidden` is true, the patterns '*', '?', '**' will match
68+
hidden directories.
6969
7070
If `recursive` is true, the pattern '**' will match any files and
7171
zero or more directories and subdirectories.
@@ -279,15 +279,15 @@ def escape(pathname):
279279
def translate(pat, *, recursive=False, include_hidden=False, seps=None):
280280
"""Translate a pathname with shell wildcards to a regular expression.
281281
282-
If `recursive` is true, the pattern segment '**' will match any number of
283-
path segments.
282+
If `recursive` is true, the pattern segment '**' will match any number
283+
of path segments.
284284
285285
If `include_hidden` is true, wildcards can match path segments beginning
286286
with a dot ('.').
287287
288288
If a sequence of separator characters is given to `seps`, they will be
289-
used to split the pattern into segments and match path separators. If not
290-
given, os.path.sep and os.path.altsep (where available) are used.
289+
used to split the pattern into segments and match path separators. If
290+
not given, os.path.sep and os.path.altsep (where available) are used.
291291
"""
292292
if not seps:
293293
if os.path.altsep:

0 commit comments

Comments
 (0)