8000 Merge remote-tracking branch 'upstream/main' into stackref_all · python/cpython@8d82237 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8d82237

Browse files
Merge remote-tracking branch 'upstream/main' into stackref_all
2 parents 2d38baa + 2d3187b commit 8d82237

Some content is hidden

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

62 files changed

+1199
-353
lines changed

.github/workflows/jit.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,17 +133,15 @@ jobs:
133133
make all --jobs 4
134134
./python.exe -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
135135
136-
# --with-lto has been removed temporarily as a result of an open issue in LLVM 18 (see https://github.com/llvm/llvm-project/issues/87553)
137136
- name: Native Linux
138137
if: runner.os == 'Linux' && matrix.architecture == 'x86_64'
139138
run: |
140139
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh ${{ matrix.llvm }}
141140
export PATH="$(llvm-config-${{ matrix.llvm }} --bindir):$PATH"
142-
./configure --enable-experimental-jit ${{ matrix.debug && '--with-pydebug' || '--enable-optimizations' }}
141+
./configure --enable-experimental-jit ${{ matrix.debug && '--with-pydebug' || '--enable-optimizations --with-lto' }}
143142
make all --jobs 4
144143
./python -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
145144
146-
# --with-lto has been removed temporarily as a result of an open issue in LLVM 18 (see https://github.com/llvm/llvm-project/issues/87553)
147145
- name: Emulated Linux
148146
if: runner.os == 'Linux' && matrix.architecture != 'x86_64'
149147
# The --ignorefile on ./python -m test is used to exclude tests known to fail when running on an emulated Linux.
@@ -161,7 +159,7 @@ jobs:
161159
CC="${{ matrix.compiler == 'clang' && 'clang --target=$HOST' || '$HOST-gcc' }}" \
162160
CPP="$CC --preprocess" \
163161
HOSTRUNNER=qemu-${{ matrix.architecture }} \
164-
./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
162+
./configure --enable-experimental-jit ${{ matrix.debug && '--with-pydebug' || '--enable-optimizations --with-lto' }} --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
165163
make all --jobs 4
166164
./python -m test --ignorefile=Tools/jit/ignore-tests-emulated-linux.txt --multiprocess 0 --timeout 4500 --verbose2 --verbose3
167165

Doc/README.rst

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ install the tools into there.
2828
Using make
2929
----------
3030

31-
To get started on UNIX, you can create a virtual environment and build
31+
To get started on Unix, you can create a virtual environment and build
3232
documentation with the commands::
3333

3434
make venv
@@ -40,13 +40,13 @@ If you'd like to create the virtual environment in a different location,
4040
you can specify it using the ``VENVDIR`` variable.
4141

4242
You can also skip creating the virtual environment altogether, in which case
43-
the Makefile will look for instances of ``sphinx-build`` and ``blurb``
43+
the ``Makefile`` will look for instances of ``sphinx-build`` and ``blurb``
4444
installed on your process ``PATH`` (configurable with the ``SPHINXBUILD`` and
4545
``BLURB`` variables).
4646

47-
On Windows, we try to emulate the Makefile as closely as possible with a
47+
On Windows, we try to emulate the ``Makefile`` as closely as possible with a
4848
``make.bat`` file. If you need to specify the Python interpreter to use,
49-
set the PYTHON environment variable.
49+
set the ``PYTHON`` environment variable.
5050

5151
Available make targets are:
5252

@@ -62,15 +62,19 @@ Available make targets are:
6262
* "htmlview", which re-uses the "html" builder, but then opens the main page
6363
in your default web browser.
6464

65+
* "htmllive", which re-uses the "html" builder, rebuilds the docs,
66+
starts a local server, and automatically reloads the page in your browser
67+
when you make changes to reST files (Unix only).
68+
6569
* "htmlhelp", which builds HTML files and a HTML Help project file usable to
6670
convert them into a single Compiled HTML (.chm) file -- these are popular
6771
under Microsoft Windows, but very handy on every platform.
6872

6973
To create the CHM file, you need to run the Microsoft HTML Help Workshop
70-
over the generated project (.hhp) file. The make.bat script does this for
74+
over the generated project (.hhp) file. The ``make.bat`` script does this for
7175
you on Windows.
7276

73-
* "latex", which builds LaTeX source files as input to "pdflatex" to produce
77+
* "latex", which builds LaTeX source files as input to ``pdflatex`` to produce
7478
PDF documents.
7579

7680
* "text", which builds a plain text file for each source file.
@@ -95,8 +99,6 @@ Available make targets are:
9599

96100
* "check", which checks for frequent markup errors.
97101

98-
* "serve", which serves the build/html directory on port 8000.
99-
100102
* "dist", (Unix only) which creates distributable archives of HTML, text,
101103
PDF, and EPUB builds.
102104

Doc/c-api/dict.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,17 @@ Dictionary Objects
290290
Py_DECREF(o);
291291
}
292292
293+
The function is not thread-safe in the :term:`free-threaded <free threading>`
294+
build without external synchronization. You can use
295+
:c:macro:`Py_BEGIN_CRITICAL_SECTION` to lock the dictionary while iterating
296+
over it::
297+
298+
Py_BEGIN_CRITICAL_SECTION(self->dict);
299+
while (PyDict_Next(self->dict, &pos, &key, &value)) {
300+
...
301+
}
302+
Py_END_CRITICAL_SECTION();
303+
293304
294305
.. c:function:: int PyDict_Merge(PyObject *a, PyObject *b, int override)
295306

Doc/c-api/unicode.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1563,6 +1563,15 @@ object.
15631563
On success, return ``0``.
15641564
On error, set an exception, leave the writer unchanged, and return ``-1``.
15651565
1566+
.. c:function:: int PyUnicodeWriter_WriteUCS4(PyUnicodeWriter *writer, Py_UCS4 *str, Py_ssize_t size)
1567+
1568+
Writer the UCS4 string *str* into *writer*.
1569+
1570+
*size* is a number of UCS4 characters.
1571+
1572+
On success, return ``0``.
1573+
On error, set an exception, leave the writer unchanged, and return ``-1``.
1574+
15661575
.. c:function:: int PyUnicodeWriter_WriteStr(PyUnicodeWriter *writer, PyObject *obj)
15671576
15681577
Call :c:func:`PyObject_Str` on *obj* and write the output into *writer*.

Doc/howto/free-threading-extensions.rst

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,24 @@ Containers like :c:struct:`PyListObject`,
114114
in the free-threaded build. For example, the :c:func:`PyList_Append` will
115115
lock the list before appending an item.
116116

117+
.. _PyDict_Next:
118+
119+
``PyDict_Next``
120+
'''''''''''''''
121+
122+
A notable exception is :c:func:`PyDict_Next`, which does not lock the
123+
dictionary. You should use :c:macro:`Py_BEGIN_CRITICAL_SECTION` to protect
124+
the dictionary while iterating over it if the dictionary may be concurrently
125+
modified::
126+
127+
Py_BEGIN_CRITICAL_SECTION(dict);
128+
PyObject *key, *value;
129+
Py_ssize_t pos = 0;
130+
while (PyDict_Next(dict, &pos, &key, &value)) {
131+
...
132+
}
133+
Py_END_CRITICAL_SECTION();
134+
117135

118136
Borrowed References
119137
===================
@@ -141,7 +159,7 @@ that return :term:`strong references <strong reference>`.
141159
+-----------------------------------+-----------------------------------+
142160
| :c:func:`PyDict_SetDefault` | :c:func:`PyDict_SetDefaultRef` |
143161
+-----------------------------------+-----------------------------------+
144-
| :c:func:`PyDict_Next` | no direct replacement |
162+
| :c:func:`PyDict_Next` | none (see :ref:`PyDict_Next`) |
145163
+-----------------------------------+-----------------------------------+
146164
| :c:func:`PyWeakref_GetObject` | :c:func:`PyWeakref_GetRef` |
147165
+-----------------------------------+-----------------------------------+

Doc/library/pathlib.rst

Lines changed: 51 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,30 +1543,39 @@ Copying, renaming and deleting
15431543
Remove this directory. The directory must be empty.
15441544

15451545

1546-
Other methods
1547-
^^^^^^^^^^^^^
1546+
Permissions and ownership
1547+
^^^^^^^^^^^^^^^^^^^^^^^^^
15481548

1549-
.. classmethod:: Path.cwd()
1549+
.. method:: Path.owner(*, follow_symlinks=True)
15501550

1551-
Return a new path object representing the current directory (as returned
1552-
by :func:`os.getcwd`)::
1551+
Return the name of the user owning the file. :exc:`KeyError` is raised
1552+
if the file's user identifier (UID) isn't found in the system database.
15531553

1554-
>>> Path.cwd()
1555-
PosixPath('/home/antoine/pathlib')
1554+
This method normally follows symlinks; to get the owner of the symlink, add
1555+
the argument ``follow_symlinks=False``.
15561556

1557+
.. versionchanged:: 3.13
1558+
Raises :exc:`UnsupportedOperation` if the :mod:`pwd` module is not
1559+
available. In earlier versions, :exc:`NotImplementedError` was raised.
15571560

1558-
.. classmethod:: Path.home()
1561+
.. versionchanged:: 3.13
1562+
The *follow_symlinks* parameter was added.
15591563

1560-
Return a new path object representing the user's home directory (as
1561-
returned by :func:`os.path.expanduser` with ``~`` construct). If the home
1562-
directory can't be resolved, :exc:`RuntimeError` is raised.
15631564

1564-
::
1565+
.. method:: Path.group(*, follow_symlinks=True)
15651566

1566-
>>> Path.home()
1567-
PosixPath('/home/antoine')
1567+
Return the name of the group owning the file. :exc:`KeyError` is raised
1568+
if the file's group identifier (GID) isn't found in the system database.
15681569

1569-
.. versionadded:: 3.5
1570+
This method normally follows symlinks; to get the group of the symlink, add
1571+
the argument ``follow_symlinks=False``.
1572+
1573+
.. versionchanged:: 3.13
1574+
Raises :exc:`UnsupportedOperation` if the :mod:`grp` module is not
1575+
available. In earlier versions, :exc:`NotImplementedError` was raised.
1576+
1577+
.. versionchanged:: 3.13
1578+
The *follow_symlinks* parameter was added.
15701579

15711580

15721581
.. method:: Path.chmod(mode, *, follow_symlinks=True)
@@ -1589,57 +1598,52 @@ Other methods
15891598
.. versionchanged:: 3.10
15901599
The *follow_symlinks* parameter was added.
15911600

1592-
.. method:: Path.expanduser()
15931601

1594-
Return a new path with expanded ``~`` and ``~user`` constructs,
1595-
as returned by :meth:`os.path.expanduser`. If a home directory can't be
1596-
resolved, :exc:`RuntimeError` is raised.
1602+
.. method:: Path.lchmod(mode)
15971603

1598-
::
1604+
Like :meth:`Path.chmod` but, if the path points to a symbolic link, the
1605+
symbolic link's mode is changed rather than its target's.
15991606

1600-
>>> p = PosixPath('~/films/Monty Python')
1601-
>>> p.expanduser()
1602-
PosixPath('/home/eric/films/Monty Python')
16031607

1604-
.. versionadded:: 3.5
1608+
Other methods
1609+
^^^^^^^^^^^^^
16051610

1611+
.. classmethod:: Path.cwd()
16061612

1607-
.. method:: Path.group(*, follow_symlinks=True)
1613+
Return a new path object representing the current directory (as returned
1614+
by :func:`os.getcwd`)::
16081615

1609-
Return the name of the group owning the file. :exc:`KeyError` is raised
1610-
if the file's gid isn't found in the system database.
1616+
>>> Path.cwd()
1617+
PosixPath('/home/antoine/pathlib')
16111618

1612-
This method normally follows symlinks; to get the group of the symlink, add
1613-
the argument ``follow_symlinks=False``.
16141619

1615-
.. versionchanged:: 3.13
1616-
Raises :exc:`UnsupportedOperation` if the :mod:`grp` module is not
1617-
available. In previous versions, :exc:`NotImplementedError` was raised.
1620+
.. classmethod:: Path.home()
16181621

1619-
.. versionchanged:: 3.13
1620-
The *follow_symlinks* parameter was added.
1622+
Return a new path object representing the user's home directory (as
1623+
returned by :func:`os.path.expanduser` with ``~`` construct). If the home
1624+
directory can't be resolved, :exc:`RuntimeError` is raised.
16211625

1626+
::
16221627

1623-
.. method:: Path.lchmod(mode)
1628+
>>> Path.home()
1629+
PosixPath('/home/antoine')
16241630

1625-
Like :meth:`Path.chmod` but, if the path points to a symbolic link, the
1626-
symbolic link's mode is changed rather than its target's.
1631+
.. versionadded:: 3.5
16271632

16281633

1629-
.. method:: Path.owner(*, follow_symlinks=True)
1634+
.. method:: Path.expanduser()
16301635

1631-
Return the name of the user owning the file. :exc:`KeyError` is raised
1632-
if the file's uid isn't found in the system database.
1636+
Return a new path with expanded ``~`` and ``~user`` constructs,
1637+
as returned by :meth:`os.path.expanduser`. If a home directory can't be
1638+
resolved, :exc:`RuntimeError` is raised.
16331639

1634-
This method normally follows symlinks; to get the owner of the symlink, add
1635-
the argument ``follow_symlinks=False``.
1640+
::
16361641

1637-
.. versionchanged:: 3.13
1638-
Raises :exc:`UnsupportedOperation` if the :mod:`pwd` module is not
1639-
available. In previous versions, :exc:`NotImplementedError` was raised.
1642+
>>> p = PosixPath('~/films/Monty Python')
1643+
>>> p.expanduser()
1644+
PosixPath('/home/eric/films/Monty Python')
16401645

1641-
.. versionchanged:: 3.13
1642-
The *follow_symlinks* parameter was added.
1646+
.. versionadded:: 3.5
16431647

16441648

16451649
.. method:: Path.readlink()

Doc/library/typing.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@ This module provides runtime support for type hints.
2727

2828
Consider the function below::
2929

30-
def moon_weight(earth_weight: float) -> str:
31-
return f'On the moon, you would weigh {earth_weight * 0.166} kilograms.'
30+
def surface_area_of_cube(edge_length: float) -> str:
31+
return f"The surface area of the cube is {6 * edge_length ** 2}."
3232

33-
The function ``moon_weight`` takes an argument expected to be an instance of :class:`float`,
34-
as indicated by the *type hint* ``earth_weight: float``. The function is expected to
35-
return an instance of :class:`str`, as indicated by the ``-> str`` hint.
33+
The function ``surface_area_of_cube`` takes an argument expected to
34+
be an instance of :class:`float`, as indicated by the :term:`type hint`
35+
``edge_length: float``. The function is expected to return an instance
36+
of :class:`str`, as indicated by the ``-> str`` hint.
3637

3738
While type hints can be simple classes like :class:`float` or :class:`str`,
3839
they can also be more complex. The :mod:`typing` module provides a vocabulary of

Doc/whatsnew/3.14.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ New Features
314314
* :c:func:`PyUnicodeWriter_Finish`.
315315
* :c:func:`PyUnicodeWriter_WriteChar`.
316316
* :c:func:`PyUnicodeWriter_WriteUTF8`.
317+
* :c:func:`PyUnicodeWriter_WriteUCS4`.
317318
* :c:func:`PyUnicodeWriter_WriteWideChar`.
318319
* :c:func:`PyUnicodeWriter_WriteStr`.
319320
* :c:func:`PyUnicodeWriter_WriteRepr`.

Include/cpython/unicodeobject.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,10 @@ PyAPI_FUNC(int) PyUnicodeWriter_WriteWideChar(
463463
PyUnicodeWriter *writer,
464464
const wchar_t *str,
465465
Py_ssize_t size);
466+
PyAPI_FUNC(int) PyUnicodeWriter_WriteUCS4(
467+
PyUnicodeWriter *writer,
468+
Py_UCS4 *str,
469+
Py_ssize_t size);
466470

467471
PyAPI_FUNC(int) PyUnicodeWriter_WriteStr(
468472
PyUnicodeWriter *writer,

Include/internal/pycore_pyerrors.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ void _PyErr_FormatNote(const char *format, ...);
168168
Py_DEPRECATED(3.12) extern void _PyErr_ChainExceptions(PyObject *, PyObject *, PyObject *);
169169

170170
// implementation detail for the codeop module.
171-
extern PyTypeObject _PyExc_IncompleteInputError;
171+
// Exported for test.test_peg_generator.test_c_parser
172+
PyAPI_DATA(PyTypeObject) _PyExc_IncompleteInputError;
172173
#define PyExc_IncompleteInputError ((PyObject *)(&_PyExc_IncompleteInputError))
173174

174175
#ifdef __cplusplus

0 commit comments

Comments
 (0)
0