Skip to content

Commit 5c962fb

Browse files
Merge remote-tracking branch 'upstream/master' into add_test_xpickle
2 parents c463dec + a8bf44d commit 5c962fb

File tree

414 files changed

+4955
-1540
lines changed

Some content is hidden

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

414 files changed

+4955
-1540
lines changed

Doc/c-api/dict.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,16 @@ Dictionary Objects
8181
.. c:function:: int PyDict_DelItem(PyObject *p, PyObject *key)
8282
8383
Remove the entry in dictionary *p* with key *key*. *key* must be hashable;
84-
if it isn't, :exc:`TypeError` is raised. Return ``0`` on success or ``-1``
85-
on failure.
84+
if it isn't, :exc:`TypeError` is raised.
85+
If *key* is not in the dictionary, :exc:`KeyError` is raised.
86+
Return ``0`` on success or ``-1`` on failure.
8687
8788
8889
.. c:function:: int PyDict_DelItemString(PyObject *p, const char *key)
8990
90-
Remove the entry in dictionary *p* which has a key specified by the string
91-
*key*. Return ``0`` on success or ``-1`` on failure.
91+
Remove the entry in dictionary *p* which has a key specified by the string *key*.
92+
If *key* is not in the dictionary, :exc:`KeyError` is raised.
93+
Return ``0`` on success or ``-1`` on failure.
9294
9395
9496
.. c:function:: PyObject* PyDict_GetItem(PyObject *p, PyObject *key)

Doc/faq/programming.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,7 +1176,7 @@ Here are three variations.::
11761176
mylist[:] = (x for x in mylist if keep_condition)
11771177
mylist[:] = [x for x in mylist if keep_condition]
11781178

1179-
If space is not an issue, the list comprehension may be fastest.
1179+
The list comprehension may be fastest.
11801180

11811181

11821182
How do you make an array in Python?
@@ -1191,7 +1191,7 @@ difference is that a Python list can contain objects of many different types.
11911191

11921192
The ``array`` module also provides methods for creating arrays of fixed types
11931193
with compact representations, but they are slower to index than lists. Also
1194-
note that the Numeric extensions and others define array-like structures with
1194+
note that NumPy and other third party packages define array-like structures with
11951195
various characteristics as well.
11961196

11971197
To get Lisp-style linked lists, you can emulate cons cells using tuples::

Doc/library/array.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,6 @@ Examples::
257257
Packing and unpacking of External Data Representation (XDR) data as used in some
258258
remote procedure call systems.
259259

260-
`The Numerical Python Documentation <https://docs.scipy.org/doc/>`_
261-
The Numeric Python extension (NumPy) defines another array type; see
262-
http://www.numpy.org/ for further information about Numerical Python.
260+
`NumPy <https://numpy.org/>`_
261+
The NumPy package defines another array type.
263262

Doc/library/ast.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1586,6 +1586,9 @@ and classes for traversing abstract syntax trees:
15861586
.. versionchanged:: 3.9
15871587
Now supports creating empty sets with ``'set()'``.
15881588

1589+
.. versionchanged:: 3.10
1590+
For string inputs, leading spaces and tabs are now stripped.
1591+
15891592

15901593
.. function:: get_docstring(node, clean=True)
15911594

@@ -1820,4 +1823,4 @@ to stdout. Otherwise, the content is read from stdin.
18201823
`Parso <https://parso.readthedocs.io>`_ is a Python parser that supports
18211824
error recovery and round-trip parsing for different Python versions (in
18221825
multiple Python versions). Parso is also able to list multiple syntax errors
1823-
in your python file.
1826+
in your python file.

Doc/library/dataclasses.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ Module-level decorators, classes, and functions
188188

189189
@dataclass
190190
class C:
191-
mylist: List[int] = field(default_factory=list)
191+
mylist: list[int] = field(default_factory=list)
192192

193193
c = C()
194194
c.mylist += [1, 2, 3]
@@ -301,7 +301,7 @@ Module-level decorators, classes, and functions
301301

302302
@dataclass
303303
class C:
304-
mylist: List[Point]
304+
mylist: list[Point]
305305

306306
p = Point(10, 20)
307307
assert asdict(p) == {'x': 10, 'y': 20}

Doc/library/decimal.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,13 @@ Decimal objects
621621
Return :const:`True` if the argument is either positive or negative
622622
infinity and :const:`False` otherwise.
623623

624+
.. method:: is_integer()
625+
626+
Return :const:`True` if the argument is a finite integral value and
627+
:const:`False` otherwise.
628+
629+
.. versionadded:: 3.10
630+
624631
.. method:: is_nan()
625632

626633
Return :const:`True` if the argument is a (quiet or signaling) NaN and
@@ -1215,6 +1222,13 @@ In addition to the three supplied contexts, new contexts can be created with the
12151222
Returns ``True`` if *x* is infinite; otherwise returns ``False``.
12161223

12171224

1225+
.. method:: is_integer(x)
1226+
1227+
Returns ``True`` if *x* is finite and integral; otherwise
1228+
returns ``False``.
1229+
1230+
.. versionadded:: 3.10
1231+
12181232
.. method:: is_nan(x)
12191233

12201234
Returns ``True`` if *x* is a qNaN or sNaN; otherwise returns ``False``.

Doc/library/functions.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,9 @@ are always available. They are listed here in alphabetical order.
506506
returns the current global and local dictionary, respectively, which may be
507507
useful to pass around for use by :func:`eval` or :func:`exec`.
508508

509+
If the given source is a string, then leading and trailing spaces and tabs
510+
are stripped.
511+
509512
See :func:`ast.literal_eval` for a function that can safely evaluate strings
510513
with expressions containing only literals.
511514

@@ -1512,14 +1515,12 @@ are always available. They are listed here in alphabetical order.
15121515
.. class:: slice(stop)
15131516
slice(start, stop[, step])
15141517

1515-
.. index:: single: Numerical Python
1516-
15171518
Return a :term:`slice` object representing the set of indices specified by
15181519
``range(start, stop, step)``. The *start* and *step* arguments default to
15191520
``None``. Slice objects have read-only data attributes :attr:`~slice.start`,
15201521
:attr:`~slice.stop` and :attr:`~slice.step` which merely return the argument
15211522
values (or their default). They have no other explicit functionality;
1522-
however they are used by Numerical Python and other third party extensions.
1523+
however they are used by NumPy and other third party packages.
15231524
Slice objects are also generated when extended indexing syntax is used. For
15241525
example: ``a[start:stop:step]`` or ``a[start:stop, i]``. See
15251526
:func:`itertools.islice` for an alternate version that returns an iterator.

Doc/library/numbers.rst

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,30 @@ The numeric tower
4949
numbers.
5050

5151
In short, those are: a conversion to :class:`float`, :func:`math.trunc`,
52-
:func:`round`, :func:`math.floor`, :func:`math.ceil`, :func:`divmod`, ``//``,
53-
``%``, ``<``, ``<=``, ``>``, and ``>=``.
52+
:func:`round`, :func:`math.floor`, :func:`math.ceil`, :func:`divmod`,
53+
:func:`~Real.is_integer`, ``//``, ``%``, ``<``, ``<=``, ``>``, and ``>=``.
5454

5555
Real also provides defaults for :func:`complex`, :attr:`~Complex.real`,
5656
:attr:`~Complex.imag`, and :meth:`~Complex.conjugate`.
5757

58+
.. method:: is_integer()
59+
60+
Returns :const:`True` if this number has a finite and integral value,
61+
otherwise :const:`False`. This is a default implementation which
62+
relies on successful conversion to :class:`int`. It may be overridden
63+
in subclasses (such as it is in :class:`float`) for better performance,
64+
or to handle special values such as NaN which are not
65+
convertible to :class:`int`.
66+
67+
.. versionadded:: 3.10
68+
5869

5970
.. class:: Rational
6071

6172
Subtypes :class:`Real` and adds
6273
:attr:`~Rational.numerator` and :attr:`~Rational.denominator` properties, which
63-
should be in lowest terms. With these, it provides a default for
64-
:func:`float`.
74+
should be in lowest terms. With these, it provides defaults for
75+
:func:`float` and :func:`~Real.is_integer`.
6576

6677
.. attribute:: numerator
6778

@@ -75,9 +86,10 @@ The numeric tower
7586
.. class:: Integral
7687

7788
Subtypes :class:`Rational` and adds a conversion to :class:`int`. Provides
78-
defaults for :func:`float`, :attr:`~Rational.numerator`, and
79-
:attr:`~Rational.denominator`. Adds abstract methods for ``**`` and
80-
bit-string operations: ``<<``, ``>>``, ``&``, ``^``, ``|``, ``~``.
89+
defaults for :func:`float`, :attr:`~Rational.numerator`,
90+
:attr:`~Rational.denominator`, and :func:`~Real.is_integer`. Adds abstract
91+
methods for ``**`` and bit-string operations: ``<<``, ``>>``, ``&``, ``^``,
92+
``|``, ``~``.
8193

8294

8395
Notes for type implementors

Doc/library/pathlib.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,6 +1008,10 @@ call fails (for example because the path doesn't exist).
10081008
>>> target.open().read()
10091009
'some text'
10101010

1011+
The target path may be absolute or relative. Relative paths are interpreted
1012+
relative to the current working directory, *not* the directory of the Path
1013+
object.
1014+
10111015
.. versionchanged:: 3.8
10121016
Added return value, return the new Path instance.
10131017

@@ -1018,6 +1022,10 @@ call fails (for example because the path doesn't exist).
10181022
instance pointing to *target*. If *target* points to an existing file or
10191023
directory, it will be unconditionally replaced.
10201024

1025+
The target path may be absolute or relative. Relative paths are interpreted
1026+
relative to the current working directory, *not* the directory of the Path
1027+
object.
1028+
10211029
.. versionchanged:: 3.8
10221030
Added return value, return the new Path instance.
10231031

Doc/library/secrets.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ The :mod:`secrets` module is used for generating cryptographically strong
2121
random numbers suitable for managing data such as passwords, account
2222
authentication, security tokens, and related secrets.
2323

24-
In particularly, :mod:`secrets` should be used in preference to the
24+
In particular, :mod:`secrets` should be used in preference to the
2525
default pseudo-random number generator in the :mod:`random` module, which
2626
is designed for modelling and simulation, not security or cryptography.
2727

0 commit comments

Comments
 (0)