Skip to content

Commit 37f3e2e

Browse files
authored
Merge branch 'main' into gh150228
2 parents f2df6a6 + 71fc4c6 commit 37f3e2e

47 files changed

Lines changed: 2396 additions & 2345 deletions

Some content is hidden

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

Doc/library/array.rst

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ defined:
2222
+-----------+--------------------+-------------------+-----------------------+-------+
2323
| ``'B'`` | unsigned char | int | 1 | |
2424
+-----------+--------------------+-------------------+-----------------------+-------+
25-
| ``'u'`` | wchar_t | Unicode character | 2 | \(1) |
26-
+-----------+--------------------+-------------------+-----------------------+-------+
27-
| ``'w'`` | Py_UCS4 | Unicode character | 4 | \(2) |
25+
| ``'w'`` | Py_UCS4 | Unicode character | 4 | \(1) |
2826
+-----------+--------------------+-------------------+-----------------------+-------+
2927
| ``'h'`` | signed short | int | 2 | |
3028
+-----------+--------------------+-------------------+-----------------------+-------+
@@ -42,35 +40,24 @@ defined:
4240
+-----------+--------------------+-------------------+-----------------------+-------+
4341
| ``'Q'`` | unsigned long long | int | 8 | |
4442
+-----------+--------------------+-------------------+-----------------------+-------+
45-
| ``'e'`` | _Float16 | float | 2 | \(3) |
43+
| ``'e'`` | _Float16 | float | 2 | \(2) |
4644
+-----------+--------------------+-------------------+-----------------------+-------+
4745
| ``'f'`` | float | float | 4 | |
4846
+-----------+--------------------+-------------------+-----------------------+-------+
4947
| ``'d'`` | double | float | 8 | |
5048
+-----------+--------------------+-------------------+-----------------------+-------+
51-
| ``'Zf'`` | float complex | complex | 8 | \(4) |
49+
| ``'Zf'`` | float complex | complex | 8 | \(3) |
5250
+-----------+--------------------+-------------------+-----------------------+-------+
53-
| ``'Zd'`` | double complex | complex | 16 | \(4) |
51+
| ``'Zd'`` | double complex | complex | 16 | \(3) |
5452
+-----------+--------------------+-------------------+-----------------------+-------+
5553

5654

5755
Notes:
5856

5957
(1)
60-
It can be 16 bits or 32 bits depending on the platform.
61-
62-
.. versionchanged:: 3.9
63-
``array('u')`` now uses :c:type:`wchar_t` as C type instead of deprecated
64-
``Py_UNICODE``. This change doesn't affect its behavior because
65-
``Py_UNICODE`` is alias of :c:type:`wchar_t` since Python 3.3.
66-
67-
.. deprecated-removed:: 3.3 3.16
68-
Please migrate to ``'w'`` typecode.
69-
70-
(2)
7158
.. versionadded:: 3.13
7259

73-
(3)
60+
(2)
7461
The IEEE 754 binary16 "half precision" type was introduced in the 2008
7562
revision of the `IEEE 754 standard <ieee 754 standard_>`_.
7663
This type is not widely supported by C compilers. It's available
@@ -79,7 +66,7 @@ Notes:
7966

8067
.. versionadded:: 3.15
8168

82-
(4)
69+
(3)
8370
Complex types (``Zf`` and ``Zd``) are available unconditionally,
8471
regardless on support for complex types (the Annex G of the C11 standard)
8572
by the C compiler.
@@ -220,7 +207,7 @@ The module defines the following type:
220207
.. method:: fromunicode(ustr, /)
221208

222209
Extends this array with data from the given Unicode string.
223-
The array must have type code ``'u'`` or ``'w'``; otherwise a :exc:`ValueError` is raised.
210+
The array must have type code ``'w'``; otherwise a :exc:`ValueError` is raised.
224211
Use ``array.frombytes(unicodestring.encode(enc))`` to append Unicode data to an
225212
array of some other type.
226213

@@ -288,15 +275,15 @@ The module defines the following type:
288275

289276
.. method:: tounicode()
290277

291-
Convert the array to a Unicode string. The array must have a type ``'u'`` or ``'w'``;
278+
Convert the array to a Unicode string. The array must have a type ``'w'``;
292279
otherwise a :exc:`ValueError` is raised. Use ``array.tobytes().decode(enc)`` to
293280
obtain a Unicode string from an array of some other type.
294281

295282

296283
The string representation of array objects has the form
297284
``array(typecode, initializer)``.
298285
The *initializer* is omitted if the array is empty, otherwise it is
299-
a Unicode string if the *typecode* is ``'u'`` or ``'w'``, otherwise it is
286+
a Unicode string if the *typecode* is ``'w'``, otherwise it is
300287
a list of numbers.
301288
The string representation is guaranteed to be able to be converted back to an
302289
array with the same type and value using :func:`eval`, so long as the

Doc/reference/import.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,12 @@ Importing ``parent.one`` will implicitly execute ``parent/__init__.py`` and
122122
``parent.three`` will execute ``parent/two/__init__.py`` and
123123
``parent/three/__init__.py`` respectively.
124124

125+
A subdirectory inside a regular package that does not contain an
126+
``__init__.py`` file is treated as an implicit
127+
:ref:`namespace package <reference-namespace-package>` (a "namespace
128+
subpackage") rooted in that parent. See :pep:`420` for the underlying
129+
specification.
130+
125131

126132
.. _reference-namespace-package:
127133

@@ -153,6 +159,12 @@ physically located next to ``parent/two``. In this case, Python will create a
153159
namespace package for the top-level ``parent`` package whenever it or one of
154160
its subpackages is imported.
155161

162+
Namespace packages may also be nested inside a regular package. When the
163+
import system searches a regular package's ``__path__`` and encounters a
164+
subdirectory that does not contain an ``__init__.py`` file, that
165+
subdirectory becomes a :term:`portion` contributing to a namespace
166+
subpackage of the enclosing regular package.
167+
156168
See also :pep:`420` for the namespace package specification.
157169

158170

Doc/whatsnew/3.16.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,13 @@ annotationlib
147147
Use :meth:`annotationlib.ForwardRef.evaluate`
148148
or :func:`typing.evaluate_forward_ref` instead.
149149

150+
array
151+
-----
152+
153+
* The ``'u'`` format code (:c:type:`wchar_t`) which has been deprecated in
154+
documentation since Python 3.3 and at runtime since Python 3.13.
155+
Use ``'w'`` format code instead (:c:type:`Py_UCS4`, always 4 bytes).
156+
150157
asyncio
151158
-------
152159

Include/cpython/pystats.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ typedef struct _optimization_stats {
163163
uint64_t jit_code_size;
164164
uint64_t jit_trampoline_size;
165165
uint64_t jit_data_size;
166+
uint64_t jit_got_size;
166167
uint64_t jit_padding_size;
167168
uint64_t jit_freed_memory_size;
168169
uint64_t trace_total_memory_hist[_Py_UOP_HIST_SIZE];

Include/internal/pycore_interpframe.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,9 @@ _PyFrame_GetLocalsArray(_PyInterpreterFrame *frame)
230230
static inline _PyStackRef*
231231
_PyFrame_GetStackPointer(_PyInterpreterFrame *frame)
232232
{
233+
#ifndef _Py_JIT
233234
assert(frame->stackpointer != NULL);
235+
#endif
234236
_PyStackRef *sp = frame->stackpointer;
235237
#ifndef NDEBUG
236238
frame->stackpointer = NULL;
@@ -241,7 +243,10 @@ _PyFrame_GetStackPointer(_PyInterpreterFrame *frame)
241243
static inline void
242244
_PyFrame_SetStackPointer(_PyInterpreterFrame *frame, _PyStackRef *stack_pointer)
243245
{
246+
/* Avoid bloating the JIT code */
247+
#ifndef _Py_JIT
244248
assert(frame->stackpointer == NULL);
249+
#endif
245250
frame->stackpointer = stack_pointer;
246251
}
247252

Include/internal/pycore_jit.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ _Py_CODEUNIT *_PyJIT_Entry(
3131
int _PyJIT_Compile(_PyExecutorObject *executor, const _PyUOpInstruction *trace, size_t length);
3232
void _PyJIT_Free(_PyExecutorObject *executor);
3333
PyAPI_FUNC(int) _PyJIT_AddressInJitCode(PyInterpreterState *interp, uintptr_t addr);
34+
PyAPI_FUNC(void) _Py_jit_assert_within_stack_bounds(_PyInterpreterFrame *frame, _PyStackRef *stack_pointer, int lineno);
35+
PyAPI_FUNC(int) _Py_jit_assertion_failure(int line);
3436

3537
#endif // _Py_JIT
3638

Include/internal/pycore_uop.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,7 @@ typedef struct _PyUOpInstruction{
3838

3939
// Fitness is the target length of the trace we translate initially. The uop
4040
// buffer has a small amount of extra space for entry/loop-closing overhead.
41-
#if defined(Py_DEBUG) && defined(_Py_JIT)
42-
// With asserts, the stencils are a lot larger
43-
#define FITNESS_INITIAL 1000
44-
#else
4541
#define FITNESS_INITIAL 2500
46-
#endif
4742

4843
#define UOP_TRACE_BUFFER_OVERHEAD 10
4944
#define UOP_MAX_TRACE_LENGTH (FITNESS_INITIAL + UOP_TRACE_BUFFER_OVERHEAD)

Lib/dis.py

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def _try_compile(source, name):
8484
return compile(source, name, 'exec')
8585

8686
def dis(x=None, *, file=None, depth=None, show_caches=False, adaptive=False,
87-
show_offsets=False, show_positions=False):
87+
show_offsets=False, show_positions=False, show_jit=False):
8888
"""Disassemble classes, methods, functions, and other compiled objects.
8989
9090
With no argument, disassemble the last traceback.
@@ -95,7 +95,8 @@ def dis(x=None, *, file=None, depth=None, show_caches=False, adaptive=False,
9595
"""
9696
if x is None:
9797
distb(file=file, show_caches=show_caches, adaptive=adaptive,
98-
show_offsets=show_offsets, show_positions=show_positions)
98+
show_offsets=show_offsets, show_positions=show_positions,
99+
show_jit=show_jit)
99100
return
100101
# Extract functions from methods.
101102
if hasattr(x, '__func__'):
@@ -116,12 +117,14 @@ def dis(x=None, *, file=None, depth=None, show_caches=False, adaptive=False,
116117
if isinstance(x1, _have_code):
117118
print("Disassembly of %s:" % name, file=file)
118119
try:
119-
dis(x1, file=file, depth=depth, show_caches=show_caches, adaptive=adaptive, show_offsets=show_offsets, show_positions=show_positions)
120+
dis(x1, file=file, depth=depth, show_caches=show_caches, adaptive=adaptive,
121+
show_offsets=show_offsets, show_positions=show_positions, show_jit=show_jit)
120122
except TypeError as msg:
121123
print("Sorry:", msg, file=file)
122124
print(file=file)
123125
elif hasattr(x, 'co_code'): # Code object
124-
_disassemble_recursive(x, file=file, depth=depth, show_caches=show_caches, adaptive=adaptive, show_offsets=show_offsets, show_positions=show_positions)
126+
_disassemble_recursive(x, file=file, depth=depth, show_caches=show_caches, adaptive=adaptive,
127+
show_offsets=show_offsets, show_positions=show_positions, show_jit=show_jit)
125128
elif isinstance(x, (bytes, bytearray)): # Raw bytecode
126129
labels_map = _make_labels_map(x)
127130
label_width = 4 + len(str(len(labels_map)))
@@ -132,12 +135,13 @@ def dis(x=None, *, file=None, depth=None, show_caches=False, adaptive=False,
132135
arg_resolver = ArgResolver(labels_map=labels_map)
133136
_disassemble_bytes(x, arg_resolver=arg_resolver, formatter=formatter)
134137
elif isinstance(x, str): # Source code
135-
_disassemble_str(x, file=file, depth=depth, show_caches=show_caches, adaptive=adaptive, show_offsets=show_offsets, show_positions=show_positions)
138+
_disassemble_str(x, file=file, depth=depth, show_caches=show_caches, adaptive=adaptive,
139+
show_offsets=show_offsets, show_positions=show_positions, show_jit=show_jit)
136140
else:
137141
raise TypeError("don't know how to disassemble %s objects" %
138142
type(x).__name__)
139143

140-
def distb(tb=None, *, file=None, show_caches=False, adaptive=False, show_offsets=False, show_positions=False):
144+
def distb(tb=None, *, file=None, show_caches=False, adaptive=False, show_offsets=False, show_positions=False, show_jit=False):
141145
"""Disassemble a traceback (default: last traceback)."""
142146
if tb is None:
143147
try:
@@ -148,7 +152,8 @@ def distb(tb=None, *, file=None, show_caches=False, adaptive=False, show_offsets
148152
except AttributeError:
149153
raise RuntimeError("no last traceback to disassemble") from None
150154
while tb.tb_next: tb = tb.tb_next
151-
disassemble(tb.tb_frame.f_code, tb.tb_lasti, file=file, show_caches=show_caches, adaptive=adaptive, show_offsets=show_offsets, show_positions=show_positions)
155+
disassemble(tb.tb_frame.f_code, tb.tb_lasti, file=file, show_caches=show_caches, adaptive=adaptive,
156+
show_offsets=show_offsets, show_positions=show_positions, show_jit=show_jit)
152157

153158
# The inspect module interrogates this dictionary to build its
154159
# list of CO_* constants. It is also used by pretty_flags to
@@ -216,14 +221,14 @@ def _deoptop(op):
216221
name = _all_opname[op]
217222
return _all_opmap[deoptmap[name]] if name in deoptmap else op
218223

219-
def _get_code_array(co, adaptive):
224+
def _get_code_array(co, adaptive, show_jit):
220225
if adaptive:
221226
code = co._co_code_adaptive
222227
res = []
223228
found = False
224229
for i in range(0, len(code), 2):
225230
op, arg = code[i], code[i+1]
226-
if op == ENTER_EXECUTOR:
231+
if op == ENTER_EXECUTOR and not show_jit:
227232
try:
228233
ex = get_executor(co, i)
229234
except (ValueError, RuntimeError):
@@ -656,7 +661,7 @@ def get_argval_argrepr(self, op, arg, offset):
656661
argrepr = 'not in' if argval else 'in'
657662
return argval, argrepr
658663

659-
def get_instructions(x, *, first_line=None, show_caches=None, adaptive=False):
664+
def get_instructions(x, *, first_line=None, show_caches=None, adaptive=False, show_jit=False):
660665
"""Iterator for the opcodes in methods, functions or code
661666
662667
Generates a series of Instruction named tuples giving the details of
@@ -679,7 +684,7 @@ def get_instructions(x, *, first_line=None, show_caches=None, adaptive=False):
679684
names=co.co_names,
680685
varname_from_oparg=co._varname_from_oparg,
681686
labels_map=_make_labels_map(original_code))
682-
return _get_instructions_bytes(_get_code_array(co, adaptive),
687+
return _get_instructions_bytes(_get_code_array(co, adaptive, show_jit),
683688
linestarts=linestarts,
684689
line_offset=line_offset,
685690
co_positions=co.co_positions(),
@@ -792,6 +797,8 @@ def _get_instructions_bytes(code, linestarts=None, line_offset=0, co_positions=N
792797
positions = Positions(*next(co_positions, ()))
793798
deop = _deoptop(op)
794799
op = code[offset]
800+
if op == ENTER_EXECUTOR:
801+
arg = code[offset+1]
795802

796803
if arg_resolver:
797804
argval, argrepr = arg_resolver.get_argval_argrepr(op, arg, offset)
@@ -820,7 +827,7 @@ def _get_instructions_bytes(code, linestarts=None, line_offset=0, co_positions=N
820827

821828

822829
def disassemble(co, lasti=-1, *, file=None, show_caches=False, adaptive=False,
823-
show_offsets=False, show_positions=False):
830+
show_offsets=False, show_positions=False, show_jit=False):
824831
"""Disassemble a code object."""
825832
linestarts = dict(findlinestarts(co))
826833
exception_entries = _parse_exception_table(co)
@@ -840,12 +847,12 @@ def disassemble(co, lasti=-1, *, file=None, show_caches=False, adaptive=False,
840847
names=co.co_names,
841848
varname_from_oparg=co._varname_from_oparg,
842849
labels_map=labels_map)
843-
_disassemble_bytes(_get_code_array(co, adaptive), lasti, linestarts,
850+
_disassemble_bytes(_get_code_array(co, adaptive, show_jit), lasti, linestarts,
844851
exception_entries=exception_entries, co_positions=co.co_positions(),
845852
original_code=co.co_code, arg_resolver=arg_resolver, formatter=formatter)
846853

847-
def _disassemble_recursive(co, *, file=None, depth=None, show_caches=False, adaptive=False, show_offsets=False, show_positions=False):
848-
disassemble(co, file=file, show_caches=show_caches, adaptive=adaptive, show_offsets=show_offsets, show_positions=show_positions)
854+
def _disassemble_recursive(co, *, file=None, depth=None, show_caches=False, adaptive=False, show_offsets=False, show_positions=False, show_jit=False):
855+
disassemble(co, file=file, show_caches=show_caches, adaptive=adaptive, show_offsets=show_offsets, show_positions=show_positions, show_jit=show_jit)
849856
if depth is None or depth > 0:
850857
if depth is not None:
851858
depth = depth - 1
@@ -855,7 +862,8 @@ def _disassemble_recursive(co, *, file=None, depth=None, show_caches=False, adap
855862
print("Disassembly of %r:" % (x,), file=file)
856863
_disassemble_recursive(
857864
x, file=file, depth=depth, show_caches=show_caches,
858-
adaptive=adaptive, show_offsets=show_offsets, show_positions=show_positions
865+
adaptive=adaptive, show_offsets=show_offsets,
866+
show_positions=show_positions, show_jit=show_jit
859867
)
860868

861869

@@ -1054,7 +1062,7 @@ class Bytecode:
10541062
10551063
Iterating over this yields the bytecode operations as Instruction instances.
10561064
"""
1057-
def __init__(self, x, *, first_line=None, current_offset=None, show_caches=False, adaptive=False, show_offsets=False, show_positions=False):
1065+
def __init__(self, x, *, first_line=None, current_offset=None, show_caches=False, adaptive=False, show_offsets=False, show_positions=False, show_jit=False):
10581066
self.codeobj = co = _get_code_object(x)
10591067
if first_line is None:
10601068
self.first_line = co.co_firstlineno
@@ -1070,6 +1078,7 @@ def __init__(self, x, *, first_line=None, current_offset=None, show_caches=False
10701078
self.adaptive = adaptive
10711079
self.show_offsets = show_offsets
10721080
self.show_positions = show_positions
1081+
self.show_jit = show_jit
10731082

10741083
def __iter__(self):
10751084
co = self.codeobj
@@ -1079,7 +1088,7 @@ def __iter__(self):
10791088
names=co.co_names,
10801089
varname_from_oparg=co._varname_from_oparg,
10811090
labels_map=labels_map)
1082-
return _get_instructions_bytes(_get_code_array(co, self.adaptive),
1091+
return _get_instructions_bytes(_get_code_array(co, self.adaptive, self.show_jit),
10831092
linestarts=self._linestarts,
10841093
line_offset=self._line_offset,
10851094
co_positions=co.co_positions(),
@@ -1111,7 +1120,7 @@ def dis(self):
11111120
else:
11121121
offset = -1
11131122
with io.StringIO() as output:
1114-
code = _get_code_array(co, self.adaptive)
1123+
code = _get_code_array(co, self.adaptive, self.show_jit)
11151124
offset_width = len(str(max(len(code) - 2, 9999))) if self.show_offsets else 0
11161125
if self.show_positions:
11171126
lineno_width = _get_positions_width(co)

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 = "26.1.1"
13+
_PIP_VERSION = "26.1.2"
1414

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

0 commit comments

Comments
 (0)