Skip to content

Commit 37d87a0

Browse files
committed
Merge branch 'main' of https://github.com/python/cpython into unraisable-color
2 parents 53fb7a8 + 8943bb7 commit 37d87a0

15 files changed

Lines changed: 77 additions & 31 deletions

File tree

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
.github/** @ezio-melotti @hugovk @AA-Turner
99

1010
# pre-commit
11-
.pre-commit-config.yaml @hugovk @AlexWaygood
11+
.pre-commit-config.yaml @hugovk
1212
.ruff.toml @hugovk @AlexWaygood @AA-Turner
1313

1414
# Build system

Doc/c-api/long.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,10 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
372372
Set *\*value* to a signed C :c:expr:`int32_t` or :c:expr:`int64_t`
373373
representation of *obj*.
374374
375+
If *obj* is not an instance of :c:type:`PyLongObject`, first call its
376+
:meth:`~object.__index__` method (if present) to convert it to a
377+
:c:type:`PyLongObject`.
378+
375379
If the *obj* value is out of range, raise an :exc:`OverflowError`.
376380
377381
Set *\*value* and return ``0`` on success.

Doc/library/ctypes.rst

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -700,14 +700,10 @@ compiler does it. It is possible to override this behavior entirely by specifyi
700700
:attr:`~Structure._layout_` class attribute in the subclass definition; see
701701
the attribute documentation for details.
702702

703-
It is possible to specify the maximum alignment for the fields by setting
704-
the :attr:`~Structure._pack_` class attribute to a positive integer.
705-
This matches what ``#pragma pack(n)`` does in MSVC.
706-
707-
It is also possible to set a minimum alignment for how the subclass itself is packed in the
708-
same way ``#pragma align(n)`` works in MSVC.
709-
This can be achieved by specifying a :attr:`~Structure._align_` class attribute
710-
in the subclass definition.
703+
It is possible to specify the maximum alignment for the fields and/or for the
704+
structure itself by setting the class attributes :attr:`~Structure._pack_`
705+
and/or :attr:`~Structure._align_`, respectively.
706+
See the attribute documentation for details.
711707

712708
:mod:`ctypes` uses the native byte order for Structures and Unions. To build
713709
structures with non-native byte order, you can use one of the
@@ -2792,11 +2788,18 @@ fields, or any other data types containing pointer type fields.
27922788
.. attribute:: _pack_
27932789

27942790
An optional small integer that allows overriding the alignment of
2795-
structure fields in the instance. :attr:`_pack_` must already be defined
2796-
when :attr:`_fields_` is assigned, otherwise it will have no effect.
2797-
Setting this attribute to 0 is the same as not setting it at all.
2791+
structure fields in the instance.
2792+
2793+
This is only implemented for the MSVC-compatible memory layout
2794+
(see :attr:`_layout_`).
27982795

2799-
This is only implemented for the MSVC-compatible memory layout.
2796+
Setting :attr:`!_pack_` to 0 is the same as not setting it at all.
2797+
Otherwise, the value must be a positive power of two.
2798+
The effect is equivalent to ``#pragma pack(N)`` in C, except
2799+
:mod:`ctypes` may allow larger *n* than what the compiler accepts.
2800+
2801+
:attr:`!_pack_` must already be defined
2802+
when :attr:`_fields_` is assigned, otherwise it will have no effect.
28002803

28012804
.. deprecated-removed:: 3.14 3.19
28022805

@@ -2809,9 +2812,22 @@ fields, or any other data types containing pointer type fields.
28092812

28102813
.. attribute:: _align_
28112814

2812-
An optional small integer that allows overriding the alignment of
2815+
An optional small integer that allows increasing the alignment of
28132816
the structure when being packed or unpacked to/from memory.
2814-
Setting this attribute to 0 is the same as not setting it at all.
2817+
2818+
The value must not be negative.
2819+
The effect is equivalent to ``__attribute__((aligned(N)))`` on GCC
2820+
or ``#pragma align(N)`` on MSVC, except :mod:`ctypes` may allow
2821+
values that the compiler would reject.
2822+
2823+
:attr:`!_align_` can only *increase* a structure's alignment
2824+
requirements. Setting it to 0 or 1 has no effect.
2825+
2826+
Using values that are not powers of two is discouraged and may lead to
2827+
surprising behavior.
2828+
2829+
:attr:`!_align_` must already be defined
2830+
when :attr:`_fields_` is assigned, otherwise it will have no effect.
28152831

28162832
.. versionadded:: 3.13
28172833

Doc/library/fractions.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
The :mod:`fractions` module provides support for rational number arithmetic.
1515

1616

17-
A Fraction instance can be constructed from a pair of integers, from
18-
another rational number, or from a string.
17+
A Fraction instance can be constructed from a pair of rational numbers, from
18+
a single number, or from a string.
1919

2020
.. index:: single: as_integer_ratio()
2121

@@ -25,8 +25,8 @@ another rational number, or from a string.
2525

2626
The first version requires that *numerator* and *denominator* are instances
2727
of :class:`numbers.Rational` and returns a new :class:`Fraction` instance
28-
with value equal to ``numerator/denominator`` where the denominator is positive.
29-
If *denominator* is ``0``, it raises a :exc:`ZeroDivisionError`.
28+
with a value equal to ``numerator/denominator``.
29+
If *denominator* is zero, it raises a :exc:`ZeroDivisionError`.
3030

3131
The second version requires that *number* is an instance of
3232
:class:`numbers.Rational` or has the :meth:`!as_integer_ratio` method
@@ -125,7 +125,8 @@ another rational number, or from a string.
125125

126126
.. attribute:: denominator
127127

128-
Denominator of the Fraction in lowest term.
128+
Denominator of the Fraction in lowest terms.
129+
Guaranteed to be positive.
129130

130131

131132
.. method:: as_integer_ratio()

Doc/library/numbers.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ The numeric tower
6969

7070
.. attribute:: numerator
7171

72-
Abstract.
72+
Abstract. The numerator of this rational number.
7373

7474
.. attribute:: denominator
7575

76-
Abstract.
76+
Abstract. The denominator of this rational number.
7777

7878

7979
.. class:: Integral

Doc/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ sphinx~=8.2.0
1111

1212
blurb
1313

14-
sphinxext-opengraph~=0.10.0
14+
sphinxext-opengraph~=0.11.0
1515
sphinx-notfound-page~=1.0.0
1616

1717
# The theme used by the documentation is stored separately, so we need

Lib/ensurepip/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
__all__ = ["version", "bootstrap"]
13-
_PIP_VERSION = "25.1.1"
13+
_PIP_VERSION = "25.2"
1414

1515
# Directory of system wheel packages. Some Linux distribution packaging
1616
# policies recommend against bundling dependencies. For example, Fedora
1.74 MB
Binary file not shown.

Lib/numbers.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,18 +290,27 @@ def conjugate(self):
290290

291291

292292
class Rational(Real):
293-
""".numerator and .denominator should be in lowest terms."""
293+
"""To Real, Rational adds numerator and denominator properties.
294+
295+
The numerator and denominator values should be in lowest terms,
296+
with a positive denominator.
297+
"""
294298

295299
__slots__ = ()
296300

297301
@property
298302
@abstractmethod
299303
def numerator(self):
304+
"""The numerator of a rational number in lowest terms."""
300305
raise NotImplementedError
301306

302307
@property
303308
@abstractmethod
304309
def denominator(self):
310+
"""The denominator of a rational number in lowest terms.
311+
312+
This denominator should be positive.
313+
"""
305314
raise NotImplementedError
306315

307316
# Concrete implementation of Real's conversion to float.

Lib/tarfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ def __init__(self, name, mode, comptype, fileobj, bufsize,
353353
fileobj = _StreamProxy(fileobj)
354354
comptype = fileobj.getcomptype()
355355

356-
self.name = name or ""
356+
self.name = os.fspath(name) if name is not None else ""
357357
self.mode = mode
358358
self.comptype = comptype
359359
self.fileobj = fileobj

0 commit comments

Comments
 (0)