Skip to content

Commit 86aee3c

Browse files
committed
Merge branch 'main' into math-cov
2 parents dc85378 + 26c6598 commit 86aee3c

File tree

206 files changed

+4519
-2763
lines changed

Some content is hidden

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

206 files changed

+4519
-2763
lines changed

.devcontainer/devcontainer.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,16 @@
3737
// "ms-python.python"
3838
],
3939
"settings": {
40+
"C_Cpp.default.compilerPath": "/usr/bin/clang",
4041
"C_Cpp.default.cStandard": "c11",
4142
"C_Cpp.default.defines": [
43+
"CONFIG_64",
4244
"Py_BUILD_CORE"
4345
],
46+
"C_Cpp.default.includePath": [
47+
"${workspaceFolder}/*",
48+
"${workspaceFolder}/Include/**"
49+
],
4450
// https://github.com/microsoft/vscode-cpptools/issues/10732
4551
"C_Cpp.errorSquiggles": "disabled",
4652
"editor.insertSpaces": true,

Doc/extending/newtypes_tutorial.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ standard Python floats::
8888
The second bit is the definition of the type object. ::
8989

9090
static PyTypeObject CustomType = {
91-
PyVarObject_HEAD_INIT(NULL, 0)
91+
.ob_base = PyVarObject_HEAD_INIT(NULL, 0)
9292
.tp_name = "custom.Custom",
9393
.tp_doc = PyDoc_STR("Custom objects"),
9494
.tp_basicsize = sizeof(CustomObject),
@@ -109,7 +109,7 @@ common practice to not specify them explicitly unless you need them.
109109

110110
We're going to pick it apart, one field at a time::
111111

112-
PyVarObject_HEAD_INIT(NULL, 0)
112+
.ob_base = PyVarObject_HEAD_INIT(NULL, 0)
113113

114114
This line is mandatory boilerplate to initialize the ``ob_base``
115115
field mentioned above. ::

Doc/howto/enum.rst

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ The values are chosen by :func:`_generate_next_value_`, which can be
284284
overridden::
285285

286286
>>> class AutoName(Enum):
287+
... @staticmethod
287288
... def _generate_next_value_(name, start, count, last_values):
288289
... return name
289290
...
@@ -372,6 +373,11 @@ below)::
372373
>>> Color.BLUE == 2
373374
False
374375

376+
.. warning::
377+
378+
It is possible to reload modules -- if a reloaded module contains
379+
enums, they will be recreated, and the new members may not
380+
compare identical/equal to the original members.
375381

376382
Allowed members and attributes of enumerations
377383
----------------------------------------------
@@ -982,12 +988,11 @@ but remain normal attributes.
982988
""""""""""""""""""""
983989

984990
Enum members are instances of their enum class, and are normally accessed as
985-
``EnumClass.member``. In Python versions starting with ``3.5`` you could access
986-
members from other members -- this practice is discouraged, is deprecated
987-
in ``3.12``, and will be removed in ``3.14``.
991+
``EnumClass.member``. In certain situations, such as writing custom enum
992+
behavior, being able to access one member directly from another is useful,
993+
and is supported.
988994

989995
.. versionchanged:: 3.5
990-
.. versionchanged:: 3.12
991996

992997

993998
Creating members that are mixed with other data types

Doc/includes/custom.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ typedef struct {
77
} CustomObject;
88

99
static PyTypeObject CustomType = {
10-
PyVarObject_HEAD_INIT(NULL, 0)
10+
.ob_base = PyVarObject_HEAD_INIT(NULL, 0)
1111
.tp_name = "custom.Custom",
1212
.tp_doc = PyDoc_STR("Custom objects"),
1313
.tp_basicsize = sizeof(CustomObject),
@@ -17,7 +17,7 @@ static PyTypeObject CustomType = {
1717
};
1818

1919
static PyModuleDef custommodule = {
20-
PyModuleDef_HEAD_INIT,
20+
.m_base = PyModuleDef_HEAD_INIT,
2121
.m_name = "custom",
2222
.m_doc = "Example module that creates an extension type.",
2323
.m_size = -1,

Doc/includes/custom2.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ static PyMethodDef Custom_methods[] = {
9090
};
9191

9292
static PyTypeObject CustomType = {
93-
PyVarObject_HEAD_INIT(NULL, 0)
93+
.ob_base = PyVarObject_HEAD_INIT(NULL, 0)
9494
.tp_name = "custom2.Custom",
9595
.tp_doc = PyDoc_STR("Custom objects"),
9696
.tp_basicsize = sizeof(CustomObject),
@@ -104,7 +104,7 @@ static PyTypeObject CustomType = {
104104
};
105105

106106
static PyModuleDef custommodule = {
107-
PyModuleDef_HEAD_INIT,
107+
.m_base =PyModuleDef_HEAD_INIT,
108108
.m_name = "custom2",
109109
.m_doc = "Example module that creates an extension type.",
110110
.m_size = -1,

Doc/includes/custom3.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ static PyMethodDef Custom_methods[] = {
130130
};
131131

132132
static PyTypeObject CustomType = {
133-
PyVarObject_HEAD_INIT(NULL, 0)
133+
.ob_base = PyVarObject_HEAD_INIT(NULL, 0)
134134
.tp_name = "custom3.Custom",
135135
.tp_doc = PyDoc_STR("Custom objects"),
136136
.tp_basicsize = sizeof(CustomObject),
@@ -145,7 +145,7 @@ static PyTypeObject CustomType = {
145145
};
146146

147147
static PyModuleDef custommodule = {
148-
PyModuleDef_HEAD_INIT,
148+
.m_base = PyModuleDef_HEAD_INIT,
149149
.m_name = "custom3",
150150
.m_doc = "Example module that creates an extension type.",
151151
.m_size = -1,

Doc/includes/custom4.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ static PyMethodDef Custom_methods[] = {
146146
};
147147

148148
static PyTypeObject CustomType = {
149-
PyVarObject_HEAD_INIT(NULL, 0)
149+
.ob_base = PyVarObject_HEAD_INIT(NULL, 0)
150150
.tp_name = "custom4.Custom",
151151
.tp_doc = PyDoc_STR("Custom objects"),
152152
.tp_basicsize = sizeof(CustomObject),
@@ -163,7 +163,7 @@ static PyTypeObject CustomType = {
163163
};
164164

165165
static PyModuleDef custommodule = {
166-
PyModuleDef_HEAD_INIT,
166+
.m_base = PyModuleDef_HEAD_INIT,
167167
.m_name = "custom4",
168168
.m_doc = "Example module that creates an extension type.",
169169
.m_size = -1,

Doc/library/bisect.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,10 @@ records in a table::
210210
>>> Movie = namedtuple('Movie', ('name', 'released', 'director'))
211211

212212
>>> movies = [
213-
... Movie('Jaws', 1975, 'Speilberg'),
213+
... Movie('Jaws', 1975, 'Spielberg'),
214214
... Movie('Titanic', 1997, 'Cameron'),
215215
... Movie('The Birds', 1963, 'Hitchcock'),
216-
... Movie('Aliens', 1986, 'Scott')
216+
... Movie('Aliens', 1986, 'Cameron')
217217
... ]
218218

219219
>>> # Find the first movie released after 1960
@@ -228,8 +228,8 @@ records in a table::
228228
>>> pprint(movies)
229229
[Movie(name='The Birds', released=1963, director='Hitchcock'),
230230
Movie(name='Love Story', released=1970, director='Hiller'),
231-
Movie(name='Jaws', released=1975, director='Speilberg'),
232-
Movie(name='Aliens', released=1986, director='Scott'),
231+
Movie(name='Jaws', released=1975, director='Spielberg'),
232+
Movie(name='Aliens', released=1986, director='Cameron'),
233233
Movie(name='Titanic', released=1997, director='Cameron')]
234234

235235
If the key function is expensive, it is possible to avoid repeated function

Doc/library/dis.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ the following command can be used to display the disassembly of
5959
3 2 LOAD_GLOBAL 1 (NULL + len)
6060
12 LOAD_FAST 0 (alist)
6161
14 CALL 1
62-
24 RETURN_VALUE
62+
22 RETURN_VALUE
6363

6464
(The "2" is a line number).
6565

Doc/library/enum.rst

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,8 @@ Module Contents
141141
:func:`global_enum`
142142

143143
Modify the :class:`str() <str>` and :func:`repr` of an enum
144-
to show its members as belonging to the module instead of its class.
145-
Should only be used if the enum members will be exported to the
146-
module global namespace.
144+
to show its members as belonging to the module instead of its class,
145+
and export the enum members to the global namespace.
147146

148147
:func:`show_flag_values`
149148

@@ -170,6 +169,27 @@ Data Types
170169
final *enum*, as well as creating the enum members, properly handling
171170
duplicates, providing iteration over the enum class, etc.
172171

172+
.. method:: EnumType.__call__(cls, value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
173+
174+
This method is called in two different ways:
175+
176+
* to look up an existing member:
177+
178+
:cls: The enum class being called.
179+
:value: The value to lookup.
180+
181+
* to use the ``cls`` enum to create a new enum (only if the existing enum
182+
does not have any members):
183+
184+
:cls: The enum class being called.
185+
:value: The name of the new Enum to create.
186+
:names: The names/values of the members for the new Enum.
187+
:module: The name of the module the new Enum is created in.
188+
:qualname: The actual location in the module where this Enum can be found.
189+
:type: A mix-in type for the new Enum.
190+
:start: The first integer value for the Enum (used by :class:`auto`).
191+
:boundary: How to handle out-of-range values from bit operations (:class:`Flag` only).
192+
173193
.. method:: EnumType.__contains__(cls, member)
174194

175195
Returns ``True`` if member belongs to the ``cls``::
@@ -255,26 +275,6 @@ Data Types
255275
names will also be removed from the completed enumeration. See
256276
:ref:`TimePeriod <enum-time-period>` for an example.
257277

258-
.. method:: Enum.__call__(cls, value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
259-
260-
This method is called in two different ways:
261-
262-
* to look up an existing member:
263-
264-
:cls: The enum class being called.
265-
:value: The value to lookup.
266-
267-
* to use the ``cls`` enum to create a new enum:
268-
269-
:cls: The enum class being called.
270-
:value: The name of the new Enum to create.
271-
:names: The names/values of the members for the new Enum.
272-
:module: The name of the module the new Enum is created in.
273-
:qualname: The actual location in the module where this Enum can be found.
274-
:type: A mix-in type for the new Enum.
275-
:start: The first integer value for the Enum (used by :class:`auto`).
276-
:boundary: How to handle out-of-range values from bit operations (:class:`Flag` only).
277-
278278
.. method:: Enum.__dir__(self)
279279

280280
Returns ``['__class__', '__doc__', '__module__', 'name', 'value']`` and
@@ -728,7 +728,6 @@ Data Types
728728
.. attribute:: EJECT
729729

730730
Out-of-range values lose their *Flag* membership and revert to :class:`int`.
731-
This is the default for :class:`IntFlag`::
732731

733732
>>> from enum import Flag, EJECT, auto
734733
>>> class EjectFlag(Flag, boundary=EJECT):
@@ -741,8 +740,8 @@ Data Types
741740

742741
.. attribute:: KEEP
743742

744-
Out-of-range values are kept, and the *Flag* membership is kept. This is
745-
used for some stdlib flags::
743+
Out-of-range values are kept, and the *Flag* membership is kept.
744+
This is the default for :class:`IntFlag`::
746745

747746
>>> from enum import Flag, KEEP, auto
748747
>>> class KeepFlag(Flag, boundary=KEEP):

0 commit comments

Comments
 (0)