8000 Merge branch 'python:main' into pprint_dict_view · python/cpython@ee7b521 · GitHub
[go: up one dir, main page]

Skip to content

Commit ee7b521

Browse files
authored
Merge branch 'python:main' into pprint_dict_view
2 parents d020f86 + a5fef80 commit ee7b521

File tree

387 files changed

+11331
-5653
lines changed

Some content is hidden

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

387 files changed

+11331
-5653
lines changed

.github/CODEOWNERS

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,21 @@ Objects/type* @markshannon
2929
Objects/codeobject.c @markshannon
3030
Objects/frameobject.c @markshannon
3131
Objects/call.c @markshannon
32-
Python/ceval*.c @markshannon @gvanrossum
33-
Python/ceval*.h @markshannon @gvanrossum
32+
Python/ceval*.c @markshannon
33+
Python/ceval*.h @markshannon
3434
Python/compile.c @markshannon @iritkatriel
3535
Python/assemble.c @markshannon @iritkatriel
3636
Python/flowgraph.c @markshannon @iritkatriel
3737
Python/ast_opt.c @isidentical
38-
Python/bytecodes.c @markshannon @gvanrossum
39-
Python/optimizer*.c @markshannon @gvanrossum
38+
Python/bytecodes.c @markshannon
39+
Python/optimizer*.c @markshannon
4040
Python/optimizer_analysis.c @Fidget-Spinner
4141
Python/optimizer_bytecodes.c @Fidget-Spinner
42+
Lib/_pyrepl/* @pablogsal @lysnikolaou @ambv
4243
Lib/test/test_patma.py @brandtbucher
4344
Lib/test/test_type_*.py @JelleZijlstra
44-
Lib/test/test_capi/test_misc.py @markshannon @gvanrossum
45+
Lib/test/test_capi/test_misc.py @markshannon
46+
Lib/test/test_pyrepl/* @pablogsal @lysnikolaou @ambv
4547
Tools/c-analyzer/ @ericsnowcurrently
4648

4749
# dbm
@@ -150,7 +152,7 @@ Include/internal/pycore_time.h @pganssle @abalkin
150152
/Lib/test/test_tokenize.py @pablogsal @lysnikolaou
151153

152154
# Code generator
153-
/Tools/cases_generator/ @gvanrossum
155+
/Tools/cases_generator/ @markshannon
154156

155157
# AST
156158
Python/ast.c @isidentical

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ jobs:
388388
id: cache-hypothesis-database
389389
uses: actions/cache@v4
390390
with:
391-
path: ./hypothesis
391+
path: ${{ env.CPYTHON_BUILDDIR }}/.hypothesis/
392392
key: hypothesis-database-${{ github.head_ref || github.run_id }}
393393
restore-keys: |
394394
- hypothesis-database-
@@ -416,7 +416,7 @@ jobs:
416416
if: always()
417417
with:
418418
name: hypothesis-example-db
419-
path: .hypothesis/examples/
419+
path: ${{ env.CPYTHON_BUILDDIR }}/.hypothesis/examples/
420420

421421

422422
build_asan:

.github/workflows/jit.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,22 @@ concurrency:
2626
cancel-in-progress: true
2727

2828
jobs:
29+
interpreter:
30+
name: Interpreter (Debug)
31+
runs-on: ubuntu-latest
32+
timeout-minutes: 90
33+
steps:
34+
- uses: actions/checkout@v4
35+
- name: Build tier two interpreter
36+
run: |
37+
./configure --enable-experimental-jit=interpreter --with-pydebug
38+
make all --jobs 4
39+
- name: Test tier two interpreter
40+
run: |
41+
./python -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
2942
jit:
3043
name: ${{ matrix.target }} (${{ matrix.debug && 'Debug' || 'Release' }})
44+
needs: interpreter
3145
runs-on: ${{ matrix.runner }}
3246
timeout-minutes: 90
3347
strategy:
@@ -150,3 +164,22 @@ jobs:
150164
./configure --enable-experimental-jit ${{ matrix.debug && '--with-pydebug' || '--enable-optimizations ' }} --build=x86_64-linux-gnu --host="$HOST" --with-build-python=../build/bin/python3 --with-pkg-config=no ac_cv_buggy_getaddrinfo=no ac_cv_file__dev_ptc=no ac_cv_file__dev_ptmx=yes
151165
make all --jobs 4
152166
./python -m test --ignorefile=Tools/jit/ignore-tests-emulated-linux.txt --multiprocess 0 --timeout 4500 --verbose2 --verbose3
167+
168+
jit-with-disabled-gil:
169+
name: Free-Threaded (Debug)
170+
needs: interpreter
171+
runs-on: ubuntu-latest
172+
steps:
173+
- uses: actions/checkout@v4
174+
- uses: actions/setup-python@v5
175+
with:
176+
python-version: '3.11'
177+
- name: Build with JIT enabled and GIL disabled
178+
run: |
179+
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh 18
180+
export PATH="$(llvm-config-18 --bindir):$PATH"
181+
./configure --enable-experimental-jit --with-pydebug --disable-gil
182+
make all --jobs 4
183+
- name: Run tests
184+
run: |
185+
./python -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3

.github/workflows/mypy.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ concurrency:
3434
jobs:
3535
mypy:
3636
strategy:
37+
fail-fast: false
3738
matrix:
3839
target: [
3940
"Lib/_pyrepl",

Doc/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,14 @@ gettext: build
150150
htmlview: html
151151
$(PYTHON) -c "import os, webbrowser; webbrowser.open('file://' + os.path.realpath('build/html/index.html'))"
152152

153+
.PHONY: ensure-sphinx-autobuild
154+
ensure-sphinx-autobuild: venv
155+
$(VENVDIR)/bin/sphinx-autobuild --version > /dev/null || $(VENVDIR)/bin/python3 -m pip install sphinx-autobuild
156+
153157
.PHONY: htmllive
154158
htmllive: SPHINXBUILD = $(VENVDIR)/bin/sphinx-autobuild
155159
htmllive: SPHINXOPTS 10000 = --re-ignore="/venv/" --open-browser --delay 0
156-
htmllive: html
160+
htmllive: ensure-sphinx-autobuild html
157161

158162
.PHONY: clean
159163
clean: clean-venv

Doc/c-api/buffer.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ a buffer, see :c:func:`PyObject_GetBuffer`.
147147
or a :c:macro:`PyBUF_WRITABLE` request, the consumer must disregard
148148
:c:member:`~Py_buffer.itemsize` and assume ``itemsize == 1``.
149149

150-
.. c:member:: const char *format
150+
.. c:member:: char *format
151151
152-
A *NUL* terminated string in :mod:`struct` module style syntax describing
152+
A *NULL* terminated string in :mod:`struct` module style syntax describing
153153
the contents of a single item. If this is ``NULL``, ``"B"`` (unsigned bytes)
154154
is assumed.
155155

Doc/c-api/hash.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ See also the :c:member:`PyTypeObject.tp_hash` member and :ref:`numeric-hash`.
2929

3030
.. versionadded:: 3.13
3131

32+
.. c:macro:: PyHASH_MULTIPLIER
33+
34+
Prime multiplier used in string and various other hashes.
35+
36+
.. versionadded:: 3.13
37+
3238
.. c:macro:: PyHASH_INF
3339
3440
The hash value returned for a positive infinity.

Doc/c-api/module.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,14 +427,14 @@ The available slot types are:
427427
This slot is ignored by Python builds not configured with
428428
:option:`--disable-gil`. Otherwise, it determines whether or not importing
429429
this module will cause the GIL to be automatically enabled. See
430-
:envvar:`PYTHON_GIL` and :option:`-X gil <-X>` for more detail.
430+
:ref:`free-threaded-cpython` for more detail.
431431
432432
Multiple ``Py_mod_gil`` slots may not be specified in one module definition.
433433
434434
If ``Py_mod_gil`` is not specified, the import machinery defaults to
435435
``Py_MOD_GIL_USED``.
436436
437-
.. versionadded: 3.13
437+
.. versionadded:: 3.13
438438
439439
See :PEP:`489` for more details on multi-phase initialization.
440440

Doc/c-api/monitoring.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,10 @@ See :mod:`sys.monitoring` for descriptions of the events.
121121
:c:func:`PyErr_GetRaisedException`).
122122
123123
124-
.. c:function:: int PyMonitoring_FireStopIterationEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset)
124+
.. c:function:: int PyMonitoring_FireStopIterationEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset, PyObject *value)
125125
126-
Fire a ``STOP_ITERATION`` event with the current exception (as returned by
127-
:c:func:`PyErr_GetRaisedException`).
126+
Fire a ``STOP_ITERATION`` event. If ``value`` is an instance of :exc:`StopIteration`, it is used. Otherwise,
127+
a new :exc:`StopIteration` instance is created with ``value`` as its argument.
128128
129129
130130
Managing the Monitoring State

Doc/c-api/tuple.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ Tuple Objects
105105
is being replaced; any reference in the tuple at position *pos* will be
106106
leaked.
107107
108+
.. warning::
109+
110+
This macro should *only* be used on tuples that are newly created.
111+
Using this macro on a tuple that is already in use (or in other words, has
112+
a refcount > 1) could lead to undefined behavior.
113+
108114
109115
.. c:function:: int _PyTuple_Resize(PyObject **p, Py_ssize_t newsize)
110116

Doc/c-api/weakref.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ as much as it can.
3535
callable object that receives notification when *ob* is garbage collected; it
3636
should accept a single parameter, which will be the weak reference object
3737
itself. *callback* may also be ``None`` or ``NULL``. If *ob* is not a
38-
weakly referencable object, or if *callback* is not callable, ``None``, or
38+
weakly referenceable object, or if *callback* is not callable, ``None``, or
3939
``NULL``, this will return ``NULL`` and raise :exc:`TypeError`.
4040
4141
@@ -47,7 +47,7 @@ as much as it can.
4747
be a callable object that receives notification when *ob* is garbage
4848
collected; it should accept a single parameter, which will be the weak
4949
reference object itself. *callback* may also be ``None`` or ``NULL``. If *ob*
50-
is not a weakly referencable object, or if *callback* is not callable,
50+
is not a weakly referenceable object, or if *callback* is not callable,
5151
``None``, or ``NULL``, this will return ``NULL`` and raise :exc:`TypeError`.
5252
5353

Doc/extending/extending.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ It is important to call :c:func:`free` at the right time. If a block's address
868868
is forgotten but :c:func:`free` is not called for it, the memory it occupies
869869
cannot be reused until the program terminates. This is called a :dfn:`memory
870870
leak`. On the other hand, if a program calls :c:func:`free` for a block and then
871-
continues to use the block, it creates a conflict with re-use of the block
871+
continues to use the block, it creates a conflict with reuse of the block
872872
through another :c:func:`malloc` call. This is called :dfn:`using freed memory`.
873873
It has the same bad consequences as referencing uninitialized data --- core
874874
dumps, wrong results, mysterious crashes.

Doc/extending/newtypes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ performance-critical objects (such as numbers).
545545
.. seealso::
546546
Documentation for the :mod:`weakref` module.
547547

548-
For an object to be weakly referencable, the extension type must set the
548+
For an object to be weakly referenceable, the extension type must set the
549549
``Py_TPFLAGS_MANAGED_WEAKREF`` bit of the :c:member:`~PyTypeObject.tp_flags`
550550
field. The legacy :c:member:`~PyTypeObject.tp_weaklistoffset` field should
551551
be left as zero.

Doc/faq/general.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ available. Consult `the Python Package Index <https://pypi.org>`_ to
122122
find packages of interest to you.
123123

124124

125+
.. _faq-version-numbering-scheme:
126+
125127
How does the Python version numbering scheme work?
126128
--------------------------------------------------
127129

@@ -183,8 +185,6 @@ information on getting the source code and compiling it.
183185
How do I get documentation on Python?
184186
-------------------------------------
185187

186-
.. XXX mention py3k
187-
188188
The standard documentation for the current stable version of Python is available
189189
at https://docs.python.org/3/. PDF, plain text, and downloadable HTML versions are
190190
also available at https://docs.python.org/3/download.html.

Doc/howto/mro.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ In this case the MRO is GFEF and the local precedence ordering is
426426
preserved.
427427

428428
As a general rule, hierarchies such as the previous one should be
429-
avoided, since it is unclear if F should override E or viceversa.
429+
avoided, since it is unclear if F should override E or vice-versa.
430430
Python 2.3 solves the ambiguity by raising an exception in the creation
431431
of class G, effectively stopping the programmer from generating
432432
ambiguous hierarchies. The reason for that is that the C3 algorithm

Doc/library/ast.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2472,6 +2472,20 @@ effects on the compilation of a program:
24722472
.. versionadded:: 3.8
24732473

24742474

2475+
.. function:: compare(a, b, /, *, compare_attributes=False)
2476+
2477+
Recursively compares two ASTs.
2478+
2479+
*compare_attributes* affects whether AST attributes are considered
2480+
in the comparison. If *compare_attributes* is ``False`` (default), then
2481+
attributes are ignored. Otherwise they must all be equal. This
2482+
option is useful to check whether the ASTs are structurally equal but
2483+
differ in whitespace or similar details. Attributes include line numbers
2484+
and column offsets.
2485+
2486+
.. versionadded:: 3.14
2487+
2488+
24752489
.. _ast-cli:
24762490

24772491
Command-Line Usage

Doc/library/base64.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ The modern interface provides:
193193

194194
*wrapcol* controls whether the output should have newline (``b'\n'``)
195195
characters added to it. If this is non-zero, each output line will be
196-
at most this many characters long.
196+
at most this many characters long, excluding the trailing newline.
197197

198198
*pad* controls whether the input is padded to a multiple of 4
199199
before encoding. Note that the ``btoa`` implementation always pads.

Doc/library/ctypes.rst

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -661,14 +661,18 @@ for debugging because they can provide useful information::
661661
guaranteed by the library to work in the general case. Unions and
662662
structures with bit-fields should always be passed to functions by pointer.
663663

664-
Structure/union alignment and byte order
665-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
666-
667-
By default, Structure and Union fields are aligned in the same way the C
668-
compiler does it. It is possible to override this behavior by specifying a
669-
:attr:`~Structure._pack_` class attribute in the subclass definition.
670-
This must be set to a positive integer and specifies the maximum alignment for the fields.
671-
This is what ``#pragma pack(n)`` also does in MSVC.
664+
Structure/union layout, alignment and byte order
665+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
666+
667+
By default, Structure and Union fields are laid out in the same way the C
668+
compiler does it. It is possible to override this behavior entirely by specifying a
669+
:attr:`~Structure._layout_` class attribute in the subclass definition; see
670+
the attribute documentation for details.
671+
672+
It is possible to specify the maximum alignment for the fields by setting
673+
the :attr:`~Structure._pack_` class attribute to a positive integer.
674+
This matches what ``#pragma pack(n)`` does in MSVC.
675+
672676
It is also possible to set a minimum alignment for how the subclass itself is packed in the
673677
same way ``#pragma align(n)`` works in MSVC.
674678
This can be achieved by specifying a ::attr:`~Structure._align_` class attribute
@@ -2540,6 +2544,31 @@ fields, or any other data types containing pointer type fields.
25402544
the structure when being packed or unpacked to/from memory.
25412545
Setting this attribute to 0 is the same as not setting it at all.
25422546

2547+
.. attribute:: _layout_
2548+
2549+
An optional string naming the struct/union layout. It can currently
2550+
be set to:
2551+
2552+
- ``"ms"``: the layout used by the Microsoft compiler (MSVC).
2553+
On GCC and Clang, this layout can be selected with
2554+
``__attribute__((ms_struct))``.
2555+
- ``"gcc-sysv"``: the layout used by GCC with the System V or “SysV-like”
2556+
data model, as used on Linux and macOS.
2557+
With this layout, :attr:`~Structure._pack_` must be unset or zero.
2558+
2559+
If not set explicitly, ``ctypes`` will use a default that
2560+
matches the platform conventions. This default may change in future
2561+
Python releases (for example, when a new platform gains official support,
2562+
or when a difference between similar platforms is found).
2563+
Currently the default will be:
2564+
2565+
- On Windows: ``"ms"``
2566+
- When :attr:`~Structure._pack_` is specified: ``"ms"``
2567+
- Otherwise: ``"gcc-sysv"``
2568+
2569+
:attr:`!_layout_` must already be defined when
2570+
:attr:`~Structure._fields_` is assigned, otherwise it will have no effect.
2571+
25432572
.. attribute:: _anonymous_
25442573

25452574
An optional sequence that lists the names of unnamed (anonymous) fields.

Doc/library/curses.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ the following methods and attributes:
924924

925925
.. method:: window.getbegyx()
926926

927-
Return a tuple ``(y, x)`` of co-ordinates of upper-left corner.
927+
Return a tuple ``(y, x)`` of coordinates of upper-left corner.
928928

929929

930930
.. method:: window.getbkgd()

Doc/library/dataclasses.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,10 @@ Module contents
185185
- *slots*: If true (the default is ``False``), :attr:`~object.__slots__` attribute
186186
will be generated and new class will be returned instead of the original one.
187187
If :attr:`!__slots__` is already defined in the class, then :exc:`TypeError`
188-
is raised.
188+
is raised. Calling no-arg :func:`super` in dataclasses using ``slots=True`` will result in
189+
the following exception being raised:
190+
``TypeError: super(type, obj): obj must be an instance or subtype of type``.
191+
The two-arg :func:`super` is a valid workaround. See :gh:`90562` for full details.
189192

190193
.. versionadded:: 3.10
191194

@@ -458,8 +461,8 @@ Module contents
458461

459462
.. function:: is_dataclass(obj)
460463

461-
Return ``True`` if its parameter is a dataclass or an instance of one,
462-
otherwise return ``False``.
464+
Return ``True`` if its parameter is a dataclass (including subclasses of a
465+
dataclass) or an instance of one, otherwise return ``False``.
463466

464467
If you need to know if a class is an instance of a dataclass (and
465468
not a dataclass itself), then add a further check for ``not

Doc/library/dis.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -929,12 +929,13 @@ iterations of the loop.
929929
Exception representation on the stack now consist of one, not three, items.
930930

931931

932-
.. opcode:: LOAD_ASSERTION_ERROR
932+
.. opcode:: LOAD_COMMON_CONSTANT
933933

934-
Pushes :exc:`AssertionError` onto the stack. Used by the :keyword:`assert`
935-
statement.
934+
Pushes a common constant onto the stack. The interpreter contains a hardcoded
935+
list of constants supported by this instruction. Used by the :keyword:`assert`
936+
statement to load :exc:`AssertionError`.
936937

937-
.. versionadded:: 3.9
938+
.. versionadded:: 3.14
938939

939940

940941
.. opcode:: LOAD_BUILD_CLASS

0 commit comments

Comments
 (0)
0