Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e0888de

Browse files
committed
Merge branch 'main' into justin
2 parents 8f6c5fe + 578ebc5 commit e0888de

379 files changed

Lines changed: 7884 additions & 2841 deletions

File tree

Some content is hidden

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

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ PCbuild/readme.txt dos
6666
[attr]generated linguist-generated=true diff=generated
6767

6868
**/clinic/*.c.h generated
69+
**/clinic/*.cpp.h generated
70+
**/clinic/*.h.h generated
6971
*_db.h generated
7072
Doc/data/stable_abi.dat generated
7173
Doc/library/token-list.inc generated

.github/workflows/jit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
# runner: ubuntu-latest
6868
# compiler: gcc
6969
# tier: 2
70-
# exclude: test_cmd_line test_concurrent_futures test_eintr test_faulthandler test_os test_posix test_signal test_socket test_subprocess test_tools
70+
# exclude: test_cmd_line test_concurrent_futures test_eintr test_faulthandler test_os test_perf_profiler test_posix test_signal test_socket test_subprocess test_tools
7171
- target: x86_64-unknown-linux-gnu/clang
7272
architecture: x86_64
7373
runner: ubuntu-latest

.github/workflows/mypy.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
paths:
1010
- "Tools/clinic/**"
1111
- "Tools/cases_generator/**"
12+
- "Tools/peg_generator/**"
1213
- "Tools/requirements-dev.txt"
1314
- ".github/workflows/mypy.yml"
1415
workflow_dispatch:
@@ -29,7 +30,11 @@ jobs:
2930
mypy:
3031
strategy:
3132
matrix:
32-
target: ["Tools/cases_generator", "Tools/clinic"]
33+
target: [
34+
"Tools/cases_generator",
35+
"Tools/clinic",
36+
"Tools/peg_generator",
37+
]
3338
name: Run mypy on ${{ matrix.target }}
3439
runs-on: ubuntu-latest
3540
timeout-minutes: 10

Doc/c-api/stable.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ way; see :ref:`stable-abi-platform` below).
1818
So, code compiled for Python 3.10.0 will work on 3.10.8 and vice versa,
1919
but will need to be compiled separately for 3.9.x and 3.10.x.
2020

21-
There are two tiers of C API with different stability exepectations:
21+
There are two tiers of C API with different stability expectations:
2222

2323
- :ref:`Unstable API <unstable-c-api>`, may change in minor versions without
2424
a deprecation period. It is marked by the ``PyUnstable`` prefix in names.

Doc/c-api/typeobj.rst

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -528,28 +528,6 @@ type objects) *must* have the :c:member:`~PyVarObject.ob_size` field.
528528
This field is inherited by subtypes.
529529

530530

531-
.. c:member:: PyObject* PyObject._ob_next
532-
PyObject* PyObject._ob_prev
533-
534-
These fields are only present when the macro ``Py_TRACE_REFS`` is defined
535-
(see the :option:`configure --with-trace-refs option <--with-trace-refs>`).
536-
537-
Their initialization to ``NULL`` is taken care of by the
538-
``PyObject_HEAD_INIT`` macro. For :ref:`statically allocated objects
539-
<static-types>`, these fields always remain ``NULL``. For :ref:`dynamically
540-
allocated objects <heap-types>`, these two fields are used to link the
541-
object into a doubly linked list of *all* live objects on the heap.
542-
543-
This could be used for various debugging purposes; currently the only uses
544-
are the :func:`sys.getobjects` function and to print the objects that are
545-
still alive at the end of a run when the environment variable
546-
:envvar:`PYTHONDUMPREFS` is set.
547-
548-
**Inheritance:**
549-
550-
These fields are not inherited by subtypes.
551-
552-
553531
PyVarObject Slots
554532
-----------------
555533

@@ -1728,7 +1706,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
17281706
treated as read-only.
17291707

17301708
Some types may not store their dictionary in this slot.
1731-
Use :c:func:`PyType_GetDict` to retreive the dictionary for an arbitrary
1709+
Use :c:func:`PyType_GetDict` to retrieve the dictionary for an arbitrary
17321710
type.
17331711

17341712
.. versionchanged:: 3.12

Doc/howto/clinic.rst

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ process a single source file, like this:
158158
The CLI supports the following options:
159159

160160
.. program:: ./Tools/clinic/clinic.py [-h] [-f] [-o OUTPUT] [-v] \
161-
[--converters] [--make] [--srcdir SRCDIR] [FILE ...]
161+
[--converters] [--make] [--srcdir SRCDIR] [--limited] [FILE ...]
162162

163163
.. option:: -h, --help
164164

@@ -193,6 +193,11 @@ The CLI supports the following options:
193193
A file to exclude in :option:`--make` mode.
194194
This option can be given multiple times.
195195

196+
.. option:: --limited
197+
198+
Use the :ref:`Limited API <limited-c-api>` to parse arguments in the generated C code.
199+
See :ref:`clinic-howto-limited-capi`.
200+
196201
.. option:: FILE ...
197202

198203
The list of files to process.
@@ -1905,6 +1910,22 @@ blocks embedded in Python files look slightly different. They look like this:
19051910
#/*[python checksum:...]*/
19061911
19071912
1913+
.. _clinic-howto-limited-capi:
1914+
1915+
How to use the Limited C API
1916+
----------------------------
1917+
1918+
If Argument Clinic :term:`input` is located within a C source file
1919+
that contains ``#define Py_LIMITED_API``, Argument Clinic will generate C code
1920+
that uses the :ref:`Limited API <limited-c-api>` to parse arguments. The
1921+
advantage of this is that the generated code will not use private functions.
1922+
However, this *can* result in Argument Clinic generating less efficient code
1923+
in some cases. The extent of the performance penalty will depend
1924+
on the parameters (types, number, etc.).
1925+
1926+
.. versionadded:: 3.13
1927+
1928+
19081929
.. _clinic-howto-override-signature:
19091930

19101931
How to override the generated signature

Doc/howto/enum.rst

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,10 +426,17 @@ enumeration, with the exception of special methods (:meth:`__str__`,
426426
:meth:`__add__`, etc.), descriptors (methods are also descriptors), and
427427
variable names listed in :attr:`_ignore_`.
428428

429-
Note: if your enumeration defines :meth:`__new__` and/or :meth:`__init__` then
429+
Note: if your enumeration defines :meth:`__new__` and/or :meth:`__init__`,
430430
any value(s) given to the enum member will be passed into those methods.
431431
See `Planet`_ for an example.
432432

433+
.. note::
434+
435+
The :meth:`__new__` method, if defined, is used during creation of the Enum
436+
members; it is then replaced by Enum's :meth:`__new__` which is used after
437+
class creation for lookup of existing members. See :ref:`new-vs-init` for
438+
more details.
439+
433440

434441
Restricted Enum subclassing
435442
---------------------------
@@ -895,6 +902,8 @@ Some rules:
895902
:meth:`__str__` method has been reset to their data types'
896903
:meth:`__str__` method.
897904

905+
.. _new-vs-init:
906+
898907
When to use :meth:`__new__` vs. :meth:`__init__`
899908
------------------------------------------------
900909

@@ -927,6 +936,11 @@ want one of them to be the value::
927936
>>> print(Coordinate(3))
928937
Coordinate.VY
929938

939+
.. warning::
940+
941+
*Do not* call ``super().__new__()``, as the lookup-only ``__new__`` is the one
942+
that is found; instead, use the data type directly.
943+
930944

931945
Finer Points
932946
^^^^^^^^^^^^
@@ -1353,6 +1367,13 @@ to handle any extra arguments::
13531367
members; it is then replaced by Enum's :meth:`__new__` which is used after
13541368
class creation for lookup of existing members.
13551369

1370+
.. warning::
1371+
1372+
*Do not* call ``super().__new__()``, as the lookup-only ``__new__`` is the one
1373+
that is found; instead, use the data type directly -- e.g.::
1374+
1375+
obj = int.__new__(cls, value)
1376+
13561377

13571378
OrderedEnum
13581379
^^^^^^^^^^^

Doc/howto/logging-cookbook.rst

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ printed on the console; on the server side, you should see something like:
761761
762762
Note that there are some security issues with pickle in some scenarios. If
763763
these affect you, you can use an alternative serialization scheme by overriding
764-
the :meth:`~handlers.SocketHandler.makePickle` method and implementing your
764+
the :meth:`~SocketHandler.makePickle` method and implementing your
765765
alternative there, as well as adapting the above script to use your alternative
766766
serialization.
767767

@@ -835,6 +835,8 @@ To test these files, do the following in a POSIX environment:
835835
You may need to tweak the configuration files in the unlikely event that the
836836
configured ports clash with something else in your test environment.
837837

838+
.. currentmodule:: logging
839+
838840
.. _context-info:
839841

840842
Adding contextual information to your logging output
@@ -1546,7 +1548,7 @@ Sometimes you want to let a log file grow to a certain size, then open a new
15461548
file and log to that. You may want to keep a certain number of these files, and
15471549
when that many files have been created, rotate the files so that the number of
15481550
files and the size of the files both remain bounded. For this usage pattern, the
1549-
logging package provides a :class:`~handlers.RotatingFileHandler`::
1551+
logging package provides a :class:`RotatingFileHandler`::
15501552

15511553
import glob
15521554
import logging
@@ -1594,6 +1596,8 @@ and each time it reaches the size limit it is renamed with the suffix
15941596
Obviously this example sets the log length much too small as an extreme
15951597
example. You would want to set *maxBytes* to an appropriate value.
15961598

1599+
.. currentmodule:: logging
1600+
15971601
.. _format-styles:
15981602

15991603
Use of alternative formatting styles
@@ -1840,6 +1844,7 @@ However, it should be borne in mind that each link in the chain adds run-time
18401844
overhead to all logging operations, and the technique should only be used when
18411845
the use of a :class:`Filter` does not provide the desired result.
18421846

1847+
.. currentmodule:: logging.handlers
18431848

18441849
.. _zeromq-handlers:
18451850

@@ -1917,6 +1922,8 @@ of queues, for example a ZeroMQ 'subscribe' socket. Here's an example::
19171922
:ref:`A more advanced logging tutorial <logging-advanced-tutorial>`
19181923

19191924

1925+
.. currentmodule:: logging
1926+
19201927
An example dictionary-based configuration
19211928
-----------------------------------------
19221929

@@ -3918,8 +3925,8 @@ that in other languages such as Java and C#, loggers are often static class
39183925
attributes. However, this pattern doesn't make sense in Python, where the
39193926
module (and not the class) is the unit of software decomposition.
39203927

3921-
Adding handlers other than :class:`NullHandler` to a logger in a library
3922-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3928+
Adding handlers other than :class:`~logging.NullHandler` to a logger in a library
3929+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
39233930

39243931
Configuring logging by adding handlers, formatters and filters is the
39253932
responsibility of the application developer, not the library developer. If you

Doc/library/ast.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ Expressions
585585
:class:`Name` or :class:`Attribute` object. Of the arguments:
586586

587587
* ``args`` holds a list of the arguments passed by position.
588-
* ``keywords`` holds a list of :class:`keyword` objects representing
588+
* ``keywords`` holds a list of :class:`.keyword` objects representing
589589
arguments passed by keyword.
590590

591591
When creating a ``Call`` node, ``args`` and ``keywords`` are required, but
@@ -2024,7 +2024,7 @@ Function and class definitions
20242024

20252025
* ``name`` is a raw string for the class name
20262026
* ``bases`` is a list of nodes for explicitly specified base classes.
2027-
* ``keywords`` is a list of :class:`keyword` nodes, principally for 'metaclass'.
2027+
* ``keywords`` is a list of :class:`.keyword` nodes, principally for 'metaclass'.
20282028
Other keywords will be passed to the metaclass, as per `PEP-3115
20292029
<https://peps.python.org/pep-3115/>`_.
20302030
* ``body`` is a list of nodes representing the code within the class

Doc/library/calendar.rst

Lines changed: 49 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -28,58 +28,6 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is
2828
2 BC, and so on.
2929

3030

31-
.. class:: Day
32-
33-
Enumeration defining the days of the week as integer constants, from 0 to 6.
34-
35-
.. attribute:: MONDAY
36-
37-
.. attribute:: TUESDAY
38-
39-
.. attribute:: WEDNESDAY
40-
41-
.. attribute:: THURSDAY
42-
43-
.. attribute:: FRIDAY
44-
45-
.. attribute:: SATURDAY
46-
47-
.. attribute:: SUNDAY
48-
49-
.. versionadded:: 3.12
50-
51-
52-
.. class:: Month
53-
54-
Enumeration defining months of the year as integer constants, from 1 to 12.
55-
56-
.. attribute:: JANUARY
57-
58-
.. attribute:: FEBRUARY
59-
60-
.. attribute:: MARCH
61-
62-
.. attribute:: APRIL
63-
64-
.. attribute:: MAY
65-
66-
.. attribute:: JUNE
67-
68-
.. attribute:: JULY
69-
70-
.. attribute:: AUGUST
71-
72-
.. attribute:: SEPTEMBER
73-
74-
.. attribute:: OCTOBER
75-
76-
.. attribute:: NOVEMBER
77-
78-
.. attribute:: DECEMBER
79-
80-
.. versionadded:: 3.12
81-
82-
8331
.. class:: Calendar(firstweekday=0)
8432

8533
Creates a :class:`Calendar` object. *firstweekday* is an integer specifying the
@@ -446,6 +394,29 @@ The :mod:`calendar` module exports the following data attributes:
446394
An array that represents the abbreviated days of the week in the current locale.
447395

448396

397+
.. data:: MONDAY
398+
TUESDAY
399+
WEDNESDAY
400+
THURSDAY
401+
FRIDAY
402+
SATURDAY
403+
SUNDAY
404+
405+
Aliases for the days of the week,
406+
where ``MONDAY`` is ``0`` and ``SUNDAY`` is ``6``.
407+
408+
.. versionadded:: 3.12
409+
410+
411+
.. class:: Day
412+
413+
Enumeration defining days of the week as integer constants.
414+
The members of this enumeration are exported to the module scope as
415+
:data:`MONDAY` through :data:`SUNDAY`.
416+
417+
.. versionadded:: 3.12
418+
419+
449420
.. data:: month_name
450421

451422
An array that represents the months of the year in the current locale. This
@@ -459,15 +430,33 @@ The :mod:`calendar` module exports the following data attributes:
459430
locale. This follows normal convention of January being month number 1, so it
460431
has a length of 13 and ``month_abbr[0]`` is the empty string.
461432

462-
.. data:: MONDAY
463-
TUESDAY
464-
WEDNESDAY
465-
THURSDAY
466-
FRIDAY
467-
SATURDAY
468-
SUNDAY
469433

470-
Aliases for day numbers, where ``MONDAY`` is ``0`` and ``SUNDAY`` is ``6``.
434+
.. data:: JANUARY
435+
FEBRUARY
436+
MARCH
437+
APRIL
438+
MAY
439+
JUNE
440+
JULY
441+
AUGUST
442+
SEPTEMBER
443+
OCTOBER
444+
NOVEMBER
445+
DECEMBER
446+
447+
Aliases for the months of the year,
448+
where ``JANUARY`` is ``1`` and ``DECEMBER`` is ``12``.
449+
450+
.. versionadded:: 3.12
451+
452+
453+
.. class:: Month
454+
455+
Enumeration defining months of the year as integer constants.
456+
The members of this enumeration are exported to the module scope as
457+
:data:`JANUARY` through :data:`DECEMBER`.
458+
459+
.. versionadded:: 3.12
471460

472461

473462
The :mod:`calendar` module defines the following exceptions:

0 commit comments

Comments
 (0)