Skip to content

Commit 7e7c13e

Browse files
committed
Merge remote-tracking branch 'upstream/main' into jit-call-tuple-1
2 parents 1a75e53 + 0a387b3 commit 7e7c13e

File tree

72 files changed

+1404
-416
lines changed

Some content is hidden

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

72 files changed

+1404
-416
lines changed

Doc/c-api/intro.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ complete listing.
148148
.. c:macro:: Py_ALWAYS_INLINE
149149
150150
Ask the compiler to always inline a static inline function. The compiler can
151-
ignore it and decides to not inline the function.
151+
ignore it and decide to not inline the function.
152152

153153
It can be used to inline performance critical static inline functions when
154154
building Python in debug mode with function inlining disabled. For example,

Doc/library/decimal.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,8 @@ Decimal objects
367367
appears above. These include decimal digits from various other
368368
alphabets (for example, Arabic-Indic and Devanāgarī digits) along
369369
with the fullwidth digits ``'\uff10'`` through ``'\uff19'``.
370+
Case is not significant, so, for example, ``inf``, ``Inf``, ``INFINITY``,
371+
and ``iNfINity`` are all acceptable spellings for positive infinity.
370372

371373
If *value* is a :class:`tuple`, it should have three components, a sign
372374
(``0`` for positive or ``1`` for negative), a :class:`tuple` of

Doc/library/fcntl.rst

Lines changed: 53 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -82,65 +82,86 @@ descriptor.
8282
The module defines the following functions:
8383

8484

85-
.. function:: fcntl(fd, cmd, arg=0)
85+
.. function:: fcntl(fd, cmd, arg=0, /)
8686

8787
Perform the operation *cmd* on file descriptor *fd* (file objects providing
8888
a :meth:`~io.IOBase.fileno` method are accepted as well). The values used
8989
for *cmd* are operating system dependent, and are available as constants
9090
in the :mod:`fcntl` module, using the same names as used in the relevant C
91-
header files. The argument *arg* can either be an integer value, or a
92-
:class:`bytes` object. With an integer value, the return value of this
93-
function is the integer return value of the C :c:func:`fcntl` call. When
94-
the argument is bytes it represents a binary structure, e.g. created by
95-
:func:`struct.pack`. The binary data is copied to a buffer whose address is
91+
header files. The argument *arg* can either be an integer value, a
92+
:term:`bytes-like object`, or a string.
93+
The type and size of *arg* must match the type and size of
94+
the argument of the operation as specified in the relevant C documentation.
95+
96+
When *arg* is an integer, the function returns the integer
97+
return value of the C :c:func:`fcntl` call.
98+
99+
When the argument is bytes-like object, it represents a binary structure,
100+
for example, created by :func:`struct.pack`.
101+
A string value is encoded to binary using the UTF-8 encoding.
102+
The binary data is copied to a buffer whose address is
96103
passed to the C :c:func:`fcntl` call. The return value after a successful
97104
call is the contents of the buffer, converted to a :class:`bytes` object.
98105
The length of the returned object will be the same as the length of the
99-
*arg* argument. This is limited to 1024 bytes. If the information returned
100-
in the buffer by the operating system is larger than 1024 bytes, this is
101-
most likely to result in a segmentation violation or a more subtle data
102-
corruption.
106+
*arg* argument. This is limited to 1024 bytes.
103107

104108
If the :c:func:`fcntl` call fails, an :exc:`OSError` is raised.
105109

110+
.. note::
111+
If the type or the size of *arg* does not match the type or size
112+
of the argument of the operation (for example, if an integer is
113+
passed when a pointer is expected, or the information returned in
114+
the buffer by the operating system is larger than 1024 bytes),
115+
this is most likely to result in a segmentation violation or
116+
a more subtle data corruption.
117+
106118
.. audit-event:: fcntl.fcntl fd,cmd,arg fcntl.fcntl
107119

120+
.. versionchanged:: next
121+
Add support of arbitrary :term:`bytes-like objects <bytes-like object>`,
122+
not only :class:`bytes`.
123+
108124

109-
.. function:: ioctl(fd, request, arg=0, mutate_flag=True)
125+
.. function:: ioctl(fd, request, arg=0, mutate_flag=True, /)
110126

111127
This function is identical to the :func:`~fcntl.fcntl` function, except
112128
that the argument handling is even more complicated.
113129

114-
The *request* parameter is limited to values that can fit in 32-bits.
130+
The *request* parameter is limited to values that can fit in 32-bits
131+
or 64-bits, depending on the platform.
115132
Additional constants of interest for use as the *request* argument can be
116133
found in the :mod:`termios` module, under the same names as used in
117134
the relevant C header files.
118135

119-
The parameter *arg* can be one of an integer, an object supporting the
120-
read-only buffer interface (like :class:`bytes`) or an object supporting
121-
the read-write buffer interface (like :class:`bytearray`).
136+
The parameter *arg* can be an integer, a :term:`bytes-like object`,
137+
or a string.
138+
The type and size of *arg* must match the type and size of
139+
the argument of the operation as specified in the relevant C documentation.
122140

123-
In all but the last case, behaviour is as for the :func:`~fcntl.fcntl`
141+
If *arg* does not support the read-write buffer interface or
142+
the *mutate_flag* is false, behavior is as for the :func:`~fcntl.fcntl`
124143
function.
125144

126-
If a mutable buffer is passed, then the behaviour is determined by the value of
127-
the *mutate_flag* parameter.
128-
129-
If it is false, the buffer's mutability is ignored and behaviour is as for a
130-
read-only buffer, except that the 1024 byte limit mentioned above is avoided --
131-
so long as the buffer you pass is at least as long as what the operating system
132-
wants to put there, things should work.
133-
134-
If *mutate_flag* is true (the default), then the buffer is (in effect) passed
135-
to the underlying :func:`ioctl` system call, the latter's return code is
145+
If *arg* supports the read-write buffer interface (like :class:`bytearray`)
146+
and *mutate_flag* is true (the default), then the buffer is (in effect) passed
147+
to the underlying :c:func:`!ioctl` system call, the latter's return code is
136148
passed back to the calling Python, and the buffer's new contents reflect the
137-
action of the :func:`ioctl`. This is a slight simplification, because if the
149+
action of the :c:func:`ioctl`. This is a slight simplification, because if the
138150
supplied buffer is less than 1024 bytes long it is first copied into a static
139151
buffer 1024 bytes long which is then passed to :func:`ioctl` and copied back
140152
into the supplied buffer.
141153

142154
If the :c:func:`ioctl` call fails, an :exc:`OSError` exception is raised.
143155

156+
.. note::
157+
If the type or size of *arg* does not match the type or size
158+
of the operation's argument (for example, if an integer is
159+
passed when a pointer is expected, or the information returned in
160+
the buffer by the operating system is larger than 1024 bytes,
161+
or the size of the mutable bytes-like object is too small),
162+
this is most likely to result in a segmentation violation or
163+
a more subtle data corruption.
164+
144165
An example::
145166

146167
>>> import array, fcntl, struct, termios, os
@@ -156,8 +177,11 @@ The module defines the following functions:
156177

157178
.. audit-event:: fcntl.ioctl fd,request,arg fcntl.ioctl
158179

180+
.. versionchanged:: next
181+
The GIL is always released during a system call.
182+
System calls failing with EINTR are automatically retried.
159183

160-
.. function:: flock(fd, operation)
184+
.. function:: flock(fd, operation, /)
161185

162186
Perform the lock operation *operation* on file descriptor *fd* (file objects providing
163187
a :meth:`~io.IOBase.fileno` method are accepted as well). See the Unix manual
@@ -169,7 +193,7 @@ The module defines the following functions:
169193
.. audit-event:: fcntl.flock fd,operation fcntl.flock
170194

171195

172-
.. function:: lockf(fd, cmd, len=0, start=0, whence=0)
196+
.. function:: lockf(fd, cmd, len=0, start=0, whence=0, /)
173197

174198
This is essentially a wrapper around the :func:`~fcntl.fcntl` locking calls.
175199
*fd* is the file descriptor (file objects providing a :meth:`~io.IOBase.fileno`

Doc/library/struct.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,9 @@ C11 standard) is supported, the following format characters are available:
273273
+--------+--------------------------+--------------------+----------------+------------+
274274
| Format | C Type | Python type | Standard size | Notes |
275275
+========+==========================+====================+================+============+
276-
| ``E`` | :c:expr:`float complex` | complex | 8 | \(10) |
276+
| ``F`` | :c:expr:`float complex` | complex | 8 | \(10) |
277277
+--------+--------------------------+--------------------+----------------+------------+
278-
| ``C`` | :c:expr:`double complex` | complex | 16 | \(10) |
278+
| ``D`` | :c:expr:`double complex` | complex | 16 | \(10) |
279279
+--------+--------------------------+--------------------+----------------+------------+
280280

281281
.. versionchanged:: 3.3
@@ -285,7 +285,7 @@ C11 standard) is supported, the following format characters are available:
285285
Added support for the ``'e'`` format.
286286

287287
.. versionchanged:: 3.14
288-
Added support for the ``'E'`` and ``'C'`` formats.
288+
Added support for the ``'F'`` and ``'D'`` formats.
289289

290290

291291
Notes:

Doc/library/webbrowser.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,8 @@ Here are some simple examples::
226226
Browser Controller Objects
227227
--------------------------
228228

229-
Browser controllers provide these methods which parallel three of the
230-
module-level convenience functions:
229+
Browser controllers provide the :attr:`~controller.name` attribute,
230+
and the following three methods which parallel module-level convenience functions:
231231

232232

233233
.. attribute:: controller.name

Doc/reference/datamodel.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,18 +1526,17 @@ positional arguments; bit ``0x08`` is set if the function uses the
15261526
if the function is a generator. See :ref:`inspect-module-co-flags` for details
15271527
on the semantics of each flags that might be present.
15281528

1529-
Future feature declarations (``from __future__ import division``) also use bits
1529+
Future feature declarations (for example, ``from __future__ import division``) also use bits
15301530
in :attr:`~codeobject.co_flags` to indicate whether a code object was compiled with a
1531-
particular feature enabled: bit ``0x2000`` is set if the function was compiled
1532-
with future division enabled; bits ``0x10`` and ``0x1000`` were used in earlier
1533-
versions of Python.
1531+
particular feature enabled. See :attr:`~__future__._Feature.compiler_flag`.
15341532

15351533
Other bits in :attr:`~codeobject.co_flags` are reserved for internal use.
15361534

15371535
.. index:: single: documentation string
15381536

15391537
If a code object represents a function and has a docstring,
1540-
the first item in :attr:`~codeobject.co_consts` is
1538+
the :data:`~inspect.CO_HAS_DOCSTRING` bit is set in :attr:`~codeobject.co_flags`
1539+
and the first item in :attr:`~codeobject.co_consts` is
15411540
the docstring of the function.
15421541

15431542
Methods on code objects

Doc/whatsnew/3.14.rst

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,49 @@ is unchanged.
264264
Improved error messages
265265
-----------------------
266266

267+
* The interpreter now provides helpful suggestions when it detects typos in Python
268+
keywords. When a word that closely resembles a Python keyword is encountered,
269+
the interpreter will suggest the correct keyword in the error message. This
270+
feature helps programmers quickly identify and fix common typing mistakes. For
271+
example:
272+
273+
.. code-block:: python
274+
275+
>>> whille True:
276+
... pass
277+
Traceback (most recent call last):
278+
File "<stdin>", line 1
279+
whille True:
280+
^^^^^^
281+
SyntaxError: invalid syntax. Did you mean 'while'?
282+
283+
>>> asynch def fetch_data():
284+
... pass
285+
Traceback (most recent call last):
286+
File "<stdin>", line 1
287+
asynch def fetch_data():
288+
^^^^^^
289+
SyntaxError: invalid syntax. Did you mean 'async'?
290+
291+
>>> async def foo():
292+
... awaid fetch_data()
293+
Traceback (most recent call last):
294+
File "<stdin>", line 2
295+
awaid fetch_data()
296+
^^^^^
297+
SyntaxError: invalid syntax. Did you mean 'await'?
298+
299+
>>> raisee ValueError("Error")
300+
Traceback (most recent call last):
301+
File "<stdin>", line 1
302+
raisee ValueError("Error")
303+
^^^^^^
304+
SyntaxError: invalid syntax. Did you mean 'raise'?
305+
306+
While the feature focuses on the most common cases, some variations of
307+
misspellings may still result in regular syntax errors.
308+
(Contributed by Pablo Galindo in :gh:`132449`.)
309+
267310
* When unpacking assignment fails due to incorrect number of variables, the
268311
error message prints the received number of values in more cases than before.
269312
(Contributed by Tushar Sadhwani in :gh:`122239`.)
@@ -1130,7 +1173,7 @@ struct
11301173
------
11311174

11321175
* Support the :c:expr:`float complex` and :c:expr:`double complex` C types in
1133-
the :mod:`struct` module (formatting characters ``'E'`` and ``'C'``,
1176+
the :mod:`struct` module (formatting characters ``'F'`` and ``'D'``,
11341177
respectively) if the compiler has C11 complex arithmetic.
11351178
(Contributed by Sergey B Kirpichev in :gh:`121249`.)
11361179

Include/internal/pycore_ceval.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,10 @@ PyAPI_FUNC(_PyStackRef) _PyFloat_FromDouble_ConsumeInputs(_PyStackRef left, _PyS
373373
#endif
374374
#endif
375375

376+
#if defined(Py_REMOTE_DEBUG) && defined(Py_SUPPORTS_REMOTE_DEBUG)
377+
extern int _PyRunRemoteDebugger(PyThreadState *tstate);
378+
#endif
379+
376380
#ifdef __cplusplus
377381
}
378382
#endif

Include/internal/pycore_uop_metadata.h

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

InternalDocs/garbage_collector.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ superset of any unreachable cycle including that object, we are guaranteed that
417417
transitive closure cannot contain any partial cycles.
418418
We can exclude scanned objects, as they must have been reachable when scanned.
419419
If a scanned object becomes part of an unreachable cycle after being scanned, it will
420-
not be collected this at this time, but it will be collected in the next full scavenge.
420+
not be collected at this time, but it will be collected in the next full scavenge.
421421

422422
> [!NOTE]
423423
> The GC implementation for the free-threaded build does not use incremental collection.

0 commit comments

Comments
 (0)