Skip to content

Commit f49055d

Browse files
authored
Merge branch 'master' into die-idna-die
2 parents de8cdfc + b838cc3 commit f49055d

File tree

340 files changed

+8387
-4326
lines changed

Some content is hidden

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

340 files changed

+8387
-4326
lines changed

.github/CODE_OF_CONDUCT.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Code of Conduct
2+
===============
3+
4+
Please note that all interactions on
5+
`Python Software Foundation <https://www.python.org/psf-landing/>`__-supported
6+
infrastructure is `covered
7+
<https://www.python.org/psf/records/board/minutes/2014-01-06/#management-of-the-psfs-web-properties>`__
8+
by the `PSF Code of Conduct <https://www.python.org/psf/codeofconduct/>`__,
9+
which includes all infrastructure used in the development of Python itself
10+
(e.g. mailing lists, issue trackers, GitHub, etc.).
11+
12+
In general this means everyone is expected to be open, considerate, and
13+
respectful of others no matter what their position is within the project.
14+

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ script:
9191
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./python Tools/scripts/patchcheck.py --travis $TRAVIS_PULL_REQUEST; fi
9292
# `-r -w` implicitly provided through `make buildbottest`.
9393
- make buildbottest TESTOPTS="-j4 -uall,-cpu"
94+
# Check that all symbols exported by libpython start with "Py" or "_Py"
95+
- make smelly
9496

9597
notifications:
9698
email: false

Doc/c-api/init.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1246,7 +1246,7 @@ CPython interpreter. This API uses a new type :c:type:`Py_tss_t` instead of
12461246
12471247
.. c:macro:: Py_tss_NEEDS_INIT
12481248
1249-
This macro expands to the default value for :c:type:`Py_tss_t` variables.
1249+
This macro expands to the initializer for :c:type:`Py_tss_t` variables.
12501250
Note that this macro won't be defined with :ref:`Py_LIMITED_API <stable>`.
12511251
12521252

Doc/c-api/memory.rst

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ The default raw memory block allocator uses the following functions:
150150
151151
Frees the memory block pointed to by *p*, which must have been returned by a
152152
previous call to :c:func:`PyMem_RawMalloc`, :c:func:`PyMem_RawRealloc` or
153-
:c:func:`PyMem_RawCalloc`. Otherwise, or if ``PyMem_Free(p)`` has been
153+
:c:func:`PyMem_RawCalloc`. Otherwise, or if ``PyMem_RawFree(p)`` has been
154154
called before, undefined behavior occurs.
155155
156156
If *p* is *NULL*, no operation is performed.
@@ -263,6 +263,69 @@ versions and is therefore deprecated in extension modules.
263263
* ``PyMem_DEL(ptr)``
264264
265265
266+
Object allocators
267+
=================
268+
269+
The following function sets, modeled after the ANSI C standard, but specifying
270+
behavior when requesting zero bytes, are available for allocating and releasing
271+
memory from the Python heap.
272+
273+
By default, these functions use :ref:`pymalloc memory allocator <pymalloc>`.
274+
275+
.. warning::
276+
277+
The :term:`GIL <global interpreter lock>` must be held when using these
278+
functions.
279+
280+
.. c:function:: void* PyObject_Malloc(size_t n)
281+
282+
Allocates *n* bytes and returns a pointer of type :c:type:`void\*` to the
283+
allocated memory, or *NULL* if the request fails.
284+
285+
Requesting zero bytes returns a distinct non-*NULL* pointer if possible, as
286+
if ``PyObject_Malloc(1)`` had been called instead. The memory will not have
287+
been initialized in any way.
288+
289+
290+
.. c:function:: void* PyObject_Calloc(size_t nelem, size_t elsize)
291+
292+
Allocates *nelem* elements each whose size in bytes is *elsize* and returns
293+
a pointer of type :c:type:`void\*` to the allocated memory, or *NULL* if the
294+
request fails. The memory is initialized to zeros.
295+
296+
Requesting zero elements or elements of size zero bytes returns a distinct
297+
non-*NULL* pointer if possible, as if ``PyObject_Calloc(1, 1)`` had been called
298+
instead.
299+
300+
.. versionadded:: 3.5
301+
302+
303+
.. c:function:: void* PyObject_Realloc(void *p, size_t n)
304+
305+
Resizes the memory block pointed to by *p* to *n* bytes. The contents will be
306+
unchanged to the minimum of the old and the new sizes.
307+
308+
If *p* is *NULL*, the call is equivalent to ``PyObject_Malloc(n)``; else if *n*
309+
is equal to zero, the memory block is resized but is not freed, and the
310+
returned pointer is non-*NULL*.
311+
312+
Unless *p* is *NULL*, it must have been returned by a previous call to
313+
:c:func:`PyObject_Malloc`, :c:func:`PyObject_Realloc` or :c:func:`PyObject_Calloc`.
314+
315+
If the request fails, :c:func:`PyObject_Realloc` returns *NULL* and *p* remains
316+
a valid pointer to the previous memory area.
317+
318+
319+
.. c:function:: void PyObject_Free(void *p)
320+
321+
Frees the memory block pointed to by *p*, which must have been returned by a
322+
previous call to :c:func:`PyObject_Malloc`, :c:func:`PyObject_Realloc` or
323+
:c:func:`PyObject_Calloc`. Otherwise, or if ``PyObject_Free(p)`` has been called
324+
before, undefined behavior occurs.
325+
326+
If *p* is *NULL*, no operation is performed.
327+
328+
266329
Customize Memory Allocators
267330
===========================
268331

Doc/c-api/typeobj.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,22 @@ type objects) *must* have the :attr:`ob_size` field.
623623
| :const:`Py_GE` | ``>=`` |
624624
+----------------+------------+
625625

626+
The following macro is defined to ease writing rich comparison functions:
627+
628+
.. c:function:: PyObject *Py_RETURN_RICHCOMPARE(VAL_A, VAL_B, int op)
629+
630+
Return ``Py_True`` or ``Py_False`` from the function, depending on the
631+
result of a comparison.
632+
VAL_A and VAL_B must be orderable by C comparison operators (for example,
633+
they may be C ints or floats). The third argument specifies the requested
634+
operation, as for :c:func:`PyObject_RichCompare`.
635+
636+
The return value's reference count is properly incremented.
637+
638+
On error, sets an exception and returns NULL from the function.
639+
640+
.. versionadded:: 3.7
641+
626642
627643
.. c:member:: Py_ssize_t PyTypeObject.tp_weaklistoffset
628644

Doc/library/asyncio-eventloop.rst

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,10 @@ Creating connections
341341

342342
.. coroutinemethod:: AbstractEventLoop.create_datagram_endpoint(protocol_factory, local_addr=None, remote_addr=None, \*, family=0, proto=0, flags=0, reuse_address=None, reuse_port=None, allow_broadcast=None, sock=None)
343343

344-
Create datagram connection: socket family :py:data:`~socket.AF_INET` or
345-
:py:data:`~socket.AF_INET6` depending on *host* (or *family* if specified),
346-
socket type :py:data:`~socket.SOCK_DGRAM`. *protocol_factory* must be a
344+
Create datagram connection: socket family :py:data:`~socket.AF_INET`,
345+
:py:data:`~socket.AF_INET6` or :py:data:`~socket.AF_UNIX` depending on
346+
*host* (or *family* if specified), socket type
347+
:py:data:`~socket.SOCK_DGRAM`. *protocol_factory* must be a
347348
callable returning a :ref:`protocol <asyncio-protocol>` instance.
348349

349350
This method is a :ref:`coroutine <coroutine>` which will try to
@@ -554,6 +555,21 @@ Low-level socket operations
554555

555556
This method is a :ref:`coroutine <coroutine>`.
556557

558+
.. coroutinemethod:: AbstractEventLoop.sock_recv_into(sock, buf)
559+
560+
Receive data from the socket. Modeled after blocking
561+
:meth:`socket.socket.recv_into` method.
562+
563+
The received data is written into *buf* (a writable buffer).
564+
The return value is the number of bytes written.
565+
566+
With :class:`SelectorEventLoop` event loop, the socket *sock* must be
567+
non-blocking.
568+
569+
This method is a :ref:`coroutine <coroutine>`.
570+
571+
.. versionadded:: 3.7
572+
557573
.. coroutinemethod:: AbstractEventLoop.sock_sendall(sock, data)
558574

559575
Send data to the socket. Modeled after blocking

Doc/library/calendar.rst

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ the week to Sunday (6) or to any other weekday. Parameters that specify dates
1919
are given as integers. For related
2020
functionality, see also the :mod:`datetime` and :mod:`time` modules.
2121

22-
Most of these functions and classes rely on the :mod:`datetime` module which
23-
uses an idealized calendar, the current Gregorian calendar extended
22+
The functions and classes defined in this module
23+
use an idealized calendar, the current Gregorian calendar extended indefinitely
2424
in both directions. This matches the definition of the "proleptic Gregorian"
2525
calendar in Dershowitz and Reingold's book "Calendrical Calculations", where
26-
it's the base calendar for all computations.
26+
it's the base calendar for all computations. Zero and negative years are
27+
interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is
28+
2 BC, and so on.
2729

2830

2931
.. class:: Calendar(firstweekday=0)
@@ -53,17 +55,40 @@ it's the base calendar for all computations.
5355
month that are required to get a complete week.
5456

5557

58+
.. method:: itermonthdays(year, month)
59+
60+
Return an iterator for the month *month* in the year *year* similar to
61+
:meth:`itermonthdates`, but not restricted by the :class:`datetime.date`
62+
range. Days returned will simply be day of the month numbers. For the
63+
days outside of the specified month, the day number is ``0``.
64+
65+
5666
.. method:: itermonthdays2(year, month)
5767

5868
Return an iterator for the month *month* in the year *year* similar to
59-
:meth:`itermonthdates`. Days returned will be tuples consisting of a day
69+
:meth:`itermonthdates`, but not restricted by the :class:`datetime.date`
70+
range. Days returned will be tuples consisting of a day of the month
6071
number and a week day number.
6172

6273

63-
.. method:: itermonthdays(year, month)
74+
.. method:: itermonthdays3(year, month)
75+
76+
Return an iterator for the month *month* in the year *year* similar to
77+
:meth:`itermonthdates`, but not restricted by the :class:`datetime.date`
78+
range. Days returned will be tuples consisting of a year, a month and a day
79+
of the month numbers.
80+
81+
.. versionadded:: 3.7
82+
83+
84+
.. method:: itermonthdays4(year, month)
6485

6586
Return an iterator for the month *month* in the year *year* similar to
66-
:meth:`itermonthdates`. Days returned will simply be day numbers.
87+
:meth:`itermonthdates`, but not restricted by the :class:`datetime.date`
88+
range. Days returned will be tuples consisting of a year, a month, a day
89+
of the month, and a day of the week numbers.
90+
91+
.. versionadded:: 3.7
6792

6893

6994
.. method:: monthdatescalendar(year, month)

Doc/library/configparser.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,8 @@ ConfigParser Objects
995995
Attempt to read and parse a list of filenames, returning a list of
996996
filenames which were successfully parsed.
997997

998-
If *filenames* is a string or :term:`path-like object`, it is treated as
998+
If *filenames* is a string, a :class:`bytes` object or a
999+
:term:`path-like object`, it is treated as
9991000
a single filename. If a file named in *filenames* cannot be opened, that
10001001
file will be ignored. This is designed so that you can specify a list of
10011002
potential configuration file locations (for example, the current
@@ -1022,6 +1023,9 @@ ConfigParser Objects
10221023
.. versionadded:: 3.6.1
10231024
The *filenames* parameter accepts a :term:`path-like object`.
10241025

1026+
.. versionadded:: 3.7
1027+
The *filenames* parameter accepts a :class:`bytes` object.
1028+
10251029

10261030
.. method:: read_file(f, source=None)
10271031

Doc/library/crypt.rst

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,24 @@ are available on all platforms):
4141
.. data:: METHOD_SHA512
4242

4343
A Modular Crypt Format method with 16 character salt and 86 character
44-
hash. This is the strongest method.
44+
hash based on the SHA-512 hash function. This is the strongest method.
4545

4646
.. data:: METHOD_SHA256
4747

4848
Another Modular Crypt Format method with 16 character salt and 43
49-
character hash.
49+
character hash based on the SHA-256 hash function.
50+
51+
.. data:: METHOD_BLOWFISH
52+
53+
Another Modular Crypt Format method with 22 character salt and 31
54+
character hash based on the Blowfish cipher.
55+
56+
.. versionadded:: 3.7
5057

5158
.. data:: METHOD_MD5
5259

5360
Another Modular Crypt Format method with 8 character salt and 22
54-
character hash.
61+
character hash based on the MD5 hash function.
5562

5663
.. data:: METHOD_CRYPT
5764

@@ -109,19 +116,25 @@ The :mod:`crypt` module defines the following functions:
109116
Accept ``crypt.METHOD_*`` values in addition to strings for *salt*.
110117

111118

112-
.. function:: mksalt(method=None)
119+
.. function:: mksalt(method=None, *, log_rounds=12)
113120

114121
Return a randomly generated salt of the specified method. If no
115122
*method* is given, the strongest method available as returned by
116123
:func:`methods` is used.
117124

118-
The return value is a string either of 2 characters in length for
119-
``crypt.METHOD_CRYPT``, or 19 characters starting with ``$digit$`` and
120-
16 random characters from the set ``[./a-zA-Z0-9]``, suitable for
121-
passing as the *salt* argument to :func:`crypt`.
125+
The return value is a string suitable for passing as the *salt* argument
126+
to :func:`crypt`.
127+
128+
*log_rounds* specifies the binary logarithm of the number of rounds
129+
for ``crypt.METHOD_BLOWFISH``, and is ignored otherwise. ``8`` specifies
130+
``256`` rounds.
122131

123132
.. versionadded:: 3.3
124133

134+
.. versionchanged:: 3.7
135+
Added the *log_rounds* parameter.
136+
137+
125138
Examples
126139
--------
127140

Doc/library/csv.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ The :mod:`csv` module defines the following classes:
172172
A short usage example::
173173

174174
>>> import csv
175-
>>> with open('names.csv') as csvfile:
175+
>>> with open('names.csv', newline='') as csvfile:
176176
... reader = csv.DictReader(csvfile)
177177
... for row in reader:
178178
... print(row['first_name'], row['last_name'])
@@ -211,7 +211,7 @@ The :mod:`csv` module defines the following classes:
211211

212212
import csv
213213

214-
with open('names.csv', 'w') as csvfile:
214+
with open('names.csv', 'w', newline='') as csvfile:
215215
fieldnames = ['first_name', 'last_name']
216216
writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
217217

@@ -270,7 +270,7 @@ The :mod:`csv` module defines the following classes:
270270

271271
An example for :class:`Sniffer` use::
272272

273-
with open('example.csv') as csvfile:
273+
with open('example.csv', newline='') as csvfile:
274274
dialect = csv.Sniffer().sniff(csvfile.read(1024))
275275
csvfile.seek(0)
276276
reader = csv.reader(csvfile, dialect)

0 commit comments

Comments
 (0)