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

Skip to content

Commit 93ff15f

Browse files
author
animalize
authored
Merge pull request #4 from python/master
1
2 parents ed20d2f + 8a03ff2 commit 93ff15f

1,006 files changed

Lines changed: 16447 additions & 4512 deletions

File tree

Some content is hidden

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

Doc/bugs.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,4 @@ any and all questions pertaining to the process of fixing issues in Python.
8989

9090
.. _Documentation bugs: https://bugs.python.org/issue?@filter=status&@filter=components&components=4&status=1&@columns=id,activity,title,status&@sort=-activity
9191
.. _Python Developer's Guide: https://devguide.python.org/
92-
.. _core-mentorship mailing list: https://mail.python.org/mailman/listinfo/core-mentorship/
92+
.. _core-mentorship mailing list: https://mail.python.org/mailman3/lists/core-mentorship.python.org/

Doc/distutils/setupscript.rst

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -524,20 +524,23 @@ following way::
524524
setup(...,
525525
data_files=[('bitmaps', ['bm/b1.gif', 'bm/b2.gif']),
526526
('config', ['cfg/data.cfg']),
527-
('/etc/init.d', ['init-script'])]
528527
)
529528

530-
Note that you can specify the directory names where the data files will be
531-
installed, but you cannot rename the data files themselves.
532-
533529
Each (*directory*, *files*) pair in the sequence specifies the installation
534-
directory and the files to install there. If *directory* is a relative path, it
535-
is interpreted relative to the installation prefix (Python's ``sys.prefix`` for
536-
pure-Python packages, ``sys.exec_prefix`` for packages that contain extension
537-
modules). Each file name in *files* is interpreted relative to the
538-
:file:`setup.py` script at the top of the package source distribution. No
539-
directory information from *files* is used to determine the final location of
540-
the installed file; only the name of the file is used.
530+
directory and the files to install there.
531+
532+
Each file name in *files* is interpreted relative to the :file:`setup.py`
533+
script at the top of the package source distribution. Note that you can
534+
specify the directory where the data files will be installed, but you cannot
535+
rename the data files themselves.
536+
537+
The *directory* should be a relative path. It is interpreted relative to the
538+
installation prefix (Python's ``sys.prefix`` for system installations;
539+
``site.USER_BASE`` for user installations). Distutils allows *directory* to be
540+
an absolute installation path, but this is discouraged since it is
541+
incompatible with the wheel packaging format. No directory information from
542+
*files* is used to determine the final location of the installed file; only
543+
the name of the file is used.
541544

542545
You can specify the ``data_files`` options as a simple sequence of files
543546
without specifying a target directory, but this is not recommended, and the

Doc/library/ast.rst

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,16 +126,33 @@ The abstract grammar is currently defined as follows:
126126
Apart from the node classes, the :mod:`ast` module defines these utility functions
127127
and classes for traversing abstract syntax trees:
128128

129-
.. function:: parse(source, filename='<unknown>', mode='exec')
129+
.. function:: parse(source, filename='<unknown>', mode='exec', *, type_comments=False)
130130

131131
Parse the source into an AST node. Equivalent to ``compile(source,
132132
filename, mode, ast.PyCF_ONLY_AST)``.
133133

134+
If ``type_comments=True`` is given, the parser is modified to check
135+
and return type comments as specified by :pep:`484` and :pep:`526`.
136+
This is equivalent to adding :data:`ast.PyCF_TYPE_COMMENTS` to the
137+
flags passed to :func:`compile()`. This will report syntax errors
138+
for misplaced type comments. Without this flag, type comments will
139+
be ignored, and the ``type_comment`` field on selected AST nodes
140+
will always be ``None``. In addition, the locations of ``# type:
141+
ignore`` comments will be returned as the ``type_ignores``
142+
attribute of :class:`Module` (otherwise it is always an empty list).
143+
144+
In addition, if ``mode`` is ``'func_type'``, the input syntax is
145+
modified to correspond to :pep:`484` "signature type comments",
146+
e.g. ``(str, int) -> List[str]``.
147+
134148
.. warning::
135149
It is possible to crash the Python interpreter with a
136150
sufficiently large/complex string due to stack depth limitations
137151
in Python's AST compiler.
138152

153+
.. versionchanged:: 3.8
154+
Added ``type_comments=True`` and ``mode='func_type'``.
155+
139156

140157
.. function:: literal_eval(node_or_string)
141158

Doc/library/collections.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -894,11 +894,18 @@ field names, the method and attribute names start with an underscore.
894894

895895
>>> p = Point(x=11, y=22)
896896
>>> p._asdict()
897-
OrderedDict([('x', 11), ('y', 22)])
897+
{'x': 11, 'y': 22}
898898

899899
.. versionchanged:: 3.1
900900
Returns an :class:`OrderedDict` instead of a regular :class:`dict`.
901901

902+
.. versionchanged:: 3.8
903+
Returns a regular :class:`dict` instead of an :class:`OrderedDict`.
904+
As of Python 3.7, regular dicts are guaranteed to be ordered. If the
905+
extra features of :class:`OrderedDict` are required, the suggested
906+
remediation is to cast the result to the desired type:
907+
``OrderedDict(nt._asdict())``.
908+
902909
.. method:: somenamedtuple._replace(**kwargs)
903910

904911
Return a new instance of the named tuple replacing specified fields with new

Doc/library/configparser.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -476,9 +476,9 @@ the :meth:`__init__` options:
476476
... 'bar': 'y',
477477
... 'baz': 'z'}
478478
... })
479-
>>> parser.sections() # doctest: +SKIP
479+
>>> parser.sections()
480480
['section1', 'section2', 'section3']
481-
>>> [option for option in parser['section3']] # doctest: +SKIP
481+
>>> [option for option in parser['section3']]
482482
['foo', 'bar', 'baz']
483483

484484
* *allow_no_value*, default value: ``False``
@@ -921,7 +921,7 @@ ConfigParser Objects
921921
providing consistent behavior across the parser: non-string
922922
keys and values are implicitly converted to strings.
923923

924-
.. versionchanged:: 3.7
924+
.. versionchanged:: 3.8
925925
The default *dict_type* is :class:`dict`, since it now preserves
926926
insertion order.
927927

@@ -1199,7 +1199,7 @@ RawConfigParser Objects
11991199
names, and values via its unsafe ``add_section`` and ``set`` methods,
12001200
as well as the legacy ``defaults=`` keyword argument handling.
12011201

1202-
.. versionchanged:: 3.7
1202+
.. versionchanged:: 3.8
12031203
The default *dict_type* is :class:`dict`, since it now preserves
12041204
insertion order.
12051205

Doc/library/csv.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,12 @@ The :mod:`csv` module defines the following classes:
150150
dialect='excel', *args, **kwds)
151151
152152
Create an object that operates like a regular reader but maps the
153-
information in each row to an :mod:`OrderedDict <collections.OrderedDict>`
154-
whose keys are given by the optional *fieldnames* parameter.
153+
information in each row to a :class:`dict` whose keys are given by the
154+
optional *fieldnames* parameter.
155155

156156
The *fieldnames* parameter is a :term:`sequence`. If *fieldnames* is
157157
omitted, the values in the first row of file *f* will be used as the
158-
fieldnames. Regardless of how the fieldnames are determined, the ordered
158+
fieldnames. Regardless of how the fieldnames are determined, the
159159
dictionary preserves their original ordering.
160160

161161
If a row has more fields than fieldnames, the remaining data is put in a
@@ -166,8 +166,8 @@ The :mod:`csv` module defines the following classes:
166166
All other optional or keyword arguments are passed to the underlying
167167
:class:`reader` instance.
168168

169-
.. versionchanged:: 3.6
170-
Returned rows are now of type :class:`OrderedDict`.
169+
.. versionchanged:: 3.8
170+
Returned rows are now of type :class:`dict`.
171171

172172
A short usage example::
173173

@@ -181,7 +181,7 @@ The :mod:`csv` module defines the following classes:
181181
John Cleese
182182

183183
>>> print(row)
184-
OrderedDict([('first_name', 'John'), ('last_name', 'Cleese')])
184+
{'first_name': 'John', 'last_name': 'Cleese'}
185185

186186

187187
.. class:: DictWriter(f, fieldnames, restval='', extrasaction='raise', \

Doc/library/decimal.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2115,3 +2115,23 @@ Alternatively, inputs can be rounded upon creation using the
21152115

21162116
>>> Context(prec=5, rounding=ROUND_DOWN).create_decimal('1.2345678')
21172117
Decimal('1.2345')
2118+
2119+
Q. Is the CPython implementation fast for large numbers?
2120+
2121+
A. Yes. In the CPython and PyPy3 implementations, the C/CFFI versions of
2122+
the decimal module integrate the high speed `libmpdec
2123+
<https://www.bytereef.org/mpdecimal/doc/libmpdec/index.html>`_ library for
2124+
arbitrary precision correctly-rounded decimal floating point arithmetic.
2125+
``libmpdec`` uses `Karatsuba multiplication
2126+
<https://en.wikipedia.org/wiki/Karatsuba_algorithm>`_
2127+
for medium-sized numbers and the `Number Theoretic Transform
2128+
<https://en.wikipedia.org/wiki/Discrete_Fourier_transform_(general)#Number-theoretic_transform>`_
2129+
for very large numbers. However, to realize this performance gain, the
2130+
context needs to be set for unrounded calculations.
2131+
2132+
>>> c = getcontext()
2133+
>>> c.prec = MAX_PREC
2134+
>>> c.Emax = MAX_EMAX
2135+
>>> c.Emin = MIN_EMIN
2136+
2137+
.. versionadded:: 3.3

Doc/library/http.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ Code Enum Name Details
9696
``413`` ``REQUEST_ENTITY_TOO_LARGE`` HTTP/1.1 :rfc:`7231`, Section 6.5.11
9797
``414`` ``REQUEST_URI_TOO_LONG`` HTTP/1.1 :rfc:`7231`, Section 6.5.12
9898
``415`` ``UNSUPPORTED_MEDIA_TYPE`` HTTP/1.1 :rfc:`7231`, Section 6.5.13
99-
``416`` ``REQUEST_RANGE_NOT_SATISFIABLE`` HTTP/1.1 Range Requests :rfc:`7233`, Section 4.4
99+
``416`` ``REQUESTED_RANGE_NOT_SATISFIABLE`` HTTP/1.1 Range Requests :rfc:`7233`, Section 4.4
100100
``417`` ``EXPECTATION_FAILED`` HTTP/1.1 :rfc:`7231`, Section 6.5.14
101101
``421`` ``MISDIRECTED_REQUEST`` HTTP/2 :rfc:`7540`, Section 9.1.2
102102
``422`` ``UNPROCESSABLE_ENTITY`` WebDAV :rfc:`4918`, Section 11.2

Doc/library/idle.rst

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -716,14 +716,33 @@ In contrast, some system text windows only keep the last n lines of output.
716716
A Windows console, for instance, keeps a user-settable 1 to 9999 lines,
717717
with 300 the default.
718718

719-
Text widgets display a subset of Unicode, the Basic Multilingual Plane (BMP).
720-
Which characters get a proper glyph instead of a replacement box depends on
721-
the operating system and installed fonts. Newline characters cause following
722-
text to appear on a new line, but other control characters are either
723-
replaced with a box or deleted. However, ``repr()``, which is used for
724-
interactive echo of expression values, replaces control characters,
725-
some BMP codepoints, and all non-BMP characters with escape codes
726-
before they are output.
719+
A Tk Text widget, and hence IDLE's Shell, displays characters (codepoints)
720+
in the the BMP (Basic Multilingual Plane) subset of Unicode.
721+
Which characters are displayed with a proper glyph and which with a
722+
replacement box depends on the operating system and installed fonts.
723+
Tab characters cause the following text to begin after
724+
the next tab stop. (They occur every 8 'characters').
725+
Newline characters cause following text to appear on a new line.
726+
Other control characters are ignored or displayed as a space, box, or
727+
something else, depending on the operating system and font.
728+
(Moving the text cursor through such output with arrow keys may exhibit
729+
some surprising spacing behavior.)
730+
731+
.. code-block:: none
732+
733+
>>> s = 'a\tb\a<\x02><\r>\bc\nd'
734+
>>> len(s)
735+
14
736+
>>> s # Display repr(s)
737+
'a\tb\x07<\x02><\r>\x08c\nd'
738+
>>> print(s, end='') # Display s as is.
739+
# Result varies by OS and font. Try it.
740+
741+
The ``repr`` function is used for interactive echo of expression
742+
values. It returns an altered version of the input string in which
743+
control codes, some BMP codepoints, and all non-BMP codepoints are
744+
replaced with escape codes. As demonstrated above, it allows one to
745+
identify the characters in a string, regardless of how they are displayed.
727746

728747
Normal and error output are generally kept separate (on separate lines)
729748
from code input and each other. They each get different highlight colors.

Doc/library/math.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,18 @@ Number-theoretic and representation functions
178178
of *x* and are floats.
179179

180180

181+
.. function:: prod(iterable, *, start=1)
182+
183+
Calculate the product of all the elements in the input *iterable*.
184+
The default *start* value for the product is ``1``.
185+
186+
When the iterable is empty, return the start value. This function is
187+
intended specifically for use with numeric values and may reject
188+
non-numeric types.
189+
190+
.. versionadded:: 3.8
191+
192+
181193
.. function:: remainder(x, y)
182194

183195
Return the IEEE 754-style remainder of *x* with respect to *y*. For

0 commit comments

Comments
 (0)