Skip to content

Commit e3b9365

Browse files
committed
Merge remote-tracking branch 'origin/master' into bpo_1635741_1
* origin/master: (113 commits) bpo-41773: Raise exception for non-finite weights in random.choices(). (pythonGH-22441) bpo-41873: Add vectorcall for float() (pythonGH-22432) bpo-41861: Convert _sqlite3 PrepareProtocolType to heap type (pythonGH-22428) bpo-41842: Add codecs.unregister() function (pythonGH-22360) bpo-41875: Use __builtin_unreachable when possible (pythonGH-22433) bpo-40105: ZipFile truncate in append mode with shorter comment (pythonGH-19337) bpo-41870: Use PEP 590 vectorcall to speed up bool() (pythonGH-22427) [doc] Leverage the fact that the actual types can now be indexed for typing (pythonGH-22340) bpo-41861: Convert _sqlite3 cache and node static types to heap types (pythonGH-22417) bpo-41858: Clarify line in optparse doc (pythonGH-22407) Revert "Fix all Python Cookbook links (python#22205)" (pythonGH-22424) bpo-1635741: Port _bisect module to multi-phase init (pythonGH-22415) bpo-41428: Fix compiler warning in unionobject.c (pythonGH-22416) Fix logging error message (pythonGH-22410) bpo-39934: Account for control blocks in 'except' in compiler. (pythonGH-22395) bpo-41775: Make 'IDLE Shell' the shell title (python#22399) bpo-41428: Fix compiler warnings in unionobject.c (pythonGH-22388) bpo-41654: Fix compiler warning in MemoryError_dealloc() (pythonGH-22387) bpo-41833: threading.Thread now uses the target name (pythonGH-22357) bpo-30155: Add macros to get tzinfo from datetime instances (pythonGH-21633) ...
2 parents 3795420 + b0dfc75 commit e3b9365

File tree

224 files changed

+4452
-2314
lines changed

Some content is hidden

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

224 files changed

+4452
-2314
lines changed

.travis.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,7 @@ matrix:
5151
env: TESTING=docs
5252
before_script:
5353
- cd Doc
54-
# Sphinx is pinned so that new versions that introduce new warnings won't suddenly cause build failures.
55-
# (Updating the version is fine as long as no warnings are raised by doing so.)
56-
# The theme used by the docs is stored separately, so we need to install that as well.
57-
- python -m pip install sphinx==2.2.0 blurb python-docs-theme
54+
- make venv PYTHON=python
5855
script:
5956
- make check suspicious html SPHINXOPTS="-q -W -j4"
6057
- name: "Documentation tests"

Doc/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ clean:
143143
venv:
144144
$(PYTHON) -m venv $(VENVDIR)
145145
$(VENVDIR)/bin/python3 -m pip install -U pip setuptools
146-
$(VENVDIR)/bin/python3 -m pip install -U Sphinx==3.2.1 blurb python-docs-theme
146+
$(VENVDIR)/bin/python3 -m pip install -r requirements.txt
147147
@echo "The venv has been created in the $(VENVDIR) directory"
148148

149149
dist:

Doc/c-api/codec.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ Codec registry and support functions
1010
As side effect, this tries to load the :mod:`encodings` package, if not yet
1111
done, to make sure that it is always first in the list of search functions.
1212
13+
.. c:function:: int PyCodec_Unregister(PyObject *search_function)
14+
15+
Unregister a codec search function and clear the registry's cache.
16+
If the search function is not registered, do nothing.
17+
Return 0 on success. Raise an exception and return -1 on error.
18+
19+
.. versionadded:: 3.10
20+
1321
.. c:function:: int PyCodec_KnownEncoding(const char *encoding)
1422
1523
Return ``1`` or ``0`` depending on whether there is a registered codec for

Doc/c-api/datetime.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,11 @@ must not be ``NULL``, and the type is not checked:
185185
186186
Return the microsecond, as an int from 0 through 999999.
187187
188+
.. c:function:: PyObject* PyDateTime_DATE_GET_TZINFO(PyDateTime_DateTime *o)
189+
190+
Return the tzinfo (which may be ``None``).
191+
192+
.. versionadded:: 3.10
188193
189194
Macros to extract fields from time objects. The argument must be an instance of
190195
:c:data:`PyDateTime_Time`, including subclasses. The argument must not be ``NULL``,
@@ -209,6 +214,12 @@ and the type is not checked:
209214
210215
Return the microsecond, as an int from 0 through 999999.
211216
217+
.. c:function:: PyObject* PyDateTime_TIME_GET_TZINFO(PyDateTime_Time *o)
218+
219+
Return the tzinfo (which may be ``None``).
220+
221+
.. versionadded:: 3.10
222+
212223
213224
Macros to extract fields from time delta objects. The argument must be an
214225
instance of :c:data:`PyDateTime_Delta`, including subclasses. The argument must

Doc/c-api/gen.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ than explicitly calling :c:func:`PyGen_New` or :c:func:`PyGen_NewWithQualName`.
1515
The C structure used for generator objects.
1616

1717

18+
.. c:type:: PySendResult
19+
20+
The enum value used to represent different results of :c:func:`PyGen_Send`.
21+
22+
1823
.. c:var:: PyTypeObject PyGen_Type
1924
2025
The type object corresponding to generator objects.
@@ -42,3 +47,13 @@ than explicitly calling :c:func:`PyGen_New` or :c:func:`PyGen_NewWithQualName`.
4247
with ``__name__`` and ``__qualname__`` set to *name* and *qualname*.
4348
A reference to *frame* is stolen by this function. The *frame* argument
4449
must not be ``NULL``.
50+
51+
.. c:function:: PySendResult PyGen_Send(PyGenObject *gen, PyObject *arg, PyObject **presult)
52+
53+
Sends the *arg* value into the generator *gen*. Coroutine objects
54+
are also allowed to be as the *gen* argument but they need to be
55+
explicitly casted to PyGenObject*. Returns:
56+
57+
- ``PYGEN_RETURN`` if generator returns. Return value is returned via *presult*.
58+
- ``PYGEN_NEXT`` if generator yields. Yielded value is returned via *presult*.
59+
- ``PYGEN_ERROR`` if generator has raised and exception. *presult* is set to ``NULL``.

Doc/data/refcounts.dat

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,11 @@ PyGen_NewWithQualName:PyFrameObject*:frame:0:
959959
PyGen_NewWithQualName:PyObject*:name:0:
960960
PyGen_NewWithQualName:PyObject*:qualname:0:
961961

962+
PyGen_Send:int:::
963+
PyGen_Send:PyGenObject*:gen:0:
964+
PyGen_Send:PyObject*:arg:0:
965+
PyGen_Send:PyObject**:presult:+1:
966+
962967
PyCoro_CheckExact:int:::
963968
PyCoro_CheckExact:PyObject*:ob:0:
964969

@@ -2283,6 +2288,11 @@ PyType_CheckExact:PyObject*:o:0:
22832288
PyType_FromSpec:PyObject*::+1:
22842289
PyType_FromSpec:PyType_Spec*:spec::
22852290

2291+
PyType_FromModuleAndSpec:PyObject*::+1:
2292+
PyType_FromModuleAndSpec:PyObject*:module:+1:
2293+
PyType_FromModuleAndSpec:PyType_Spec*:spec::
2294+
PyType_FromModuleAndSpec:PyObject*:bases:0:
2295+
22862296
PyType_FromSpecWithBases:PyObject*::+1:
22872297
PyType_FromSpecWithBases:PyType_Spec*:spec::
22882298
PyType_FromSpecWithBases:PyObject*:bases:0:

Doc/faq/programming.rst

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,20 +1504,19 @@ Most :meth:`__setattr__` implementations must modify ``self.__dict__`` to store
15041504
local state for self without causing an infinite recursion.
15051505

15061506

1507-
How do I call a method defined in a base class from a derived class that overrides it?
1508-
--------------------------------------------------------------------------------------
1507+
How do I call a method defined in a base class from a derived class that extends it?
1508+
------------------------------------------------------------------------------------
15091509

15101510
Use the built-in :func:`super` function::
15111511

15121512
class Derived(Base):
15131513
def meth(self):
1514-
super(Derived, self).meth()
1514+
super().meth() # calls Base.meth
15151515

1516-
For version prior to 3.0, you may be using classic classes: For a class
1517-
definition such as ``class Derived(Base): ...`` you can call method ``meth()``
1518-
defined in ``Base`` (or one of ``Base``'s base classes) as ``Base.meth(self,
1519-
arguments...)``. Here, ``Base.meth`` is an unbound method, so you need to
1520-
provide the ``self`` argument.
1516+
In the example, :func:`super` will automatically determine the instance from
1517+
which it was called (the ``self`` value), look up the :term:`method resolution
1518+
order` (MRO) with ``type(self).__mro__``, and return the next in line after
1519+
``Derived`` in the MRO: ``Base``.
15211520

15221521

15231522
How can I organize my code to make it easier to change the base class?

Doc/glossary.rst

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,19 +1084,15 @@ Glossary
10841084
Type aliases are useful for simplifying :term:`type hints <type hint>`.
10851085
For example::
10861086

1087-
from typing import List, Tuple
1088-
10891087
def remove_gray_shades(
1090-
colors: List[Tuple[int, int, int]]) -> List[Tuple[int, int, int]]:
1088+
colors: list[tuple[int, int, int]]) -> list[tuple[int, int, int]]:
10911089
pass
10921090

10931091
could be made more readable like this::
10941092

1095-
from typing import List, Tuple
1096-
1097-
Color = Tuple[int, int, int]
1093+
Color = tuple[int, int, int]
10981094

1099-
def remove_gray_shades(colors: List[Color]) -> List[Color]:
1095+
def remove_gray_shades(colors: list[Color]) -> list[Color]:
11001096
pass
11011097

11021098
See :mod:`typing` and :pep:`484`, which describe this functionality.

Doc/library/codecs.rst

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,14 @@ function:
163163
:class:`CodecInfo` object. In case a search function cannot find
164164
a given encoding, it should return ``None``.
165165

166-
.. note::
167166

168-
Search function registration is not currently reversible,
169-
which may cause problems in some cases, such as unit testing or
170-
module reloading.
167+
.. function:: unregister(search_function)
168+
169+
Unregister a codec search function and clear the registry's cache.
170+
If the search function is not registered, do nothing.
171+
172+
.. versionadded:: 3.10
173+
171174

172175
While the builtin :func:`open` and the associated :mod:`io` module are the
173176
recommended approach for working with encoded text files, this module

Doc/library/configparser.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,30 @@ involves the ``DEFAULT`` section which provides default values for all other
135135
sections [1]_. Note also that keys in sections are
136136
case-insensitive and stored in lowercase [1]_.
137137

138+
It is possible to read several configurations into a single
139+
:class:`ConfigParser`, where the most recently added configuration has the
140+
highest priority. Any conflicting keys are taken from the more recent
141+
configuration while the previously existing keys are retained.
142+
143+
.. doctest::
144+
145+
>>> another_config = configparser.ConfigParser()
146+
>>> another_config.read('example.ini')
147+
['example.ini']
148+
>>> another_config['topsecret.server.com']['Port']
149+
'50022'
150+
>>> another_config.read_string("[topsecret.server.com]\nPort=48484")
151+
>>> another_config['topsecret.server.com']['Port']
152+
'48484'
153+
>>> another_config.read_dict({"topsecret.server.com": {"Port": 21212}})
154+
>>> another_config['topsecret.server.com']['Port']
155+
'21212'
156+
>>> another_config['topsecret.server.com']['ForwardX11']
157+
'no'
158+
159+
This behaviour is equivalent to a :meth:`ConfigParser.read` call with several
160+
files passed to the *filenames* parameter.
161+
138162

139163
Supported Datatypes
140164
-------------------

Doc/library/constants.rst

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,21 @@ A small number of constants live in the built-in namespace. They are:
1919

2020
.. data:: None
2121

22-
The sole value of the type ``NoneType``. ``None`` is frequently used to
23-
represent the absence of a value, as when default arguments are not passed to a
24-
function. Assignments to ``None`` are illegal and raise a :exc:`SyntaxError`.
22+
An object frequently used to represent the absence of a value, as when
23+
default arguments are not passed to a function. Assignments to ``None``
24+
are illegal and raise a :exc:`SyntaxError`.
25+
``None`` is the sole instance of the :data:`NoneType` type.
2526

2627

2728
.. data:: NotImplemented
2829

29-
Special value which should be returned by the binary special methods
30+
A special value which should be returned by the binary special methods
3031
(e.g. :meth:`__eq__`, :meth:`__lt__`, :meth:`__add__`, :meth:`__rsub__`,
3132
etc.) to indicate that the operation is not implemented with respect to
3233
the other type; may be returned by the in-place binary special methods
3334
(e.g. :meth:`__imul__`, :meth:`__iand__`, etc.) for the same purpose.
3435
It should not be evaluated in a boolean context.
36+
``NotImplemented`` is the sole instance of the :data:`types.NotImplementedType` type.
3537

3638
.. note::
3739

@@ -59,8 +61,9 @@ A small number of constants live in the built-in namespace. They are:
5961
.. index:: single: ...; ellipsis literal
6062
.. data:: Ellipsis
6163

62-
The same as the ellipsis literal "``...``". Special value used mostly in conjunction
64+
The same as the ellipsis literal "``...``". Special value used mostly in conjunction
6365
with extended slicing syntax for user-defined container data types.
66+
``Ellipsis`` is the sole instance of the :data:`types.EllipsisType` type.
6467

6568

6669
.. data:: __debug__

Doc/library/difflib.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
--------------
1919

2020
This module provides classes and functions for comparing sequences. It
21-
can be used for example, for comparing files, and can produce difference
22-
information in various formats, including HTML and context and unified
21+
can be used for example, for comparing files, and can produce information
22+
about file differences in various formats, including HTML and context and unified
2323
diffs. For comparing directories and files, see also, the :mod:`filecmp` module.
2424

2525

0 commit comments

Comments
 (0)