Skip to content

Commit 3020fee

Browse files
committed
Merge remote-tracking branch 'upstream/main' into pep688v2
2 parents 46a9239 + a309ad9 commit 3020fee

File tree

69 files changed

+762
-2087
lines changed

Some content is hidden

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

69 files changed

+762
-2087
lines changed

Doc/c-api/call.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ This is a pointer to a function with the following signature:
9393
and they must be unique.
9494
If there are no keyword arguments, then *kwnames* can instead be *NULL*.
9595

96-
.. c:macro:: PY_VECTORCALL_ARGUMENTS_OFFSET
96+
.. data:: PY_VECTORCALL_ARGUMENTS_OFFSET
9797

9898
If this flag is set in a vectorcall *nargsf* argument, the callee is allowed
9999
to temporarily change ``args[-1]``. In other words, *args* points to

Doc/c-api/typeobj.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,6 +1245,17 @@ and :c:type:`PyType_Type` effectively act as defaults.)
12451245
**Inheritance:**
12461246

12471247
This flag is not inherited.
1248+
However, subclasses will not be instantiable unless they provide a
1249+
non-NULL :c:member:`~PyTypeObject.tp_new` (which is only possible
1250+
via the C API).
1251+
1252+
.. note::
1253+
1254+
To disallow instantiating a class directly but allow instantiating
1255+
its subclasses (e.g. for an :term:`abstract base class`),
1256+
do not use this flag.
1257+
Instead, make :c:member:`~PyTypeObject.tp_new` only succeed for
1258+
subclasses.
12481259

12491260
.. versionadded:: 3.10
12501261

Doc/faq/windows.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ How can I embed Python into a Windows application?
167167

168168
Embedding the Python interpreter in a Windows app can be summarized as follows:
169169

170-
1. Do _not_ build Python into your .exe file directly. On Windows, Python must
170+
1. Do **not** build Python into your .exe file directly. On Windows, Python must
171171
be a DLL to handle importing modules that are themselves DLL's. (This is the
172172
first key undocumented fact.) Instead, link to :file:`python{NN}.dll`; it is
173173
typically installed in ``C:\Windows\System``. *NN* is the Python version, a
@@ -191,7 +191,7 @@ Embedding the Python interpreter in a Windows app can be summarized as follows:
191191
2. If you use SWIG, it is easy to create a Python "extension module" that will
192192
make the app's data and methods available to Python. SWIG will handle just
193193
about all the grungy details for you. The result is C code that you link
194-
*into* your .exe file (!) You do _not_ have to create a DLL file, and this
194+
*into* your .exe file (!) You do **not** have to create a DLL file, and this
195195
also simplifies linking.
196196

197197
3. SWIG will create an init function (a C function) whose name depends on the
@@ -218,10 +218,10 @@ Embedding the Python interpreter in a Windows app can be summarized as follows:
218218
5. There are two problems with Python's C API which will become apparent if you
219219
use a compiler other than MSVC, the compiler used to build pythonNN.dll.
220220

221-
Problem 1: The so-called "Very High Level" functions that take FILE *
221+
Problem 1: The so-called "Very High Level" functions that take ``FILE *``
222222
arguments will not work in a multi-compiler environment because each
223-
compiler's notion of a struct FILE will be different. From an implementation
224-
standpoint these are very _low_ level functions.
223+
compiler's notion of a ``struct FILE`` will be different. From an implementation
224+
standpoint these are very low level functions.
225225

226226
Problem 2: SWIG generates the following code when generating wrappers to void
227227
functions:

Doc/library/functions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1419,7 +1419,7 @@ are always available. They are listed here in alphabetical order.
14191419
supported.
14201420

14211421

1422-
.. function:: print(*objects, sep=' ', end='\n', file=sys.stdout, flush=False)
1422+
.. function:: print(*objects, sep=' ', end='\n', file=None, flush=False)
14231423

14241424
Print *objects* to the text stream *file*, separated by *sep* and followed
14251425
by *end*. *sep*, *end*, *file*, and *flush*, if present, must be given as keyword

Doc/library/socket.rst

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,11 @@ created. Socket addresses are represented as follows:
189189
``(ifname, proto[, pkttype[, hatype[, addr]]])`` where:
190190

191191
- *ifname* - String specifying the device name.
192-
- *proto* - An in network-byte-order integer specifying the Ethernet
193-
protocol number.
192+
- *proto* - The Ethernet protocol number.
193+
May be :data:`ETH_P_ALL` to capture all protocols,
194+
one of the :ref:`ETHERTYPE_* constants <socket-ethernet-types>`
195+
or any other Ethernet protocol number.
196+
Value must be in network-byte-order.
194197
- *pkttype* - Optional integer specifying the packet type:
195198

196199
- ``PACKET_HOST`` (the default) - Packet addressed to the local host.
@@ -508,6 +511,19 @@ Constants
508511
.. availability:: Linux >= 2.2.
509512

510513

514+
.. data:: ETH_P_ALL
515+
516+
:data:`!ETH_P_ALL` can be used in the :class:`~socket.socket`
517+
constructor as *proto* for the :const:`AF_PACKET` family in order to
518+
capture every packet, regardless of protocol.
519+
520+
For more information, see the :manpage:`packet(7)` manpage.
521+
522+
.. availability:: Linux.
523+
524+
.. versionadded:: 3.12
525+
526+
511527
.. data:: AF_RDS
512528
PF_RDS
513529
SOL_RDS
@@ -638,6 +654,22 @@ Constants
638654

639655
.. versionadded:: 3.12
640656

657+
.. _socket-ethernet-types:
658+
659+
.. data:: ETHERTYPE_ARP
660+
ETHERTYPE_IP
661+
ETHERTYPE_IPV6
662+
ETHERTYPE_VLAN
663+
664+
`IEEE 802.3 protocol number
665+
<https://www.iana.org/assignments/ieee-802-numbers/ieee-802-numbers.txt>`_.
666+
constants.
667+
668+
.. availability:: Linux, FreeBSD, macOS.
669+
670+
.. versionadded:: 3.12
671+
672+
641673
Functions
642674
^^^^^^^^^
643675

Doc/library/sqlite3.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1834,8 +1834,13 @@ The deprecated default adapters and converters consist of:
18341834
Command-line interface
18351835
^^^^^^^^^^^^^^^^^^^^^^
18361836

1837-
The :mod:`!sqlite3` module can be invoked as a script
1837+
The :mod:`!sqlite3` module can be invoked as a script,
1838+
using the interpreter's :option:`-m` switch,
18381839
in order to provide a simple SQLite shell.
1840+
The argument signature is as follows::
1841+
1842+
python -m sqlite3 [-h] [-v] [filename] [sql]
1843+
18391844
Type ``.quit`` or CTRL-D to exit the shell.
18401845

18411846
.. program:: python -m sqlite3 [-h] [-v] [filename] [sql]

Doc/reference/grammar.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ and `PEG <https://en.wikipedia.org/wiki/Parsing_expression_grammar>`_.
1212
In particular, ``&`` followed by a symbol, token or parenthesized
1313
group indicates a positive lookahead (i.e., is required to match but
1414
not consumed), while ``!`` indicates a negative lookahead (i.e., is
15-
required _not_ to match). We use the ``|`` separator to mean PEG's
15+
required *not* to match). We use the ``|`` separator to mean PEG's
1616
"ordered choice" (written as ``/`` in traditional PEG grammars). See
1717
:pep:`617` for more details on the grammar's syntax.
1818

Doc/reference/simple_stmts.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ statement, of a variable or attribute annotation and an optional assignment stat
330330
annotated_assignment_stmt: `augtarget` ":" `expression`
331331
: ["=" (`starred_expression` | `yield_expression`)]
332332

333-
The difference from normal :ref:`assignment` is that only single target is allowed.
333+
The difference from normal :ref:`assignment` is that only a single target is allowed.
334334

335335
For simple names as assignment targets, if in class or module scope,
336336
the annotations are evaluated and stored in a special class or module
@@ -365,8 +365,8 @@ target, then the interpreter evaluates the target except for the last
365365
IDEs.
366366

367367
.. versionchanged:: 3.8
368-
Now annotated assignments allow same expressions in the right hand side as
369-
the regular assignments. Previously, some expressions (like un-parenthesized
368+
Now annotated assignments allow the same expressions in the right hand side as
369+
regular assignments. Previously, some expressions (like un-parenthesized
370370
tuple expressions) caused a syntax error.
371371

372372

@@ -756,7 +756,7 @@ commas) the two steps are carried out separately for each clause, just
756756
as though the clauses had been separated out into individual import
757757
statements.
758758

759-
The details of the first step, finding and loading modules are described in
759+
The details of the first step, finding and loading modules, are described in
760760
greater detail in the section on the :ref:`import system <importsystem>`,
761761
which also describes the various types of packages and modules that can
762762
be imported, as well as all the hooks that can be used to customize

Doc/whatsnew/3.12.rst

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,15 @@ Important deprecations, removals or restrictions:
7575
Improved Error Messages
7676
=======================
7777

78+
* Modules from the standard library are now potentially suggested as part of
79+
the error messages displayed by the interpreter when a :exc:`NameError` is
80+
raised to the top level. Contributed by Pablo Galindo in :gh:`98254`.
81+
82+
>>> sys.version_info
83+
Traceback (most recent call last):
84+
File "<stdin>", line 1, in <module>
85+
NameError: name 'sys' is not defined. Did you forget to import 'sys'?
86+
7887
* Improve the error suggestion for :exc:`NameError` exceptions for instances.
7988
Now if a :exc:`NameError` is raised in a method and the instance has an
8089
attribute that's exactly equal to the name in the exception, the suggestion
@@ -106,6 +115,16 @@ Improved Error Messages
106115
^^^^^^^^^^^^^^^^^^^^^^^
107116
SyntaxError: Did you mean to use 'from ... import ...' instead?
108117

118+
* :exc:`ImportError` exceptions raised from failed ``from <module> import
119+
<name>`` statements now include suggestions for the value of ``<name>`` based on the
120+
available names in ``<module>``. Contributed by Pablo Galindo in :gh:`91058`.
121+
122+
>>> from collections import chainmap
123+
Traceback (most recent call last):
124+
File "<stdin>", line 1, in <module>
125+
ImportError: cannot import name 'chainmap' from 'collections'. Did you mean: 'ChainMap'?
126+
127+
109128
New Features
110129
============
111130

@@ -677,6 +696,18 @@ New Features
677696
``__dict__`` and weakrefs with less bookkeeping,
678697
using less memory and with faster access.
679698

699+
* API for performing calls using
700+
:ref:`the vectorcall protocol <vectorcall>` was added to the
701+
:ref:`Limited API <stable>`:
702+
703+
* :c:func:`PyObject_Vectorcall`
704+
* :c:func:`PyObject_VectorcallMethod`
705+
* :const:`PY_VECTORCALL_ARGUMENTS_OFFSET`
706+
707+
This means that both the incoming and outgoing ends of the vector call
708+
protocol are now available in the :ref:`Limited API <stable>`. (Contributed
709+
by Wenzel Jakob in :gh:`98586`.)
710+
680711
* Added two new public functions,
681712
:c:func:`PyEval_SetProfileAllThreads` and
682713
:c:func:`PyEval_SetTraceAllThreads`, that allow to set tracing and profiling

Grammar/python.gram

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,8 +1254,8 @@ invalid_try_stmt:
12541254
| a='try' ':' NEWLINE !INDENT {
12551255
RAISE_INDENTATION_ERROR("expected an indented block after 'try' statement on line %d", a->lineno) }
12561256
| 'try' ':' block !('except' | 'finally') { RAISE_SYNTAX_ERROR("expected 'except' or 'finally' block") }
1257-
| 'try' ':' block* ((except_block+ except_star_block) | (except_star_block+ except_block)) block* {
1258-
RAISE_SYNTAX_ERROR("cannot have both 'except' and 'except*' on the same 'try'") }
1257+
| a='try' ':' block* ((except_block+ except_star_block) | (except_star_block+ except_block)) block* {
1258+
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "cannot have both 'except' and 'except*' on the same 'try'") }
12591259
invalid_except_stmt:
12601260
| 'except' '*'? a=expression ',' expressions ['as' NAME ] ':' {
12611261
RAISE_SYNTAX_ERROR_STARTING_FROM(a, "multiple exception types must be parenthesized") }

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy