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

Skip to content

Commit f1d8888

Browse files
committed
Merge remote-tracking branch 'upstream/main' into fwdref-format
2 parents 675f55c + b1fc8b6 commit f1d8888

File tree

91 files changed

+3923
-833
lines changed

Some content is hidden

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

91 files changed

+3923
-833
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: 13 additions & 2 deletions
F438
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ descriptor.
7979
On macOS and NetBSD, the :mod:`!fcntl` module exposes the ``F_GETNOSIGPIPE``
8080
and ``F_SETNOSIGPIPE`` constant.
8181

82+
.. versionchanged:: next
83+
On Linux >= 6.1, the :mod:`!fcntl` module exposes the ``F_DUPFD_QUERY``
84+
to query a file descriptor pointing to the same file.
85+
8286
The module defines the following functions:
8387

8488

@@ -89,14 +93,14 @@ The module defines the following functions:
8993
for *cmd* are operating system dependent, and are available as constants
9094
in the :mod:`fcntl` module, using the same names as used in the relevant C
9195
header files. The argument *arg* can either be an integer value, a
92-
:class:`bytes` object, or a string.
96+
:term:`bytes-like object`, or a string.
9397
The type and size of *arg* must match the type and size of
9498
the argument of the operation as specified in the relevant C documentation.
9599

96100
When *arg* is an integer, the function returns the integer
97101
return value of the C :c:func:`fcntl` call.
98102

99-
When the argument is bytes, it represents a binary structure,
103+
When the argument is bytes-like object, it represents a binary structure,
100104
for example, created by :func:`struct.pack`.
101105
A string value is encoded to binary using the UTF-8 encoding.
102106
The binary data is copied to a buffer whose address is
@@ -117,6 +121,10 @@ The module defines the following functions:
117121

118122
.. audit-event:: fcntl.fcntl fd,cmd,arg fcntl.fcntl
119123

124+
.. versionchanged:: next
125+
Add support of arbitrary :term:`bytes-like objects <bytes-like object>`,
126+
not only :class:`bytes`.
127+
120128

121129
.. function:: ioctl(fd, request, arg=0, mutate_flag=True, /)
122130

@@ -173,6 +181,9 @@ The module defines the following functions:
173181

174182
.. audit-event:: fcntl.ioctl fd,request,arg fcntl.ioctl
175183

184+
.. versionchanged:: next
185+
The GIL is always released during a system call.
186+
System calls failing with EINTR are automatically retried.
176187

177188
.. function:: flock(fd, operation, /)
178189

Doc/library/gzip.rst

Line 10000 s changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,10 @@ Example of how to GZIP compress a binary string::
258258
The basic data compression module needed to support the :program:`gzip` file
259259
format.
260260

261+
In case gzip (de)compression is a bottleneck, the `python-isal`_
262+
package speeds up (de)compression with a mostly compatible API.
263+
264+
.. _python-isal: https://github.com/pycompression/python-isal
261265

262266
.. program:: gzip
263267

Doc/library/sys.monitoring.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ More events may be added in the future.
160160

161161
These events are attributes of the :mod:`!sys.monitoring.events` namespace.
162162
Each event is represented as a power-of-2 integer constant.
163-
To define a set of events, simply bitwise or the individual events together.
163+
To define a set of events, simply bitwise OR the individual events together.
164164
For example, to specify both :monitoring-event:`PY_RETURN` and :monitoring-event:`PY_START`
165165
events, use the expression ``PY_RETURN | PY_START``.
166166

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,3 +353,8 @@ the following constants:
353353
http://www.zlib.net/manual.html
354354
The zlib manual explains the semantics and usage of the library's many
355355
functions.
356+
357+
In case gzip (de)compression is a bottleneck, the `python-isal`_
358+
package speeds up (de)compression with a mostly compatible API.
359+
360+
.. _python-isal: https://github.com/pycompression/python-isal

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
@@ -99,7 +99,9 @@ PEP 768: Safe external debugger interface for CPython
9999

100100
:pep:`768` introduces a zero-overhead debugging interface that allows debuggers and profilers
101101
to safely attach to running Python processes. This is a significant enhancement to Python's
102-
debugging capabilities allowing debuggers to forego unsafe alternatives.
102+
debugging capabilities allowing debuggers to forego unsafe alternatives. See
103+
:ref:`below <whatsnew314-remote-pdb>` for how this feature is leveraged to
104+
implement the new :mod:`pdb` module's remote attaching capabilities.
103105

104106
The new interface provides safe execution points for attaching debugger code without modifying
105107
the interpreter's normal execution path or adding runtime overhead. This enables tools to
@@ -149,6 +151,32 @@ See :pep:`768` for more details.
149151

150152
(Contributed by Pablo Galindo Salgado, Matt Wozniski, and Ivona Stojanovic in :gh:`131591`.)
151153

154+
155+
.. _whatsnew314-remote-pdb:
156+
157+
Remote attaching to a running Python process with PDB
158+
-----------------------------------------------------
159+
160+
The :mod:`pdb` module now supports remote attaching to a running Python process
161+
using a new ``-p PID`` command-line option:
162+
163+
.. code-block:: sh
164+
165+
python -m pdb -p 1234
166+
167+
This will connect to the Python process with the given PID and allow you to
168+
debug it interactively. Notice that due to how the Python interpreter works
169+
attaching to a remote process that is blocked in a system call or waiting for
170+
I/O will only work once the next bytecode instruction is executed or when the
171+
process receives a signal.
172+
173+
This feature leverages :pep:`768` and the :func:`sys.remote_exec` function
174+
to attach to the remote process and send the PDB commands to it.
175+
176+
177+
(Contributed by Matt Wozniski and Pablo Galindo in :gh:`131591`.)
178+
179+
152180
.. _whatsnew314-pep758:
153181

154182
PEP 758 – Allow except and except* expressions without parentheses
@@ -320,6 +348,21 @@ Improved error messages
320348
^^^^^^^
321349
ValueError: too many values to unpack (expected 3, got 4)
322350
351+
* :keyword:`elif` statements that follow an :keyword:`else` block now have a specific error message.
352+
(Contributed by Steele Farnsworth in :gh:`129902`.)
353+
354+
.. code-block:: pycon
355+
356+
>>> if who == "me":
357+
... print("It's me!")
358+
... else:
359+
... print("It's not me!")
360+
... elif who is None:
361+
... print("Who is it?")
362+
File "<stdin>", line 5
363+
elif who is None:
364+
^^^^
365+
SyntaxError: 'elif' block follows an 'else' block
323366
324367
* If a statement (:keyword:`pass`, :keyword:`del`, :keyword:`return`,
325368
:keyword:`yield`, :keyword:`raise`, :keyword:`break`, :keyword:`continue`,

Grammar/python.gram

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,6 +1422,7 @@ invalid_elif_stmt:
14221422
invalid_else_stmt:
14231423
| a='else' ':' NEWLINE !INDENT {
14241424
RAISE_INDENTATION_ERROR("expected an indented block after 'else' statement on line %d", a->lineno) }
1425+
| 'else' ':' block 'elif' { RAISE_SYNTAX_ERROR("'elif' block follows an 'else' block")}
14251426
invalid_while_stmt:
14261427
| 'while' named_expression NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") }
14271428
| a='while' named_expression ':' NEWLINE !INDENT {

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_interp_structs.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ extern "C" {
99

1010
#include "pycore_ast_state.h" // struct ast_state
1111
#include "pycore_llist.h" // struct llist_node
12+
#include "pycore_memoryobject.h" // struct _memoryobject_state
1213
#include "pycore_opcode_utils.h" // NUM_COMMON_CONSTANTS
1314
#include "pycore_pymath.h" // _PY_SHORT_FLOAT_REPR
1415
#include "pycore_structs.h" // PyHamtObject
@@ -912,9 +913,10 @@ struct _is {
912913
struct _dtoa_state dtoa;
913914
struct _py_func_state func_state;
914915
struct _py_code_state code_state;
915-
916916
struct _Py_dict_state dict_state;
917917
struct _Py_exc_state exc_state;
918+
struct _memoryobject_state memobj_state;
919+
918920
struct _Py_mem_interp_free_queue mem_free_queue;
919921

920922
struct ast_state ast;

Include/internal/pycore_memoryobject.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@ extern "C" {
88
# error "this header requires Py_BUILD_CORE define"
99
#endif
1010

11+
struct _memoryobject_state {
12+
PyTypeObject *XIBufferViewType;
13+
};
14+
15+
extern PyStatus _PyMemoryView_InitTypes(PyInterpreterState *);
16+
extern void _PyMemoryView_FiniTypes(PyInterpreterState *);
17+
18+
// exported for _interpreters module
19+
PyAPI_FUNC(PyTypeObject *) _PyMemoryView_GetXIBuffewViewType(void);
20+
21+
1122
extern PyTypeObject _PyManagedBuffer_Type;
1223

1324
PyObject *

Include/internal/pycore_opcode_metadata.h

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

0 commit comments

Comments
 (0)
0