Skip to content

Commit c5407d5

Browse files
committed
Merge branch 'main' into pyrepl/completions-below
2 parents 119c01d + 4c387a7 commit c5407d5

File tree

354 files changed

+11320
-5477
lines changed

Some content is hidden

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

354 files changed

+11320
-5477
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: 15 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:
@@ -153,6 +167,7 @@ jobs:
153167
154168
jit-with-disabled-gil:
155169
name: Free-Threaded (Debug)
170+
needs: interpreter
156171
runs-on: ubuntu-latest
157172
steps:
158173
- uses: actions/checkout@v4

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 = --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/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/faq/library.rst

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -541,84 +541,6 @@ Thus, to read *n* bytes from a pipe *p* created with :func:`os.popen`, you need
541541
use ``p.read(n)``.
542542
543543
544-
.. XXX update to use subprocess. See the :ref:`subprocess-replacements` section.
545-
546-
How do I run a subprocess with pipes connected to both input and output?
547-
------------------------------------------------------------------------
548-
549-
Use the :mod:`popen2` module. For example::
550-
551-
import popen2
552-
fromchild, tochild = popen2.popen2("command")
553-
tochild.write("input\n")
554-
tochild.flush()
555-
output = fromchild.readline()
556-
557-
Warning: in general it is unwise to do this because you can easily cause a
558-
deadlock where your process is blocked waiting for output from the child
559-
while the child is blocked waiting for input from you. This can be caused
560-
by the parent expecting the child to output more text than it does or
561-
by data being stuck in stdio buffers due to lack of flushing.
562-
The Python parent can of course explicitly flush the data it sends to the
563-
child before it reads any output, but if the child is a naive C program it
564-
may have been written to never explicitly flush its output, even if it is
565-
interactive, since flushing is normally automatic.
566-
567-
Note that a deadlock is also possible if you use :func:`popen3` to read
568-
stdout and stderr. If one of the two is too large for the internal buffer
569-
(increasing the buffer size does not help) and you ``read()`` the other one
570-
first, there is a deadlock, too.
571-
572-
Note on a bug in popen2: unless your program calls ``wait()`` or
573-
``waitpid()``, finished child processes are never removed, and eventually
574-
calls to popen2 will fail because of a limit on the number of child
575-
processes. Calling :func:`os.waitpid` with the :const:`os.WNOHANG` option can
576-
prevent this; a good place to insert such a call would be before calling
577-
``popen2`` again.
578-
579-
In many cases, all you really need is to run some data through a command and
580-
get the result back. Unless the amount of data is very large, the easiest
581-
way to do this is to write it to a temporary file and run the command with
582-
that temporary file as input. The standard module :mod:`tempfile` exports a
583-
:func:`~tempfile.mktemp` function to generate unique temporary file names. ::
584-
585-
import tempfile
586-
import os
587-
588-
class Popen3:
589-
"""
590-
This is a deadlock-safe version of popen that returns
591-
an object with errorlevel, out (a string) and err (a string).
592-
(capturestderr may not work under windows.)
593-
Example: print(Popen3('grep spam','\n\nhere spam\n\n').out)
594-
"""
595-
def __init__(self,command,input=None,capturestderr=None):
596-
outfile=tempfile.mktemp()
597-
command="( %s ) > %s" % (command,outfile)
598-
if input:
599-
infile=tempfile.mktemp()
600-
open(infile,"w").write(input)
601-
command=command+" <"+infile
602-
if capturestderr:
603-
errfile=tempfile.mktemp()
604-
command=command+" 2>"+errfile
605-
self.errorlevel=os.system(command) >> 8
606-
self.out=open(outfile,"r").read()
607-
os.remove(outfile)
608-
if input:
609-
os.remove(infile)
610-
if capturestderr:
611-
self.err=open(errfile,"r").read()
612-
os.remove(errfile)
613-
614-
Note that many interactive programs (e.g. vi) don't work well with pipes
615-
substituted for standard input and output. You will have to use pseudo ttys
616-
("ptys") instead of pipes. Or you can use a Python interface to Don Libes'
617-
"expect" library. A Python extension that interfaces to expect is called
618-
"expy" and available from https://expectpy.sourceforge.net. A pure Python
619-
solution that works like expect is :pypi:`pexpect`.
620-
621-
622544
How do I access the serial (RS232) port?
623545
----------------------------------------
624546

Doc/glossary.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,11 +425,11 @@ Glossary
425425
An object that tries to find the :term:`loader` for a module that is
426426
being imported.
427427

428-
Since Python 3.3, there are two types of finder: :term:`meta path finders
428+
There are two types of finder: :term:`meta path finders
429429
<meta path finder>` for use with :data:`sys.meta_path`, and :term:`path
430430
entry finders <path entry finder>` for use with :data:`sys.path_hooks`.
431431

432-
See :pep:`302`, :pep:`420` and :pep:`451` for much more detail.
432+
See :ref:`importsystem` and :mod:`importlib` for much more detail.
433433

434434
floor division
435435
Mathematical division that rounds down to nearest integer. The floor

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/howto/pyporting.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ please see :ref:`cporting-howto`.
1818

1919
The archived python-porting_ mailing list may contain some useful guidance.
2020

21-
Since Python 3.13 the original porting guide was discontinued.
21+
Since Python 3.11 the original porting guide was discontinued.
2222
You can find the old guide in the
23-
`archive <https://docs.python.org/3.12/howto/pyporting.html>`_.
23+
`archive <https://docs.python.org/3.10/howto/pyporting.html>`_.
2424

2525

2626
Third-party guides

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/cmath.rst

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@ Conversions to and from polar coordinates
4343

4444
A Python complex number ``z`` is stored internally using *rectangular*
4545
or *Cartesian* coordinates. It is completely determined by its *real
46-
part* ``z.real`` and its *imaginary part* ``z.imag``. In other
47-
words::
48-
49-
z == z.real + z.imag*1j
46+
part* ``z.real`` and its *imaginary part* ``z.imag``.
5047

5148
*Polar coordinates* give an alternative way to represent a complex
5249
number. In polar coordinates, a complex number *z* is defined by the
@@ -90,7 +87,7 @@ rectangular coordinates to polar coordinates and back.
9087
.. function:: rect(r, phi)
9188

9289
Return the complex number *x* with polar coordinates *r* and *phi*.
93-
Equivalent to ``r * (math.cos(phi) + math.sin(phi)*1j)``.
90+
Equivalent to ``complex(r * math.cos(phi), r * math.sin(phi))``.
9491

9592

9693
Power and logarithmic functions

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()

0 commit comments

Comments
 (0)