Skip to content

Commit ebebdb7

Browse files
author
Erlend E. Aasland
committed
Merge branch 'main' into sqlite-optimise-resets
2 parents 41410e0 + a677971 commit ebebdb7

File tree

200 files changed

+2518
-9724
lines changed

Some content is hidden

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

200 files changed

+2518
-9724
lines changed

.gitignore

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,11 @@ Tools/msi/obj
121121
Tools/ssl/amd64
122122
Tools/ssl/win32
123123

124-
# TODO: Once we auto-regen frozem modules for Windows builds
125-
# we can drop the .h files from the repo and ignore them here.
126-
# At that point we will rely the frozen manifest file to identify
127-
# changed generated files. We'll drop the entry for it then.
128-
# See: Tools/scripts/freeze_modules.py.
129-
#Python/frozen_modules/*.h
124+
# The frozen modules are always generated by the build so we don't
125+
# keep them in the repo. Also see Tools/scripts/freeze_modules.py.
126+
Python/frozen_modules/*.h
127+
# The manifest can be generated at any time with "make regen-frozen".
128+
Python/frozen_modules/MANIFEST
130129

131130
# Two-trick pony for OSX and other case insensitive file systems:
132131
# Ignore ./python binary on Unix but still look into ./Python/ directory.

Doc/c-api/intro.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,28 @@ complete listing.
111111

112112
.. versionadded:: 3.3
113113

114+
.. c:macro:: Py_ALWAYS_INLINE
115+
116+
Ask the compiler to always inline a static inline function. The compiler can
117+
ignore it and decides to not inline the function.
118+
119+
It can be used to inline performance critical static inline functions when
120+
building Python in debug mode with function inlining disabled. For example,
121+
MSC disables function inlining when building in debug mode.
122+
123+
Marking blindly a static inline function with Py_ALWAYS_INLINE can result in
124+
worse performances (due to increased code size for example). The compiler is
125+
usually smarter than the developer for the cost/benefit analysis.
126+
127+
If Python is :ref:`built in debug mode <debug-build>` (if the ``Py_DEBUG``
128+
macro is defined), the :c:macro:`Py_ALWAYS_INLINE` macro does nothing.
129+
130+
It must be specified before the function return type. Usage::
131+
132+
static inline Py_ALWAYS_INLINE int random(void) { return 4; }
133+
134+
.. versionadded:: 3.11
135+
114136
.. c:macro:: Py_CHARMASK(c)
115137
116138
Argument must be a character or an integer in the range [-128, 127] or [0,

Doc/c-api/type.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ The following functions and structs are used to create
187187
The *module* argument can be used to record the module in which the new
188188
class is defined. It must be a module object or ``NULL``.
189189
If not ``NULL``, the module is associated with the new type and can later be
190-
retreived with :c:func:`PyType_GetModule`.
190+
retrieved with :c:func:`PyType_GetModule`.
191191
The associated module is not inherited by subclasses; it must be specified
192192
for each class individually.
193193

Doc/c-api/typehints.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ two types exist -- :ref:`GenericAlias <types-genericalias>` and
3131
static PyMethodDef my_obj_methods[] = {
3232
// Other methods.
3333
...
34-
{"__class_getitem__", (PyCFunction)Py_GenericAlias, METH_O|METH_CLASS, "See PEP 585"}
34+
{"__class_getitem__", Py_GenericAlias, METH_O|METH_CLASS, "See PEP 585"}
3535
...
3636
}
3737

Doc/c-api/typeobj.rst

Lines changed: 132 additions & 132 deletions
Large diffs are not rendered by default.

Doc/library/ast.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1917,6 +1917,19 @@ and classes for traversing abstract syntax trees:
19171917
``await`` as variable names. The lowest supported version is
19181918
``(3, 4)``; the highest is ``sys.version_info[0:2]``.
19191919

1920+
If source contains a null character ('\0'), :exc:`ValueError` is raised.
1921+
1922+
.. warning::
1923+
Note that succesfully parsing souce code into an AST object doesn't
1924+
guarantee that the source code provided is valid Python code that can
1925+
be executed as the compilation step can raise further :exc:`SyntaxError`
1926+
exceptions. For instance, the source ``return 42`` generates a valid
1927+
AST node for a return statement, but it cannot be compiled alone (it needs
1928+
to be inside a function node).
1929+
1930+
In particular, :func:`ast.parse` won't do any scoping checks, which the
1931+
compilation step does.
1932+
19201933
.. warning::
19211934
It is possible to crash the Python interpreter with a
19221935
sufficiently large/complex string due to stack depth limitations

Doc/library/calendar.rst

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,16 +279,13 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is
279279

280280
This subclass of :class:`TextCalendar` can be passed a locale name in the
281281
constructor and will return month and weekday names in the specified locale.
282-
If this locale includes an encoding all strings containing month and weekday
283-
names will be returned as unicode.
284282

285283

286284
.. class:: LocaleHTMLCalendar(firstweekday=0, locale=None)
287285

288286
This subclass of :class:`HTMLCalendar` can be passed a locale name in the
289287
constructor and will return month and weekday names in the specified
290-
locale. If this locale includes an encoding all strings containing month and
291-
weekday names will be returned as unicode.
288+
locale.
292289

293290
.. note::
294291

Doc/library/configparser.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,8 @@ A configuration file consists of sections, each led by a ``[section]`` header,
261261
followed by key/value entries separated by a specific string (``=`` or ``:`` by
262262
default [1]_). By default, section names are case sensitive but keys are not
263263
[1]_. Leading and trailing whitespace is removed from keys and values.
264-
Values can be omitted, in which case the key/value delimiter may also be left
264+
Values can be omitted if the parser is configured to allow it [1]_,
265+
in which case the key/value delimiter may also be left
265266
out. Values can also span multiple lines, as long as they are indented deeper
266267
than the first line of the value. Depending on the parser's mode, blank lines
267268
may be treated as parts of multiline values or ignored.

Doc/library/itertools.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -821,14 +821,14 @@ which incur interpreter overhead.
821821
822822
def triplewise(iterable):
823823
"Return overlapping triplets from an iterable"
824-
# pairwise('ABCDEFG') -> ABC BCD CDE DEF EFG
824+
# triplewise('ABCDEFG') -> ABC BCD CDE DEF EFG
825825
for (a, _), (b, c) in pairwise(pairwise(iterable)):
826826
yield a, b, c
827827

828828
def sliding_window(iterable, n):
829829
# sliding_window('ABCDEFG', 4) -> ABCD BCDE CDEF DEFG
830830
it = iter(iterable)
831-
window = deque(islice(it, n), maxlen=n)
831+
window = collections.deque(islice(it, n), maxlen=n)
832832
if len(window) == n:
833833
yield tuple(window)
834834
for x in it:

Doc/library/multiprocessing.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,8 @@ Miscellaneous
951951
use. The number of usable CPUs can be obtained with
952952
``len(os.sched_getaffinity(0))``
953953

954-
May raise :exc:`NotImplementedError`.
954+
When the number of CPUs cannot be determined a :exc:`NotImplementedError`
955+
is raised.
955956

956957
.. seealso::
957958
:func:`os.cpu_count`

Doc/library/sqlite3.rst

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -460,14 +460,22 @@ Connection Objects
460460
Registers *trace_callback* to be called for each SQL statement that is
461461
actually executed by the SQLite backend.
462462

463-
The only argument passed to the callback is the statement (as string) that
464-
is being executed. The return value of the callback is ignored. Note that
465-
the backend does not only run statements passed to the :meth:`Cursor.execute`
466-
methods. Other sources include the transaction management of the Python
467-
module and the execution of triggers defined in the current database.
463+
The only argument passed to the callback is the statement (as
464+
:class:`str`) that is being executed. The return value of the callback is
465+
ignored. Note that the backend does not only run statements passed to the
466+
:meth:`Cursor.execute` methods. Other sources include the
467+
:ref:`transaction management <sqlite3-controlling-transactions>` of the
468+
sqlite3 module and the execution of triggers defined in the current
469+
database.
468470

469471
Passing :const:`None` as *trace_callback* will disable the trace callback.
470472

473+
.. note::
474+
Exceptions raised in the trace callback are not propagated. As a
475+
development and debugging aid, use
476+
:meth:`~sqlite3.enable_callback_tracebacks` to enable printing
477+
tracebacks from exceptions raised in the trace callback.
478+
471479
.. versionadded:: 3.3
472480

473481

Doc/library/stdtypes.rst

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ class`. In addition, it provides a few more methods:
499499

500500
.. versionadded:: 3.10
501501

502-
.. method:: int.to_bytes(length, byteorder, *, signed=False)
502+
.. method:: int.to_bytes(length=1, byteorder='big', *, signed=False)
503503

504504
Return an array of bytes representing an integer.
505505

@@ -513,25 +513,31 @@ class`. In addition, it provides a few more methods:
513513
>>> x.to_bytes((x.bit_length() + 7) // 8, byteorder='little')
514514
b'\xe8\x03'
515515

516-
The integer is represented using *length* bytes. An :exc:`OverflowError`
517-
is raised if the integer is not representable with the given number of
518-
bytes.
516+
The integer is represented using *length* bytes, and defaults to 1. An
517+
:exc:`OverflowError` is raised if the integer is not representable with
518+
the given number of bytes.
519519

520520
The *byteorder* argument determines the byte order used to represent the
521-
integer. If *byteorder* is ``"big"``, the most significant byte is at the
522-
beginning of the byte array. If *byteorder* is ``"little"``, the most
523-
significant byte is at the end of the byte array. To request the native
524-
byte order of the host system, use :data:`sys.byteorder` as the byte order
525-
value.
521+
integer, and defaults to ``"big"``. If *byteorder* is
522+
``"big"``, the most significant byte is at the beginning of the byte
523+
array. If *byteorder* is ``"little"``, the most significant byte is at
524+
the end of the byte array.
526525

527526
The *signed* argument determines whether two's complement is used to
528527
represent the integer. If *signed* is ``False`` and a negative integer is
529528
given, an :exc:`OverflowError` is raised. The default value for *signed*
530529
is ``False``.
531530

531+
The default values can be used to conveniently turn an integer into a
532+
single byte object. However, when using the default arguments, don't try
533+
to convert a value greater than 255 or you'll get an :exc:`OverflowError`::
534+
535+
>>> (65).to_bytes()
536+
b'A'
537+
532538
Equivalent to::
533539

534-
def to_bytes(n, length, byteorder, signed=False):
540+
def to_bytes(n, length=1, byteorder='big', signed=False):
535541
if byteorder == 'little':
536542
order = range(length)
537543
elif byteorder == 'big':
@@ -542,8 +548,10 @@ class`. In addition, it provides a few more methods:
542548
return bytes((n >> i*8) & 0xff for i in order)
543549

544550
.. versionadded:: 3.2
551+
.. versionchanged:: 3.11
552+
Added default argument values for ``length`` and ``byteorder``.
545553

546-
.. classmethod:: int.from_bytes(bytes, byteorder, *, signed=False)
554+
.. classmethod:: int.from_bytes(bytes, byteorder='big', *, signed=False)
547555

548556
Return the integer represented by the given array of bytes.
549557

@@ -562,18 +570,18 @@ class`. In addition, it provides a few more methods:
562570
iterable producing bytes.
563571

564572
The *byteorder* argument determines the byte order used to represent the
565-
integer. If *byteorder* is ``"big"``, the most significant byte is at the
566-
beginning of the byte array. If *byteorder* is ``"little"``, the most
567-
significant byte is at the end of the byte array. To request the native
568-
byte order of the host system, use :data:`sys.byteorder` as the byte order
569-
value.
573+
integer, and defaults to ``"big"``. If *byteorder* is
574+
``"big"``, the most significant byte is at the beginning of the byte
575+
array. If *byteorder* is ``"little"``, the most significant byte is at
576+
the end of the byte array. To request the native byte order of the host
577+
system, use :data:`sys.byteorder` as the byte order value.
570578

571579
The *signed* argument indicates whether two's complement is used to
572580
represent the integer.
573581

574582
Equivalent to::
575583

576-
def from_bytes(bytes, byteorder, signed=False):
584+
def from_bytes(bytes, byteorder='big', signed=False):
577585
if byteorder == 'little':
578586
little_ordered = list(bytes)
579587
elif byteorder == 'big':
@@ -588,6 +596,8 @@ class`. In addition, it provides a few more methods:
588596
return n
589597

590598
.. versionadded:: 3.2
599+
.. versionchanged:: 3.11
600+
Added default argument value for ``byteorder``.
591601

592602
.. method:: int.as_integer_ratio()
593603

Doc/library/tracemalloc.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -740,12 +740,12 @@ Traceback
740740

741741
.. method:: format(limit=None, most_recent_first=False)
742742

743-
Format the traceback as a list of lines with newlines. Use the
744-
:mod:`linecache` module to retrieve lines from the source code.
745-
If *limit* is set, format the *limit* most recent frames if *limit*
746-
is positive. Otherwise, format the ``abs(limit)`` oldest frames.
747-
If *most_recent_first* is ``True``, the order of the formatted frames
748-
is reversed, returning the most recent frame first instead of last.
743+
Format the traceback as a list of lines. Use the :mod:`linecache` module to
744+
retrieve lines from the source code. If *limit* is set, format the *limit*
745+
most recent frames if *limit* is positive. Otherwise, format the
746+
``abs(limit)`` oldest frames. If *most_recent_first* is ``True``, the order
747+
of the formatted frames is reversed, returning the most recent frame first
748+
instead of last.
749749

750750
Similar to the :func:`traceback.format_tb` function, except that
751751
:meth:`.format` does not include newlines.

Doc/library/unittest.rst

Lines changed: 7 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,9 +1237,6 @@ Test cases
12371237
:meth:`.assertRegex`.
12381238
.. versionadded:: 3.2
12391239
:meth:`.assertNotRegex`.
1240-
.. versionadded:: 3.5
1241-
The name ``assertNotRegexpMatches`` is a deprecated alias
1242-
for :meth:`.assertNotRegex`.
12431240

12441241

12451242
.. method:: assertCountEqual(first, second, msg=None)
@@ -1605,40 +1602,6 @@ Test cases
16051602
:mod:`unittest`-based test framework.
16061603

16071604

1608-
.. _deprecated-aliases:
1609-
1610-
Deprecated aliases
1611-
##################
1612-
1613-
For historical reasons, some of the :class:`TestCase` methods had one or more
1614-
aliases that are now deprecated. The following table lists the correct names
1615-
along with their deprecated aliases:
1616-
1617-
============================== ====================== =======================
1618-
Method Name Deprecated alias Deprecated alias
1619-
============================== ====================== =======================
1620-
:meth:`.assertEqual` failUnlessEqual assertEquals
1621-
:meth:`.assertNotEqual` failIfEqual assertNotEquals
1622-
:meth:`.assertTrue` failUnless assert\_
1623-
:meth:`.assertFalse` failIf
1624-
:meth:`.assertRaises` failUnlessRaises
1625-
:meth:`.assertAlmostEqual` failUnlessAlmostEqual assertAlmostEquals
1626-
:meth:`.assertNotAlmostEqual` failIfAlmostEqual assertNotAlmostEquals
1627-
:meth:`.assertRegex` assertRegexpMatches
1628-
:meth:`.assertNotRegex` assertNotRegexpMatches
1629-
:meth:`.assertRaisesRegex` assertRaisesRegexp
1630-
============================== ====================== =======================
1631-
1632-
.. deprecated:: 3.1
1633-
The fail* aliases listed in the second column have been deprecated.
1634-
.. deprecated:: 3.2
1635-
The assert* aliases listed in the third column have been deprecated.
1636-
.. deprecated:: 3.2
1637-
``assertRegexpMatches`` and ``assertRaisesRegexp`` have been renamed to
1638-
:meth:`.assertRegex` and :meth:`.assertRaisesRegex`.
1639-
.. deprecated:: 3.5
1640-
The ``assertNotRegexpMatches`` name is deprecated in favor of :meth:`.assertNotRegex`.
1641-
16421605
.. _testsuite-objects:
16431606

16441607
Grouping tests
@@ -1764,7 +1727,7 @@ Loading and running tests
17641727
case is created for that method instead.
17651728

17661729

1767-
.. method:: loadTestsFromModule(module, pattern=None)
1730+
.. method:: loadTestsFromModule(module, *, pattern=None)
17681731

17691732
Return a suite of all test cases contained in the given module. This
17701733
method searches *module* for classes derived from :class:`TestCase` and
@@ -1788,10 +1751,11 @@ Loading and running tests
17881751
Support for ``load_tests`` added.
17891752

17901753
.. versionchanged:: 3.5
1791-
The undocumented and unofficial *use_load_tests* default argument is
1792-
deprecated and ignored, although it is still accepted for backward
1793-
compatibility. The method also now accepts a keyword-only argument
1794-
*pattern* which is passed to ``load_tests`` as the third argument.
1754+
Support for a keyword-only argument *pattern* has been added.
1755+
1756+
.. versionchanged:: 3.11
1757+
The undocumented and unofficial *use_load_tests* parameter has been
1758+
removed.
17951759

17961760

17971761
.. method:: loadTestsFromName(name, module=None)
@@ -2144,8 +2108,6 @@ Loading and running tests
21442108
:class:`TextTestRunner`.
21452109

21462110
.. versionadded:: 3.2
2147-
This class was previously named ``_TextTestResult``. The old name still
2148-
exists as an alias but is deprecated.
21492111

21502112

21512113
.. data:: defaultTestLoader
@@ -2168,10 +2130,7 @@ Loading and running tests
21682130
By default this runner shows :exc:`DeprecationWarning`,
21692131
:exc:`PendingDeprecationWarning`, :exc:`ResourceWarning` and
21702132
:exc:`ImportWarning` even if they are :ref:`ignored by default
2171-
<warning-ignored>`. Deprecation warnings caused by :ref:`deprecated unittest
2172-
methods <deprecated-aliases>` are also special-cased and, when the warning
2173-
filters are ``'default'`` or ``'always'``, they will appear only once
2174-
per-module, in order to avoid too many warning messages. This behavior can
2133+
<warning-ignored>`. This behavior can
21752134
be overridden using Python's :option:`!-Wd` or :option:`!-Wa` options
21762135
(see :ref:`Warning control <using-on-warnings>`) and leaving
21772136
*warnings* to ``None``.

Doc/library/venv.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ subclass which installs setuptools and pip into a created virtual environment::
426426
'more target '
427427
'directories.')
428428
parser.add_argument('dirs', metavar='ENV_DIR', nargs='+',
429-
help='A directory in which to create the
429+
help='A directory in which to create the '
430430
'virtual environment.')
431431
parser.add_argument('--no-setuptools', default=False,
432432
action='store_true', dest='nodist',

0 commit comments

Comments
 (0)