Skip to content

Commit 3c1c647

Browse files
committed
Merge remote-tracking branch 'upstream/main' into expose_codegen
2 parents a2a1c17 + c43714f commit 3c1c647

File tree

88 files changed

+1187
-2132
lines changed

Some content is hidden

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

88 files changed

+1187
-2132
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/ctypes.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ from within *IDLE* or *PythonWin*::
359359
>>> printf(b"%f bottles of beer\n", 42.5)
360360
Traceback (most recent call last):
361361
File "<stdin>", line 1, in <module>
362-
ArgumentError: argument 2: exceptions.TypeError: Don't know how to convert parameter 2
362+
ArgumentError: argument 2: TypeError: Don't know how to convert parameter 2
363363
>>>
364364

365365
As has been mentioned before, all Python types except integers, strings, and
@@ -422,7 +422,7 @@ prototype for a C function), and tries to convert the arguments to valid types::
422422
>>> printf(b"%d %d %d", 1, 2, 3)
423423
Traceback (most recent call last):
424424
File "<stdin>", line 1, in <module>
425-
ArgumentError: argument 2: exceptions.TypeError: wrong type
425+
ArgumentError: argument 2: TypeError: wrong type
426426
>>> printf(b"%s %d %f\n", b"X", 2, 3)
427427
X 2 3.000000
428428
13
@@ -487,7 +487,7 @@ single character Python bytes object into a C char::
487487
>>> strchr(b"abcdef", b"def")
488488
Traceback (most recent call last):
489489
File "<stdin>", line 1, in <module>
490-
ArgumentError: argument 2: exceptions.TypeError: one character string expected
490+
ArgumentError: argument 2: TypeError: one character string expected
491491
>>> print(strchr(b"abcdef", b"x"))
492492
None
493493
>>> strchr(b"abcdef", b"d")

Doc/library/enum.rst

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,8 @@ Data Types
242242

243243
Member values can be anything: :class:`int`, :class:`str`, etc.. If
244244
the exact value is unimportant you may use :class:`auto` instances and an
245-
appropriate value will be chosen for you. Care must be taken if you mix
246-
:class:`auto` with other values.
245+
appropriate value will be chosen for you. See :class:`auto` for the
246+
details.
247247

248248
.. attribute:: Enum._ignore_
249249

@@ -778,7 +778,16 @@ Utilities and Decorators
778778
For *Enum* and *IntEnum* that appropriate value will be the last value plus
779779
one; for *Flag* and *IntFlag* it will be the first power-of-two greater
780780
than the last value; for *StrEnum* it will be the lower-cased version of the
781-
member's name.
781+
member's name. Care must be taken if mixing *auto()* with manually specified
782+
values.
783+
784+
*auto* instances are only resolved when at the top level of an assignment:
785+
786+
* ``FIRST = auto()`` will work (auto() is replaced with ``1``);
787+
* ``SECOND = auto(), -2`` will work (auto is replaced with ``2``, so ``2, -2`` is
788+
used to create the ``SECOND`` enum member;
789+
* ``THREE = [auto(), -3]`` will *not* work (``<auto instance>, -3`` is used to
790+
create the ``THREE`` enum member)
782791

783792
``_generate_next_value_`` can be overridden to customize the values used by
784793
*auto*.

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

0 commit comments

Comments
 (0)