Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 236f608

Browse files
Merge branch 'master' into disable-wchar-cache
2 parents 11e0e0c + 5f1e8b4 commit 236f608

58 files changed

Lines changed: 1333 additions & 881 deletions

Some content is hidden

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

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
language: c
2-
dist: trusty
3-
sudo: false
2+
dist: xenial
43
group: beta
54

65
# To cache doc-building dependencies and C compiler output.

Doc/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ check:
174174
$(PYTHON) tools/rstlint.py -i tools -i $(VENVDIR) -i README.rst
175175

176176
serve:
177-
../Tools/scripts/serve.py build/html
177+
$(PYTHON) ../Tools/scripts/serve.py build/html
178178

179179
# Targets for daily automated doc build
180180
# By default, Sphinx only rebuilds pages where the page content has changed.

Doc/library/codecs.rst

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,16 +1316,10 @@ encodings.
13161316
| | | code actually uses UTF-8 |
13171317
| | | by default. |
13181318
+--------------------+---------+---------------------------+
1319-
| unicode_internal | | Return the internal |
1320-
| | | representation of the |
1321-
| | | operand. Stateful codecs |
1322-
| | | are not supported. |
1323-
| | | |
1324-
| | | .. deprecated:: 3.3 |
1325-
| | | This representation is |
1326-
| | | obsoleted by |
1327-
| | | :pep:`393`. |
1328-
+--------------------+---------+---------------------------+
1319+
1320+
.. versionchanged:: 3.8
1321+
"unicode_internal" codec is removed.
1322+
13291323

13301324
.. _binary-transforms:
13311325

Doc/library/collections.rst

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@ they add the ability to access fields by name instead of position index.
853853
Added the *module* parameter.
854854

855855
.. versionchanged:: 3.7
856-
Remove the *verbose* parameter and the :attr:`_source` attribute.
856+
Removed the *verbose* parameter and the :attr:`_source` attribute.
857857

858858
.. versionchanged:: 3.7
859859
Added the *defaults* parameter and the :attr:`_field_defaults`
@@ -953,14 +953,14 @@ field names, the method and attribute names start with an underscore.
953953
>>> Pixel(11, 22, 128, 255, 0)
954954
Pixel(x=11, y=22, red=128, green=255, blue=0)
955955

956-
.. attribute:: somenamedtuple._fields_defaults
956+
.. attribute:: somenamedtuple._field_defaults
957957

958958
Dictionary mapping field names to default values.
959959

960960
.. doctest::
961961

962962
>>> Account = namedtuple('Account', ['type', 'balance'], defaults=[0])
963-
>>> Account._fields_defaults
963+
>>> Account._field_defaults
964964
{'balance': 0}
965965
>>> Account('premium')
966966
Account(type='premium', balance=0)
@@ -1028,17 +1028,20 @@ customize a prototype instance:
10281028

10291029
.. seealso::
10301030

1031-
* `Recipe for named tuple abstract base class with a metaclass mix-in
1032-
<https://code.activestate.com/recipes/577629-namedtupleabc-abstract-base-class-mix-in-for-named/>`_
1033-
by Jan Kaliszewski. Besides providing an :term:`abstract base class` for
1034-
named tuples, it also supports an alternate :term:`metaclass`-based
1035-
constructor that is convenient for use cases where named tuples are being
1036-
subclassed.
1031+
* See :class:`typing.NamedTuple` for a way to add type hints for named
1032+
tuples. It also provides an elegant notation using the :keyword:`class`
1033+
keyword::
1034+
1035+
class Component(NamedTuple):
1036+
part_number: int
1037+
weight: float
1038+
description: Optional[str] = None
10371039

10381040
* See :meth:`types.SimpleNamespace` for a mutable namespace based on an
10391041
underlying dictionary instead of a tuple.
10401042

1041-
* See :meth:`typing.NamedTuple` for a way to add type hints for named tuples.
1043+
* The :mod:`dataclasses` module provides a decorator and functions for
1044+
automatically adding generated special methods to user-defined classes.
10421045

10431046

10441047
:class:`OrderedDict` objects

Doc/library/statistics.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,18 @@ of applications in statistics.
569569
compute the probability that a random variable *X* will be less than or
570570
equal to *x*. Mathematically, it is written ``P(X <= x)``.
571571

572+
.. method:: NormalDist.inv_cdf(p)
573+
574+
Compute the inverse cumulative distribution function, also known as the
575+
`quantile function <https://en.wikipedia.org/wiki/Quantile_function>`_
576+
or the `percent-point
577+
<https://www.statisticshowto.datasciencecentral.com/inverse-distribution-function/>`_
578+
function. Mathematically, it is written ``x : P(X <= x) = p``.
579+
580+
Finds the value *x* of the random variable *X* such that the
581+
probability of the variable being less than or equal to that value
582+
equals the given probability *p*.
583+
572584
.. method:: NormalDist.overlap(other)
573585

574586
Compute the `overlapping coefficient (OVL)
@@ -628,6 +640,16 @@ rounding to the nearest whole number:
628640
>>> round(fraction * 100.0, 1)
629641
18.4
630642

643+
Find the `quartiles <https://en.wikipedia.org/wiki/Quartile>`_ and `deciles
644+
<https://en.wikipedia.org/wiki/Decile>`_ for the SAT scores:
645+
646+
.. doctest::
647+
648+
>>> [round(sat.inv_cdf(p)) for p in (0.25, 0.50, 0.75)]
649+
[928, 1060, 1192]
650+
>>> [round(sat.inv_cdf(p / 10)) for p in range(1, 10)]
651+
[810, 896, 958, 1011, 1060, 1109, 1162, 1224, 1310]
652+
631653
What percentage of men and women will have the same height in `two normally
632654
distributed populations with known means and standard deviations
633655
<http://www.usablestats.com/lessons/normal>`_?

Doc/library/typing.rst

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,7 @@ The module defines the following classes, functions and decorators:
815815

816816
.. class:: NamedTuple
817817

818-
Typed version of namedtuple.
818+
Typed version of :func:`collections.namedtuple`.
819819

820820
Usage::
821821

@@ -838,10 +838,11 @@ The module defines the following classes, functions and decorators:
838838

839839
Fields with a default value must come after any fields without a default.
840840

841-
The resulting class has two extra attributes: ``_field_types``,
842-
giving a dict mapping field names to types, and ``_field_defaults``, a dict
843-
mapping field names to default values. (The field names are in the
844-
``_fields`` attribute, which is part of the namedtuple API.)
841+
The resulting class has an extra attribute ``__annotations__`` giving a
842+
dict that maps the field names to the field types. (The field names are in
843+
the ``_fields`` attribute and the default values are in the
844+
``_field_defaults`` attribute both of which are part of the namedtuple
845+
API.)
845846

846847
``NamedTuple`` subclasses can also have docstrings and methods::
847848

@@ -863,6 +864,15 @@ The module defines the following classes, functions and decorators:
863864
.. versionchanged:: 3.6.1
864865
Added support for default values, methods, and docstrings.
865866

867+
.. versionchanged:: 3.8
868+
Deprecated the ``_field_types`` attribute in favor of the more
869+
standard ``__annotations__`` attribute which has the same information.
870+
871+
.. versionchanged:: 3.8
872+
The ``_field_types`` and ``__annotations__`` attributes are
873+
now regular dictionaries instead of instances of ``OrderedDict``.
874+
875+
866876
.. function:: NewType(typ)
867877

868878
A helper function to indicate a distinct types to a typechecker,

Doc/library/unittest.mock.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1440,7 +1440,7 @@ passed by keyword *after* any of the standard arguments created by :func:`patch`
14401440
>>> test_function()
14411441

14421442
If :func:`patch.multiple` is used as a context manager, the value returned by the
1443-
context manger is a dictionary where created mocks are keyed by name::
1443+
context manager is a dictionary where created mocks are keyed by name::
14441444

14451445
>>> with patch.multiple('__main__', thing=DEFAULT, other=DEFAULT) as values:
14461446
... assert 'other' in repr(values['other'])

Doc/whatsnew/3.8.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,10 @@ Deprecated
510510

511511
(Contributed by Berker Peksag in :issue:`9372`.)
512512

513+
* The :class:`typing.NamedTuple` class has deprecated the ``_field_types``
514+
attribute in favor of the ``__annotations__`` attribute which has the same
515+
information. (Contributed by Raymond Hettinger in :issue:`36320`.)
516+
513517
* :mod:`ast` classes ``Num``, ``Str``, ``Bytes``, ``NameConstant`` and
514518
``Ellipsis`` are considered deprecated and will be removed in future Python
515519
versions. :class:`~ast.Constant` should be used instead.
@@ -573,6 +577,9 @@ The following features and APIs have been removed from Python 3.8:
573577
* Removed the ``doctype()`` method of :class:`~xml.etree.ElementTree.XMLParser`.
574578
(Contributed by Serhiy Storchaka in :issue:`29209`.)
575579

580+
* "unicode_internal" codec is removed.
581+
(Contributed by Inada Naoki in :issue:`36297`.)
582+
576583

577584
Porting to Python 3.8
578585
=====================
@@ -614,6 +621,11 @@ Changes in the Python API
614621
specialized methods like :meth:`~tkinter.ttk.Treeview.selection_set` for
615622
changing the selection. (Contributed by Serhiy Storchaka in :issue:`31508`.)
616623

624+
* The :meth:`writexml`, :meth:`toxml` and :meth:`toprettyxml` methods of the
625+
:mod:`xml.dom.minidom` module, and :mod:`xml.etree` now preserve the attribute
626+
order specified by the user.
627+
(Contributed by Diego Rojas and Raymond Hettinger in :issue:`34160`.)
628+
617629
* A :mod:`dbm.dumb` database opened with flags ``'r'`` is now read-only.
618630
:func:`dbm.dumb.open` with flags ``'r'`` and ``'w'`` no longer creates
619631
a database if it does not exist.

Include/cpython/abstract.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ PyAPI_FUNC(int) _PyObject_HasFastCall(PyObject *callable);
6666
If nargs is equal to zero, args can be NULL. kwargs can be NULL.
6767
nargs must be greater or equal to zero.
6868
69-
Return the result on success. Raise an exception on return NULL on
69+
Return the result on success. Raise an exception and return NULL on
7070
error. */
7171
PyAPI_FUNC(PyObject *) _PyObject_FastCallDict(
7272
PyObject *callable,

Include/cpython/unicodeobject.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -908,15 +908,6 @@ PyAPI_FUNC(PyObject*) PyUnicode_EncodeRawUnicodeEscape(
908908
Py_ssize_t length /* Number of Py_UNICODE chars to encode */
909909
) Py_DEPRECATED(3.3);
910910

911-
/* --- Unicode Internal Codec --------------------------------------------- */
912-
913-
/* Only for internal use in _codecsmodule.c */
914-
PyObject *_PyUnicode_DecodeUnicodeInternal(
915-
const char *string,
916-
Py_ssize_t length,
917-
const char *errors
918-
);
919-
920911
/* --- Latin-1 Codecs ----------------------------------------------------- */
921912

922913
PyAPI_FUNC(PyObject*) _PyUnicode_AsLatin1String(

0 commit comments

Comments
 (0)