Skip to content

Commit e99d76a

Browse files
Merge branch 'main' into gh-130698-pyrepl-ps1-exception
2 parents 9baac77 + 6d45cd8 commit e99d76a

File tree

20 files changed

+130
-16
lines changed

20 files changed

+130
-16
lines changed

Doc/c-api/conversion.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ The return value (*rv*) for these functions should be interpreted as follows:
4141
``rv + 1`` bytes would have been needed to succeed. ``str[size-1]`` is ``'\0'``
4242
in this case.
4343
44-
* When ``rv < 0``, "something bad happened." ``str[size-1]`` is ``'\0'`` in
44+
* When ``rv < 0``, the output conversion failed and ``str[size-1]`` is ``'\0'`` in
4545
this case too, but the rest of *str* is undefined. The exact cause of the error
4646
depends on the underlying platform.
4747

Doc/c-api/dict.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Dictionary Objects
5050
5151
.. c:function:: int PyDict_Contains(PyObject *p, PyObject *key)
5252
53-
Determine if dictionary *p* contains *key*. If an item in *p* is matches
53+
Determine if dictionary *p* contains *key*. If an item in *p* matches
5454
*key*, return ``1``, otherwise return ``0``. On error, return ``-1``.
5555
This is equivalent to the Python expression ``key in p``.
5656
@@ -198,7 +198,7 @@ Dictionary Objects
198198
.. c:function:: int PyDict_Pop(PyObject *p, PyObject *key, PyObject **result)
199199
200200
Remove *key* from dictionary *p* and optionally return the removed value.
201-
Do not raise :exc:`KeyError` if the key missing.
201+
Do not raise :exc:`KeyError` if the key is missing.
202202
203203
- If the key is present, set *\*result* to a new reference to the removed
204204
value if *result* is not ``NULL``, and return ``1``.
@@ -207,7 +207,7 @@ Dictionary Objects
207207
- On error, raise an exception and return ``-1``.
208208
209209
Similar to :meth:`dict.pop`, but without the default value and
210-
not raising :exc:`KeyError` if the key missing.
210+
not raising :exc:`KeyError` if the key is missing.
211211
212212
.. versionadded:: 3.13
213213

Doc/c-api/typeobj.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1260,7 +1260,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
12601260
This bit indicates that instances of the class have a :attr:`~object.__dict__`
12611261
attribute, and that the space for the dictionary is managed by the VM.
12621262

1263-
If this flag is set, :c:macro:`Py_TPFLAGS_HAVE_GC` should also be set.
1263+
If this flag is set, :c:macro:`Py_TPFLAGS_HAVE_GC` must also be set.
12641264

12651265
The type traverse function must call :c:func:`PyObject_VisitManagedDict`
12661266
and its clear function must call :c:func:`PyObject_ClearManagedDict`.
@@ -1278,6 +1278,8 @@ and :c:data:`PyType_Type` effectively act as defaults.)
12781278
This bit indicates that instances of the class should be weakly
12791279
referenceable.
12801280

1281+
If this flag is set, :c:macro:`Py_TPFLAGS_HAVE_GC` must also be set.
1282+
12811283
.. versionadded:: 3.12
12821284

12831285
**Inheritance:**

Doc/extending/newtypes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,8 @@ For an object to be weakly referenceable, the extension type must set the
560560
field. The legacy :c:member:`~PyTypeObject.tp_weaklistoffset` field should
561561
be left as zero.
562562

563+
If this flag is set, :c:macro:`Py_TPFLAGS_HAVE_GC` should also be set.
564+
563565
Concretely, here is how the statically declared type object would look::
564566

565567
static PyTypeObject TrivialType = {

Doc/whatsnew/3.15.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,14 @@ New features
951951
(Contributed by Victor Stinner in :gh:`111489`.)
952952

953953

954+
Changed C APIs
955+
--------------
956+
957+
* If the :c:macro:`Py_TPFLAGS_MANAGED_DICT` or :c:macro:`Py_TPFLAGS_MANAGED_WEAKREF`
958+
flag is set then :c:macro:`Py_TPFLAGS_HAVE_GC` must be set too.
959+
(Contributed by Sergey Miryanov in :gh:`134786`)
960+
961+
954962
Porting to Python 3.15
955963
----------------------
956964

Include/internal/pycore_stackref.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,8 @@ PyStackRef_IsTaggedInt(_PyStackRef i)
403403
static inline _PyStackRef
404404
PyStackRef_TagInt(intptr_t i)
405405
{
406-
assert(Py_ARITHMETIC_RIGHT_SHIFT(intptr_t, (i << Py_TAGGED_SHIFT), Py_TAGGED_SHIFT) == i);
406+
assert(Py_ARITHMETIC_RIGHT_SHIFT(intptr_t, (intptr_t)(((uintptr_t)i) << Py_TAGGED_SHIFT),
407+
Py_TAGGED_SHIFT) == i);
407408
return (_PyStackRef){ .bits = ((((uintptr_t)i) << Py_TAGGED_SHIFT) | Py_INT_TAG) };
408409
}
409410

Include/object.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ given type object has a specified feature.
529529
#define Py_TPFLAGS_INLINE_VALUES (1 << 2)
530530

531531
/* Placement of weakref pointers are managed by the VM, not by the type.
532-
* The VM will automatically set tp_weaklistoffset.
532+
* The VM will automatically set tp_weaklistoffset. Implies Py_TPFLAGS_HAVE_GC.
533533
*/
534534
#define Py_TPFLAGS_MANAGED_WEAKREF (1 << 3)
535535

Lib/email/contentmanager.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import email.charset
33
import email.message
44
import email.errors
5+
import sys
56
from email import quoprimime
67

78
class ContentManager:
@@ -142,22 +143,23 @@ def _encode_base64(data, max_line_length):
142143

143144

144145
def _encode_text(string, charset, cte, policy):
146+
# If max_line_length is 0 or None, there is no limit.
147+
maxlen = policy.max_line_length or sys.maxsize
145148
lines = string.encode(charset).splitlines()
146149
linesep = policy.linesep.encode('ascii')
147150
def embedded_body(lines): return linesep.join(lines) + linesep
148151
def normal_body(lines): return b'\n'.join(lines) + b'\n'
149152
if cte is None:
150153
# Use heuristics to decide on the "best" encoding.
151-
if max((len(x) for x in lines), default=0) <= policy.max_line_length:
154+
if max(map(len, lines), default=0) <= maxlen:
152155
try:
153156
return '7bit', normal_body(lines).decode('ascii')
154157
except UnicodeDecodeError:
155158
pass
156159
if policy.cte_type == '8bit':
157160
return '8bit', normal_body(lines).decode('ascii', 'surrogateescape')
158161
sniff = embedded_body(lines[:10])
159-
sniff_qp = quoprimime.body_encode(sniff.decode('latin-1'),
160-
policy.max_line_length)
162+
sniff_qp = quoprimime.body_encode(sniff.decode('latin-1'), maxlen)
161163
sniff_base64 = binascii.b2a_base64(sniff)
162164
# This is a little unfair to qp; it includes lineseps, base64 doesn't.
163165
if len(sniff_qp) > len(sniff_base64):
@@ -172,9 +174,9 @@ def normal_body(lines): return b'\n'.join(lines) + b'\n'
172174
data = normal_body(lines).decode('ascii', 'surrogateescape')
173175
elif cte == 'quoted-printable':
174176
data = quoprimime.body_encode(normal_body(lines).decode('latin-1'),
175-
policy.max_line_length)
177+
maxlen)
176178
elif cte == 'base64':
177-
data = _encode_base64(embedded_body(lines), policy.max_line_length)
179+
data = _encode_base64(embedded_body(lines), maxlen)
178180
else:
179181
raise ValueError("Unknown content transfer encoding {}".format(cte))
180182
return cte, data

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.2"
13+
_PIP_VERSION = "25.3"
1414

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

0 commit comments

Comments
 (0)