Skip to content

Commit 7fe556e

Browse files
authored
Merge branch 'main' into fstring-grammar-rebased-after-sprint
2 parents 9a6e7e4 + 52f96d3 commit 7fe556e

File tree

156 files changed

+9796
-4262
lines changed

Some content is hidden

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

156 files changed

+9796
-4262
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# https://git-scm.com/docs/gitignore#_pattern_format
66

77
# GitHub
8-
.github/** @ezio-melotti
8+
.github/** @ezio-melotti @hugovk
99

1010
# Build system
1111
configure* @erlend-aasland @corona10
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Check labels
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened, labeled, unlabeled, synchronize]
6+
7+
jobs:
8+
label:
9+
name: DO-NOT-MERGE
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: mheap/github-action-required-labels@v4
14+
with:
15+
mode: exactly
16+
count: 0
17+
labels: "DO-NOT-MERGE"

.github/workflows/stale.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515

1616
steps:
1717
- name: "Check PRs"
18-
uses: actions/stale@v7
18+
uses: actions/stale@v8
1919
with:
2020
repo-token: ${{ secrets.GITHUB_TOKEN }}
2121
stale-pr-message: 'This PR is stale because it has been open for 30 days with no activity.'

Doc/conf.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,10 @@
6868
# Minimum version of sphinx required
6969
needs_sphinx = '3.2'
7070

71+
# Ignore any .rst files in the includes/ directory;
72+
# they're embedded in pages but not rendered individually.
7173
# Ignore any .rst files in the venv/ directory.
72-
exclude_patterns = ['venv/*', 'README.rst']
74+
exclude_patterns = ['includes/*.rst', 'venv/*', 'README.rst']
7375
venvdir = os.getenv('VENVDIR')
7476
if venvdir is not None:
7577
exclude_patterns.append(venvdir + '/*')

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/glossary.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ Glossary
214214
A callable is an object that can be called, possibly with a set
215215
of arguments (see :term:`argument`), with the following syntax::
216216

217-
callable(argument1, argument2, ...)
217+
callable(argument1, argument2, argumentN)
218218

219219
A :term:`function`, and by extension a :term:`method`, is a callable.
220220
An instance of a class that implements the :meth:`~object.__call__`

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ regular, non-variadic, function arguments:
390390
391391
libc.printf.argtypes = [ctypes.c_char_p]
392392
393-
Because specifying the attribute does inhibit portability it is advised to always
393+
Because specifying the attribute does not inhibit portability it is advised to always
394394
specify ``argtypes`` for all variadic functions.
395395

396396

Doc/library/datetime.rst

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -737,18 +737,16 @@ Instance methods:
737737
.. method:: date.strftime(format)
738738

739739
Return a string representing the date, controlled by an explicit format string.
740-
Format codes referring to hours, minutes or seconds will see 0 values. For a
741-
complete list of formatting directives, see
742-
:ref:`strftime-strptime-behavior`.
740+
Format codes referring to hours, minutes or seconds will see 0 values.
741+
See also :ref:`strftime-strptime-behavior` and :meth:`date.isoformat`.
743742

744743

745744
.. method:: date.__format__(format)
746745

747746
Same as :meth:`.date.strftime`. This makes it possible to specify a format
748747
string for a :class:`.date` object in :ref:`formatted string
749-
literals <f-strings>` and when using :meth:`str.format`. For a
750-
complete list of formatting directives, see
751-
:ref:`strftime-strptime-behavior`.
748+
literals <f-strings>` and when using :meth:`str.format`.
749+
See also :ref:`strftime-strptime-behavior` and :meth:`date.isoformat`.
752750

753751
Examples of Usage: :class:`date`
754752
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -1051,8 +1049,8 @@ Other constructors, all class methods:
10511049

10521050
:exc:`ValueError` is raised if the date_string and format
10531051
can't be parsed by :func:`time.strptime` or if it returns a value which isn't a
1054-
time tuple. For a complete list of formatting directives, see
1055-
:ref:`strftime-strptime-behavior`.
1052+
time tuple. See also :ref:`strftime-strptime-behavior` and
1053+
:meth:`datetime.fromisoformat`.
10561054

10571055

10581056

@@ -1510,20 +1508,21 @@ Instance methods:
15101508
(which :func:`time.ctime` invokes, but which
15111509
:meth:`datetime.ctime` does not invoke) conforms to the C standard.
15121510

1511+
15131512
.. method:: datetime.strftime(format)
15141513

1515-
Return a string representing the date and time, controlled by an explicit format
1516-
string. For a complete list of formatting directives, see
1517-
:ref:`strftime-strptime-behavior`.
1514+
Return a string representing the date and time,
1515+
controlled by an explicit format string.
1516+
See also :ref:`strftime-strptime-behavior` and :meth:`datetime.isoformat`.
15181517

15191518

15201519
.. method:: datetime.__format__(format)
15211520

15221521
Same as :meth:`.datetime.strftime`. This makes it possible to specify a format
15231522
string for a :class:`.datetime` object in :ref:`formatted string
1524-
literals <f-strings>` and when using :meth:`str.format`. For a
1525-
complete list of formatting directives, see
1526-
:ref:`strftime-strptime-behavior`.
1523+
literals <f-strings>` and when using :meth:`str.format`.
1524+
See also :ref:`strftime-strptime-behavior` and :meth:`datetime.isoformat`.
1525+
15271526

15281527
Examples of Usage: :class:`.datetime`
15291528
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -1868,17 +1867,15 @@ Instance methods:
18681867
.. method:: time.strftime(format)
18691868

18701869
Return a string representing the time, controlled by an explicit format
1871-
string. For a complete list of formatting directives, see
1872-
:ref:`strftime-strptime-behavior`.
1870+
string. See also :ref:`strftime-strptime-behavior` and :meth:`time.isoformat`.
18731871

18741872

18751873
.. method:: time.__format__(format)
18761874

1877-
Same as :meth:`.time.strftime`. This makes it possible to specify a format string
1878-
for a :class:`.time` object in :ref:`formatted string
1879-
literals <f-strings>` and when using :meth:`str.format`. For a
1880-
complete list of formatting directives, see
1881-
:ref:`strftime-strptime-behavior`.
1875+
Same as :meth:`.time.strftime`. This makes it possible to specify
1876+
a format string for a :class:`.time` object in :ref:`formatted string
1877+
literals <f-strings>` and when using :meth:`str.format`.
1878+
See also :ref:`strftime-strptime-behavior` and :meth:`time.isoformat`.
18821879

18831880

18841881
.. method:: time.utcoffset()
@@ -2320,6 +2317,14 @@ versus :meth:`strptime`:
23202317
:meth:`strftime` and :meth:`strptime` Format Codes
23212318
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
23222319

2320+
These methods accept format codes that can be used to parse and format dates::
2321+
2322+
>>> datetime.strptime('31/01/22 23:59:59.999999',
2323+
... '%d/%m/%y %H:%M:%S.%f')
2324+
datetime.datetime(2022, 1, 31, 23, 59, 59, 999999)
2325+
>>> _.strftime('%a %d %b %Y, %I:%M%p')
2326+
'Mon 31 Jan 2022, 11:59PM'
2327+
23232328
The following is a list of all the format codes that the 1989 C standard
23242329
requires, and these work on all platforms with a standard C implementation.
23252330

Doc/library/functions.rst

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

16821682
class C:
16831683
@staticmethod
1684-
def f(arg1, arg2, ...): ...
1684+
def f(arg1, arg2, argN): ...
16851685

16861686
The ``@staticmethod`` form is a function :term:`decorator` -- see
16871687
:ref:`function` for details.

Doc/library/gc.rst

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,17 @@ The :mod:`gc` module provides the following functions:
206206

207207
.. function:: freeze()
208208

209-
Freeze all the objects tracked by gc - move them to a permanent generation
210-
and ignore all the future collections. This can be used before a POSIX
211-
fork() call to make the gc copy-on-write friendly or to speed up collection.
212-
Also collection before a POSIX fork() call may free pages for future
213-
allocation which can cause copy-on-write too so it's advised to disable gc
214-
in parent process and freeze before fork and enable gc in child process.
209+
Freeze all the objects tracked by the garbage collector; move them to a
210+
permanent generation and ignore them in all the future collections.
211+
212+
If a process will ``fork()`` without ``exec()``, avoiding unnecessary
213+
copy-on-write in child processes will maximize memory sharing and reduce
214+
overall memory usage. This requires both avoiding creation of freed "holes"
215+
in memory pages in the parent process and ensuring that GC collections in
216+
child processes won't touch the ``gc_refs`` counter of long-lived objects
217+
originating in the parent process. To accomplish both, call ``gc.disable()``
218+
early in the parent process, ``gc.freeze()`` right before ``fork()``, and
219+
``gc.enable()`` early in child processes.
215220

216221
.. versionadded:: 3.7
217222

0 commit comments

Comments
 (0)