blob: 73c851dc93e0ce5b8b081c83d09087eacbd8964e [file] [log] [blame]
Zachary Ware569db2c2015-05-22 11:42:20 -05001****************************
Victor Stinner01adf062014-03-18 00:53:32 +01002 What's New In Python 3.5
3****************************
4
Yury Selivanov7b76bae2015-09-12 17:53:33 -04005:Editors: Elvis Pranskevichus <elvis@magic.io>, Yury Selivanov <yury@magic.io>
Yury Selivanovdfcfe132015-09-08 15:33:15 -04006
Victor Stinner01adf062014-03-18 00:53:32 +01007.. Rules for maintenance:
8
9 * Anyone can add text to this document. Do not spend very much time
10 on the wording of your changes, because your text will probably
11 get rewritten to some degree.
12
13 * The maintainer will go through Misc/NEWS periodically and add
14 changes; it's therefore more important to add your changes to
15 Misc/NEWS than to this file.
16
17 * This is not a complete list of every single change; completeness
18 is the purpose of Misc/NEWS. Some changes I consider too small
19 or esoteric to include. If such a change is added to the text,
20 I'll just remove it. (This is another reason you shouldn't spend
21 too much time on writing your addition.)
22
23 * If you want to draw your new text to the attention of the
24 maintainer, add 'XXX' to the beginning of the paragraph or
25 section.
26
27 * It's OK to just add a fragmentary note about a change. For
28 example: "XXX Describe the transmogrify() function added to the
29 socket module." The maintainer will research the change and
30 write the necessary text.
31
32 * You can comment out your additions if you like, but it's not
33 necessary (especially when a final release is some months away).
34
35 * Credit the author of a patch or bugfix. Just the name is
36 sufficient; the e-mail address isn't necessary.
37
38 * It's helpful to add the bug/patch number as a comment:
39
40 XXX Describe the transmogrify() function added to the socket
41 module.
42 (Contributed by P.Y. Developer in :issue:`12345`.)
43
44 This saves the maintainer the effort of going through the Mercurial log
45 when researching a change.
46
47This article explains the new features in Python 3.5, compared to 3.4.
Yury Selivanov69a15f12015-09-13 11:52:07 -040048Python 3.5 was released on September 13, 2015.  See the
Yury Selivanov801306b2015-09-13 11:40:00 -040049`changelog <https://docs.python.org/3.5/whatsnew/changelog.html>`_ for a full
50list of changes.
Victor Stinner01adf062014-03-18 00:53:32 +010051
52.. seealso::
53
Berker Peksagfa0423b2014-10-09 11:38:19 +030054 :pep:`478` - Python 3.5 Release Schedule
Victor Stinner01adf062014-03-18 00:53:32 +010055
56
57Summary -- Release highlights
58=============================
59
Victor Stinner01adf062014-03-18 00:53:32 +010060New syntax features:
61
Yury Selivanova33cb352015-09-13 11:21:25 -040062* :ref:`PEP 492 <whatsnew-pep-492>`, coroutines with async and await syntax.
63* :ref:`PEP 465 <whatsnew-pep-465>`, a new matrix multiplication operator: ``a @ b``.
64* :ref:`PEP 448 <whatsnew-pep-448>`, additional unpacking generalizations.
Victor Stinner01adf062014-03-18 00:53:32 +010065
Yury Selivanov95fd26b2015-09-12 17:50:58 -040066
Victor Stinner01adf062014-03-18 00:53:32 +010067New library modules:
68
Yury Selivanova33cb352015-09-13 11:21:25 -040069* :mod:`typing`: :ref:`PEP 484 -- Type Hints <whatsnew-pep-484>`.
70* :mod:`zipapp`: :ref:`PEP 441 Improving Python ZIP Application Support
71 <whatsnew-zipapp>`.
Victor Stinner01adf062014-03-18 00:53:32 +010072
Yury Selivanov95fd26b2015-09-12 17:50:58 -040073
Victor Stinner01adf062014-03-18 00:53:32 +010074New built-in features:
75
Yury Selivanova33cb352015-09-13 11:21:25 -040076* ``bytes % args``, ``bytearray % args``: :ref:`PEP 461 <whatsnew-pep-461>` --
77 Adding ``%`` formatting to bytes and bytearray.
Yury Selivanov40301c02015-09-08 23:28:06 -040078
Yury Selivanov8e3b04c2015-09-16 12:18:29 -040079* New :meth:`bytes.hex`, :meth:`bytearray.hex` and :meth:`memoryview.hex`
80 methods. (Contributed by Arnon Yaari in :issue:`9951`.)
Yury Selivanov40301c02015-09-08 23:28:06 -040081
Yury Selivanova33cb352015-09-13 11:21:25 -040082* :class:`memoryview` now supports tuple indexing (including multi-dimensional).
Yury Selivanov4dde5872015-09-11 00:48:21 -040083 (Contributed by Antoine Pitrou in :issue:`23632`.)
84
Yury Selivanova33cb352015-09-13 11:21:25 -040085* Generators have a new ``gi_yieldfrom`` attribute, which returns the
Yury Selivanove13f8f32015-07-03 00:23:30 -040086 object being iterated by ``yield from`` expressions. (Contributed
87 by Benno Leslie and Yury Selivanov in :issue:`24450`.)
Yury Selivanov40301c02015-09-08 23:28:06 -040088
Yury Selivanova33cb352015-09-13 11:21:25 -040089* A new :exc:`RecursionError` exception is now raised when maximum
90 recursion depth is reached. (Contributed by Georg Brandl
Yury Selivanovf488fb42015-07-03 01:04:23 -040091 in :issue:`19235`.)
Victor Stinner01adf062014-03-18 00:53:32 +010092
Yury Selivanov95fd26b2015-09-12 17:50:58 -040093
Yury Selivanovce917c7312015-09-10 17:35:38 -040094CPython implementation improvements:
Victor Stinner01adf062014-03-18 00:53:32 +010095
Victor Stinner71430292014-03-18 01:18:21 +010096* When the ``LC_TYPE`` locale is the POSIX locale (``C`` locale),
Yury Selivanova33cb352015-09-13 11:21:25 -040097 :py:data:`sys.stdin` and :py:data:`sys.stdout` now use the
Serhiy Storchaka1c30e7e2015-09-11 20:55:28 +030098 ``surrogateescape`` error handler, instead of the ``strict`` error handler.
99 (Contributed by Victor Stinner in :issue:`19977`.)
Victor Stinner01adf062014-03-18 00:53:32 +0100100
Yury Selivanovce917c7312015-09-10 17:35:38 -0400101* ``.pyo`` files are no longer used and have been replaced by a more flexible
Yury Selivanova33cb352015-09-13 11:21:25 -0400102 scheme that includes the optimization level explicitly in ``.pyc`` name.
103 (See :ref:`PEP 488 overview <whatsnew-pep-488>`.)
Yury Selivanov40301c02015-09-08 23:28:06 -0400104
Yury Selivanovce917c7312015-09-10 17:35:38 -0400105* Builtin and extension modules are now initialized in a multi-phase process,
Yury Selivanova33cb352015-09-13 11:21:25 -0400106 which is similar to how Python modules are loaded.
107 (See :ref:`PEP 489 overview <whatsnew-pep-489>`.)
Brett Cannonf299abd2015-04-13 14:21:02 -0400108
Victor Stinner01adf062014-03-18 00:53:32 +0100109
Yury Selivanova33cb352015-09-13 11:21:25 -0400110Significant improvements in the standard library:
Yury Selivanov58444362015-05-30 10:49:09 -0400111
Yury Selivanov95fd26b2015-09-12 17:50:58 -0400112* :class:`collections.OrderedDict` is now
113 :ref:`implemented in C <whatsnew-ordereddict>`, which makes it
114 4 to 100 times faster.
Victor Stinner01adf062014-03-18 00:53:32 +0100115
Martin Panter97ce0fa2015-11-14 01:14:54 +0000116* The :mod:`ssl` module gained
Yury Selivanov95fd26b2015-09-12 17:50:58 -0400117 :ref:`support for Memory BIO <whatsnew-sslmemorybio>`, which decouples SSL
118 protocol handling from network IO.
Yury Selivanov7d6adab2015-08-05 19:01:51 -0400119
Yury Selivanov95fd26b2015-09-12 17:50:58 -0400120* The new :func:`os.scandir` function provides a
121 :ref:`better and significantly faster way <whatsnew-pep-471>`
122 of directory traversal.
123
Yury Selivanova33cb352015-09-13 11:21:25 -0400124* :func:`functools.lru_cache` has been mostly
Yury Selivanov95fd26b2015-09-12 17:50:58 -0400125 :ref:`reimplemented in C <whatsnew-lrucache>`, yielding much better
126 performance.
127
128* The new :func:`subprocess.run` function provides a
129 :ref:`streamlined way to run subprocesses <whatsnew-subprocess>`.
130
Yury Selivanova33cb352015-09-13 11:21:25 -0400131* The :mod:`traceback` module has been significantly
Yury Selivanovfe369a62015-09-13 08:29:19 -0400132 :ref:`enhanced <whatsnew-traceback>` for improved
133 performance and developer convenience.
134
Yury Selivanov336b37b2015-09-09 12:23:01 -0400135
Victor Stinner01adf062014-03-18 00:53:32 +0100136Security improvements:
137
Yury Selivanov100fc3f2015-09-08 22:40:30 -0400138* SSLv3 is now disabled throughout the standard library.
139 It can still be enabled by instantiating a :class:`ssl.SSLContext`
140 manually. (See :issue:`22638` for more details; this change was
141 backported to CPython 3.4 and 2.7.)
142
143* HTTP cookie parsing is now stricter, in order to protect
144 against potential injection attacks. (Contributed by Antoine Pitrou
145 in :issue:`22796`.)
Victor Stinner01adf062014-03-18 00:53:32 +0100146
Yury Selivanov95fd26b2015-09-12 17:50:58 -0400147
Steve Dower313fbf42015-07-17 16:48:48 -0700148Windows improvements:
149
Yury Selivanovce917c7312015-09-10 17:35:38 -0400150* A new installer for Windows has replaced the old MSI.
151 See :ref:`using-on-windows` for more information.
Yury Selivanov40301c02015-09-08 23:28:06 -0400152
Steve Dower313fbf42015-07-17 16:48:48 -0700153* Windows builds now use Microsoft Visual C++ 14.0, and extension modules
154 should use the same.
155
Yury Selivanov95fd26b2015-09-12 17:50:58 -0400156
Yury Selivanov0ac5f282015-09-08 23:40:46 -0400157Please read on for a comprehensive list of user-facing changes, including many
158other smaller improvements, CPython optimizations, deprecations, and potential
159porting issues.
Victor Stinner01adf062014-03-18 00:53:32 +0100160
161
Yury Selivanovdfcfe132015-09-08 15:33:15 -0400162New Features
163============
164
165.. _whatsnew-pep-492:
166
Yury Selivanovf3e40fa2015-05-21 11:50:30 -0400167PEP 492 - Coroutines with async and await syntax
168------------------------------------------------
169
Yury Selivanovdfcfe132015-09-08 15:33:15 -0400170:pep:`492` greatly improves support for asynchronous programming in Python
171by adding :term:`awaitable objects <awaitable>`,
172:term:`coroutine functions <coroutine function>`,
173:term:`asynchronous iteration <asynchronous iterable>`,
174and :term:`asynchronous context managers <asynchronous context manager>`.
Yury Selivanovf3e40fa2015-05-21 11:50:30 -0400175
Yury Selivanovdfcfe132015-09-08 15:33:15 -0400176Coroutine functions are declared using the new :keyword:`async def` syntax::
Yury Selivanovf3e40fa2015-05-21 11:50:30 -0400177
Yury Selivanovdfcfe132015-09-08 15:33:15 -0400178 >>> async def coro():
179 ... return 'spam'
Yury Selivanovf3e40fa2015-05-21 11:50:30 -0400180
Yury Selivanova88cd642015-09-10 21:26:54 -0400181Inside a coroutine function, the new :keyword:`await` expression can be used
Yury Selivanovdfcfe132015-09-08 15:33:15 -0400182to suspend coroutine execution until the result is available. Any object
183can be *awaited*, as long as it implements the :term:`awaitable` protocol by
184defining the :meth:`__await__` method.
185
186PEP 492 also adds :keyword:`async for` statement for convenient iteration
187over asynchronous iterables.
188
Yury Selivanova33cb352015-09-13 11:21:25 -0400189An example of a rudimentary HTTP client written using the new syntax::
Yury Selivanovdfcfe132015-09-08 15:33:15 -0400190
191 import asyncio
192
193 async def http_get(domain):
194 reader, writer = await asyncio.open_connection(domain, 80)
195
196 writer.write(b'\r\n'.join([
197 b'GET / HTTP/1.1',
198 b'Host: %b' % domain.encode('latin-1'),
199 b'Connection: close',
200 b'', b''
201 ]))
202
203 async for line in reader:
204 print('>>>', line)
205
206 writer.close()
207
208 loop = asyncio.get_event_loop()
209 try:
210 loop.run_until_complete(http_get('example.com'))
211 finally:
212 loop.close()
213
214
215Similarly to asynchronous iteration, there is a new syntax for asynchronous
Yury Selivanov79cf1b02015-09-10 21:44:59 -0400216context managers. The following script::
Yury Selivanovdfcfe132015-09-08 15:33:15 -0400217
Yury Selivanov79cf1b02015-09-10 21:44:59 -0400218 import asyncio
219
220 async def coro(name, lock):
221 print('coro {}: waiting for lock'.format(name))
222 async with lock:
223 print('coro {}: holding the lock'.format(name))
224 await asyncio.sleep(1)
225 print('coro {}: releasing the lock'.format(name))
226
227 loop = asyncio.get_event_loop()
228 lock = asyncio.Lock()
229 coros = asyncio.gather(coro(1, lock), coro(2, lock))
230 try:
231 loop.run_until_complete(coros)
232 finally:
233 loop.close()
234
Yury Selivanov95fd26b2015-09-12 17:50:58 -0400235will output::
Yury Selivanov79cf1b02015-09-10 21:44:59 -0400236
237 coro 2: waiting for lock
238 coro 2: holding the lock
239 coro 1: waiting for lock
240 coro 2: releasing the lock
241 coro 1: holding the lock
242 coro 1: releasing the lock
Yury Selivanovdfcfe132015-09-08 15:33:15 -0400243
244Note that both :keyword:`async for` and :keyword:`async with` can only
245be used inside a coroutine function declared with :keyword:`async def`.
246
Yury Selivanova88cd642015-09-10 21:26:54 -0400247Coroutine functions are intended to be run inside a compatible event loop,
Yury Selivanova33cb352015-09-13 11:21:25 -0400248such as the :ref:`asyncio loop <asyncio-event-loop>`.
Yury Selivanovf3e40fa2015-05-21 11:50:30 -0400249
250.. seealso::
251
252 :pep:`492` -- Coroutines with async and await syntax
Yury Selivanovdfcfe132015-09-08 15:33:15 -0400253 PEP written and implemented by Yury Selivanov.
Yury Selivanovf3e40fa2015-05-21 11:50:30 -0400254
255
Yury Selivanovce917c7312015-09-10 17:35:38 -0400256.. _whatsnew-pep-465:
257
Yury Selivanovdfcfe132015-09-08 15:33:15 -0400258PEP 465 - A dedicated infix operator for matrix multiplication
259--------------------------------------------------------------
Victor Stinner93692bb2015-03-30 15:04:45 +0200260
Yury Selivanovdfcfe132015-09-08 15:33:15 -0400261:pep:`465` adds the ``@`` infix operator for matrix multiplication.
262Currently, no builtin Python types implement the new operator, however, it
263can be implemented by defining :meth:`__matmul__`, :meth:`__rmatmul__`,
264and :meth:`__imatmul__` for regular, reflected, and in-place matrix
265multiplication. The semantics of these methods is similar to that of
266methods defining other infix arithmetic operators.
267
268Matrix multiplication is a notably common operation in many fields of
269mathematics, science, engineering, and the addition of ``@`` allows writing
270cleaner code::
271
Yury Selivanov0ac5f282015-09-08 23:40:46 -0400272 S = (H @ beta - r).T @ inv(H @ V @ H.T) @ (H @ beta - r)
273
274instead of::
275
276 S = dot((dot(H, beta) - r).T,
277 dot(inv(dot(dot(H, V), H.T)), dot(H, beta) - r))
Yury Selivanovdfcfe132015-09-08 15:33:15 -0400278
Yury Selivanovf97edf12015-10-31 13:33:49 -0400279NumPy 1.10 has support for the new operator::
Yury Selivanovdfcfe132015-09-08 15:33:15 -0400280
281 >>> import numpy
282
283 >>> x = numpy.ones(3)
284 >>> x
285 array([ 1., 1., 1.])
286
287 >>> m = numpy.eye(3)
288 >>> m
289 array([[ 1., 0., 0.],
290 [ 0., 1., 0.],
291 [ 0., 0., 1.]])
292
293 >>> x @ m
294 array([ 1., 1., 1.])
295
296
297.. seealso::
298
299 :pep:`465` -- A dedicated infix operator for matrix multiplication
300 PEP written by Nathaniel J. Smith; implemented by Benjamin Peterson.
301
302
Yury Selivanovce917c7312015-09-10 17:35:38 -0400303.. _whatsnew-pep-448:
304
Yury Selivanovdfcfe132015-09-08 15:33:15 -0400305PEP 448 - Additional Unpacking Generalizations
306----------------------------------------------
307
308:pep:`448` extends the allowed uses of the ``*`` iterable unpacking
309operator and ``**`` dictionary unpacking operator. It is now possible
310to use an arbitrary number of unpackings in function calls::
311
312 >>> print(*[1], *[2], 3, *[4, 5])
313 1 2 3 4 5
314
315 >>> def fn(a, b, c, d):
316 ... print(a, b, c, d)
317 ...
318
319 >>> fn(**{'a': 1, 'c': 3}, **{'b': 2, 'd': 4})
320 1 2 3 4
321
322Similarly, tuple, list, set, and dictionary displays allow multiple
323unpackings::
324
325 >>> *range(4), 4
326 (0, 1, 2, 3, 4)
Yury Selivanov79cf1b02015-09-10 21:44:59 -0400327
Yury Selivanovdfcfe132015-09-08 15:33:15 -0400328 >>> [*range(4), 4]
329 [0, 1, 2, 3, 4]
Yury Selivanov79cf1b02015-09-10 21:44:59 -0400330
Yury Selivanovdfcfe132015-09-08 15:33:15 -0400331 >>> {*range(4), 4, *(5, 6, 7)}
332 {0, 1, 2, 3, 4, 5, 6, 7}
Yury Selivanov79cf1b02015-09-10 21:44:59 -0400333
Yury Selivanovdfcfe132015-09-08 15:33:15 -0400334 >>> {'x': 1, **{'y': 2}}
335 {'x': 1, 'y': 2}
336
337.. seealso::
338
339 :pep:`448` -- Additional Unpacking Generalizations
340 PEP written by Joshua Landau; implemented by Neil Girdhar,
341 Thomas Wouters, and Joshua Landau.
342
343
Yury Selivanovce917c7312015-09-10 17:35:38 -0400344.. _whatsnew-pep-461:
345
Yury Selivanovdfcfe132015-09-08 15:33:15 -0400346PEP 461 - % formatting support for bytes and bytearray
347------------------------------------------------------
348
Martin Panter97ce0fa2015-11-14 01:14:54 +0000349:pep:`461` adds support for the ``%``
Yury Selivanov95fd26b2015-09-12 17:50:58 -0400350:ref:`interpolation operator <bytes-formatting>` to :class:`bytes`
351and :class:`bytearray`.
352
353While interpolation is usually thought of as a string operation, there are
Yury Selivanova33cb352015-09-13 11:21:25 -0400354cases where interpolation on ``bytes`` or ``bytearrays`` makes sense, and the
Yury Selivanov95fd26b2015-09-12 17:50:58 -0400355work needed to make up for this missing functionality detracts from the
356overall readability of the code. This issue is particularly important when
357dealing with wire format protocols, which are often a mixture of binary
358and ASCII compatible text.
Victor Stinner93692bb2015-03-30 15:04:45 +0200359
360Examples::
361
Yury Selivanov95fd26b2015-09-12 17:50:58 -0400362 >>> b'Hello %b!' % b'World'
Victor Stinner93692bb2015-03-30 15:04:45 +0200363 b'Hello World!'
Yury Selivanov79cf1b02015-09-10 21:44:59 -0400364
Victor Stinner93692bb2015-03-30 15:04:45 +0200365 >>> b'x=%i y=%f' % (1, 2.5)
366 b'x=1 y=2.500000'
367
Yury Selivanov95fd26b2015-09-12 17:50:58 -0400368Unicode is not allowed for ``%b``, but it is accepted by ``%a`` (equivalent of
Victor Stinner93692bb2015-03-30 15:04:45 +0200369``repr(obj).encode('ascii', 'backslashreplace')``)::
370
Yury Selivanov95fd26b2015-09-12 17:50:58 -0400371 >>> b'Hello %b!' % 'World'
Victor Stinner93692bb2015-03-30 15:04:45 +0200372 Traceback (most recent call last):
373 File "<stdin>", line 1, in <module>
374 TypeError: %b requires bytes, or an object that implements __bytes__, not 'str'
Yury Selivanov79cf1b02015-09-10 21:44:59 -0400375
Victor Stinner93692bb2015-03-30 15:04:45 +0200376 >>> b'price: %a' % '10€'
377 b"price: '10\\u20ac'"
378
Yury Selivanov95fd26b2015-09-12 17:50:58 -0400379Note that ``%s`` and ``%r`` conversion types, although supported, should
380only be used in codebases that need compatibility with Python 2.
381
Victor Stinner93692bb2015-03-30 15:04:45 +0200382.. seealso::
383
384 :pep:`461` -- Adding % formatting to bytes and bytearray
Yury Selivanovdfcfe132015-09-08 15:33:15 -0400385 PEP written by Ethan Furman; implemented by Neil Schemenauer and
386 Ethan Furman.
Yury Selivanov216d9992015-08-04 12:42:20 -0400387
388
Yury Selivanovce917c7312015-09-10 17:35:38 -0400389.. _whatsnew-pep-484:
390
Yury Selivanov5df36af2015-08-04 12:46:57 -0400391PEP 484 - Type Hints
392--------------------
393
Yury Selivanov95fd26b2015-09-12 17:50:58 -0400394Function annotation syntax has been a Python feature since version 3.0
395(:pep:`3107`), however the semantics of annotations has been left undefined.
396
397Experience has shown that the majority of function annotation
398uses were to provide type hints to function parameters and return values. It
399became evident that it would be beneficial for Python users, if the
400standard library included the base definitions and tools for type annotations.
401
402:pep:`484` introduces a :term:`provisional module <provisional api>` to
403provide these standard definitions and tools, along with some conventions
404for situations where annotations are not available.
Yury Selivanov5df36af2015-08-04 12:46:57 -0400405
406For example, here is a simple function whose argument and return type
407are declared in the annotations::
408
Yury Selivanovdfcfe132015-09-08 15:33:15 -0400409 def greeting(name: str) -> str:
410 return 'Hello ' + name
Yury Selivanov5df36af2015-08-04 12:46:57 -0400411
Yury Selivanov95fd26b2015-09-12 17:50:58 -0400412While these annotations are available at runtime through the usual
413:attr:`__annotations__` attribute, *no automatic type checking happens at
Yury Selivanova33cb352015-09-13 11:21:25 -0400414runtime*. Instead, it is assumed that a separate off-line type checker
415(e.g. `mypy <http://mypy-lang.org>`_) will be used for on-demand
416source code analysis.
Yury Selivanov95fd26b2015-09-12 17:50:58 -0400417
Yury Selivanov5df36af2015-08-04 12:46:57 -0400418The type system supports unions, generic types, and a special type
Yury Selivanov95fd26b2015-09-12 17:50:58 -0400419named :class:`~typing.Any` which is consistent with (i.e. assignable to
420and from) all types.
Yury Selivanov5df36af2015-08-04 12:46:57 -0400421
422.. seealso::
423
Yury Selivanov40c0ce42015-08-05 12:46:29 -0400424 * :mod:`typing` module documentation
Yury Selivanovdfcfe132015-09-08 15:33:15 -0400425 * :pep:`484` -- Type Hints
426 PEP written by Guido van Rossum, Jukka Lehtosalo, and Łukasz Langa;
427 implemented by Guido van Rossum.
Yury Selivanov95fd26b2015-09-12 17:50:58 -0400428 * :pep:`483` -- The Theory of Type Hints
429 PEP written by Guido van Rossum
Yury Selivanov5df36af2015-08-04 12:46:57 -0400430
431
Yury Selivanovce917c7312015-09-10 17:35:38 -0400432.. _whatsnew-pep-471:
433
Victor Stinner6036e442015-03-08 01:58:04 +0100434PEP 471 - os.scandir() function -- a better and faster directory iterator
435-------------------------------------------------------------------------
436
Victor Stinner37f20342015-03-10 13:29:41 +0100437:pep:`471` adds a new directory iteration function, :func:`os.scandir`,
Yury Selivanovce917c7312015-09-10 17:35:38 -0400438to the standard library. Additionally, :func:`os.walk` is now
Yury Selivanov23950372015-09-12 23:46:39 -0400439implemented using ``scandir``, which makes it 3 to 5 times faster
Yury Selivanov95fd26b2015-09-12 17:50:58 -0400440on POSIX systems and 7 to 20 times faster on Windows systems. This is
441largely achieved by greatly reducing the number of calls to :func:`os.stat`
442required to walk a directory tree.
443
Yury Selivanov23950372015-09-12 23:46:39 -0400444Additionally, ``scandir`` returns an iterator, as opposed to returning
Yury Selivanov95fd26b2015-09-12 17:50:58 -0400445a list of file names, which improves memory efficiency when iterating
446over very large directories.
Victor Stinner37f20342015-03-10 13:29:41 +0100447
Yury Selivanov23950372015-09-12 23:46:39 -0400448The following example shows a simple use of :func:`os.scandir` to display all
449the files (excluding directories) in the given *path* that don't start with
Yury Selivanova33cb352015-09-13 11:21:25 -0400450``'.'``. The :meth:`entry.is_file() <os.DirEntry.is_file>` call will generally
Yury Selivanov23950372015-09-12 23:46:39 -0400451not make an additional system call::
452
453 for entry in os.scandir(path):
454 if not entry.name.startswith('.') and entry.is_file():
455 print(entry.name)
456
Victor Stinner6036e442015-03-08 01:58:04 +0100457.. seealso::
458
Yury Selivanovdfcfe132015-09-08 15:33:15 -0400459 :pep:`471` -- os.scandir() function -- a better and faster directory iterator
460 PEP written and implemented by Ben Hoyt with the help of Victor Stinner.
Victor Stinner6036e442015-03-08 01:58:04 +0100461
462
Yury Selivanovce917c7312015-09-10 17:35:38 -0400463.. _whatsnew-pep-475:
464
Charles-François Natali6e6c59b2015-02-07 13:27:50 +0000465PEP 475: Retry system calls failing with EINTR
466----------------------------------------------
467
Martin Panterd2ad5712015-11-02 04:20:33 +0000468An :py:data:`errno.EINTR` error code is returned whenever a system call, that
Yury Selivanov95fd26b2015-09-12 17:50:58 -0400469is waiting for I/O, is interrupted by a signal. Previously, Python would
Martin Panter97ce0fa2015-11-14 01:14:54 +0000470raise :exc:`InterruptedError` in such cases. This meant that, when writing a
Yury Selivanov95fd26b2015-09-12 17:50:58 -0400471Python application, the developer had two choices:
Charles-François Natali6e6c59b2015-02-07 13:27:50 +0000472
Yury Selivanov95fd26b2015-09-12 17:50:58 -0400473#. Ignore the ``InterruptedError``.
474#. Handle the ``InterruptedError`` and attempt to restart the interrupted
475 system call at every call site.
476
477The first option makes an application fail intermittently.
478The second option adds a large amount of boilerplate that makes the
479code nearly unreadable. Compare::
480
481 print("Hello World")
482
483and::
484
485 while True:
486 try:
487 print("Hello World")
488 break
489 except InterruptedError:
490 continue
491
492:pep:`475` implements automatic retry of system calls on
493``EINTR``. This removes the burden of dealing with ``EINTR``
494or :exc:`InterruptedError` in user code in most situations and makes
495Python programs, including the standard library, more robust. Note that
496the system call is only retried if the signal handler does not raise an
497exception.
498
499Below is a list of functions which are now retried when interrupted
500by a signal:
Victor Stinner6752d652015-07-29 01:11:10 +0200501
Yury Selivanova33cb352015-09-13 11:21:25 -0400502* :func:`open` and :func:`io.open`;
Victor Stinner6752d652015-07-29 01:11:10 +0200503
Yury Selivanov0ac5f282015-09-08 23:40:46 -0400504* functions of the :mod:`faulthandler` module;
Victor Stinner6752d652015-07-29 01:11:10 +0200505
Yury Selivanov0ac5f282015-09-08 23:40:46 -0400506* :mod:`os` functions: :func:`~os.fchdir`, :func:`~os.fchmod`,
507 :func:`~os.fchown`, :func:`~os.fdatasync`, :func:`~os.fstat`,
508 :func:`~os.fstatvfs`, :func:`~os.fsync`, :func:`~os.ftruncate`,
Yury Selivanova33cb352015-09-13 11:21:25 -0400509 :func:`~os.mkfifo`, :func:`~os.mknod`, :func:`~os.open`,
510 :func:`~os.posix_fadvise`, :func:`~os.posix_fallocate`, :func:`~os.pread`,
511 :func:`~os.pwrite`, :func:`~os.read`, :func:`~os.readv`, :func:`~os.sendfile`,
Yury Selivanov0ac5f282015-09-08 23:40:46 -0400512 :func:`~os.wait3`, :func:`~os.wait4`, :func:`~os.wait`,
513 :func:`~os.waitid`, :func:`~os.waitpid`, :func:`~os.write`,
514 :func:`~os.writev`;
Victor Stinner6752d652015-07-29 01:11:10 +0200515
Yury Selivanov0ac5f282015-09-08 23:40:46 -0400516* special cases: :func:`os.close` and :func:`os.dup2` now ignore
Martin Panter97ce0fa2015-11-14 01:14:54 +0000517 :py:data:`~errno.EINTR` errors; the syscall is not retried (see the PEP
Yury Selivanov0ac5f282015-09-08 23:40:46 -0400518 for the rationale);
Victor Stinner6752d652015-07-29 01:11:10 +0200519
Yury Selivanova33cb352015-09-13 11:21:25 -0400520* :mod:`select` functions: :func:`devpoll.poll() <select.devpoll.poll>`,
521 :func:`epoll.poll() <select.epoll.poll>`,
522 :func:`kqueue.control() <select.kqueue.control>`,
523 :func:`poll.poll() <select.poll.poll>`, :func:`~select.select`;
Victor Stinner6752d652015-07-29 01:11:10 +0200524
Yury Selivanova33cb352015-09-13 11:21:25 -0400525* methods of the :class:`~socket.socket` class: :meth:`~socket.socket.accept`,
Yury Selivanov0ac5f282015-09-08 23:40:46 -0400526 :meth:`~socket.socket.connect` (except for non-blocking sockets),
Yury Selivanov336b37b2015-09-09 12:23:01 -0400527 :meth:`~socket.socket.recv`, :meth:`~socket.socket.recvfrom`,
528 :meth:`~socket.socket.recvmsg`, :meth:`~socket.socket.send`,
529 :meth:`~socket.socket.sendall`, :meth:`~socket.socket.sendmsg`,
Yury Selivanov0ac5f282015-09-08 23:40:46 -0400530 :meth:`~socket.socket.sendto`;
Victor Stinner6752d652015-07-29 01:11:10 +0200531
Yury Selivanova33cb352015-09-13 11:21:25 -0400532* :func:`signal.sigtimedwait` and :func:`signal.sigwaitinfo`;
Yury Selivanov0ac5f282015-09-08 23:40:46 -0400533
534* :func:`time.sleep`.
Victor Stinner6752d652015-07-29 01:11:10 +0200535
Charles-François Natali6e6c59b2015-02-07 13:27:50 +0000536.. seealso::
537
538 :pep:`475` -- Retry system calls failing with EINTR
Yury Selivanovdfcfe132015-09-08 15:33:15 -0400539 PEP and implementation written by Charles-François Natali and
Yury Selivanov95fd26b2015-09-12 17:50:58 -0400540 Victor Stinner, with the help of Antoine Pitrou (the French connection).
Victor Stinner01adf062014-03-18 00:53:32 +0100541
542
Yury Selivanovce917c7312015-09-10 17:35:38 -0400543.. _whatsnew-pep-479:
544
Yury Selivanov8d006e72015-05-22 11:30:45 -0400545PEP 479: Change StopIteration handling inside generators
546--------------------------------------------------------
547
Yury Selivanov95fd26b2015-09-12 17:50:58 -0400548The interaction of generators and :exc:`StopIteration` in Python 3.4 and
Yury Selivanova33cb352015-09-13 11:21:25 -0400549earlier was sometimes surprising, and could conceal obscure bugs. Previously,
Yury Selivanov95fd26b2015-09-12 17:50:58 -0400550``StopIteration`` raised accidentally inside a generator function was
551interpreted as the end of the iteration by the loop construct driving the
552generator.
553
554:pep:`479` changes the behavior of generators: when a ``StopIteration``
Yury Selivanov8d006e72015-05-22 11:30:45 -0400555exception is raised inside a generator, it is replaced with a
Yury Selivanov95fd26b2015-09-12 17:50:58 -0400556:exc:`RuntimeError` before it exits the generator frame. The main goal of
557this change is to ease debugging in the situation where an unguarded
558:func:`next` call raises ``StopIteration`` and causes the iteration controlled
559by the generator to terminate silently. This is particularly pernicious in
560combination with the ``yield from`` construct.
561
562This is a backwards incompatible change, so to enable the new behavior,
563a :term:`__future__` import is necessary::
Yury Selivanov8d006e72015-05-22 11:30:45 -0400564
Yury Selivanova33cb352015-09-13 11:21:25 -0400565 >>> from __future__ import generator_stop
566
567 >>> def gen():
568 ... next(iter([]))
569 ... yield
570 ...
571 >>> next(gen())
572 Traceback (most recent call last):
573 File "<stdin>", line 2, in gen
574 StopIteration
575
576 The above exception was the direct cause of the following exception:
577
578 Traceback (most recent call last):
579 File "<stdin>", line 1, in <module>
580 RuntimeError: generator raised StopIteration
Yury Selivanov8d006e72015-05-22 11:30:45 -0400581
582Without a ``__future__`` import, a :exc:`PendingDeprecationWarning` will be
Yury Selivanov95fd26b2015-09-12 17:50:58 -0400583raised whenever a ``StopIteration`` exception is raised inside a generator.
Yury Selivanov8d006e72015-05-22 11:30:45 -0400584
Yury Selivanov8d006e72015-05-22 11:30:45 -0400585.. seealso::
586
587 :pep:`479` -- Change StopIteration handling inside generators
Yury Selivanovdfcfe132015-09-08 15:33:15 -0400588 PEP written by Chris Angelico and Guido van Rossum. Implemented by
589 Chris Angelico, Yury Selivanov and Nick Coghlan.
Yury Selivanov8d006e72015-05-22 11:30:45 -0400590
591
Yury Selivanova33cb352015-09-13 11:21:25 -0400592.. _whatsnew-pep-485:
593
594PEP 485: A function for testing approximate equality
595----------------------------------------------------
596
597:pep:`485` adds the :func:`math.isclose` and :func:`cmath.isclose`
598functions which tell whether two values are approximately equal or
599"close" to each other. Whether or not two values are considered
600close is determined according to given absolute and relative tolerances.
601Relative tolerance is the maximum allowed difference between ``isclose``
602arguments, relative to the larger absolute value::
603
604 >>> import math
605 >>> a = 5.0
606 >>> b = 4.99998
607 >>> math.isclose(a, b, rel_tol=1e-5)
608 True
609 >>> math.isclose(a, b, rel_tol=1e-6)
610 False
611
612It is also possible to compare two values using absolute tolerance, which
613must be a non-negative value::
614
615 >>> import math
616 >>> a = 5.0
617 >>> b = 4.99998
618 >>> math.isclose(a, b, abs_tol=0.00003)
619 True
620 >>> math.isclose(a, b, abs_tol=0.00001)
621 False
622
623.. seealso::
624
625 :pep:`485` -- A function for testing approximate equality
626 PEP written by Christopher Barker; implemented by Chris Barker and
627 Tal Einat.
628
629
Yury Selivanovce917c7312015-09-10 17:35:38 -0400630.. _whatsnew-pep-486:
631
Steve Dower76998fe2015-02-26 14:25:33 -0800632PEP 486: Make the Python Launcher aware of virtual environments
633---------------------------------------------------------------
634
635:pep:`486` makes the Windows launcher (see :pep:`397`) aware of an active
636virtual environment. When the default interpreter would be used and the
637``VIRTUAL_ENV`` environment variable is set, the interpreter in the virtual
638environment will be used.
639
640.. seealso::
641
642 :pep:`486` -- Make the Python Launcher aware of virtual environments
Yury Selivanovdfcfe132015-09-08 15:33:15 -0400643 PEP written and implemented by Paul Moore.
Steve Dower76998fe2015-02-26 14:25:33 -0800644
Brett Cannonf299abd2015-04-13 14:21:02 -0400645
Yury Selivanovce917c7312015-09-10 17:35:38 -0400646.. _whatsnew-pep-488:
647
Brett Cannonf299abd2015-04-13 14:21:02 -0400648PEP 488: Elimination of PYO files
649---------------------------------
650
651:pep:`488` does away with the concept of ``.pyo`` files. This means that
Benjamin Petersone3283232015-05-26 21:40:28 -0500652``.pyc`` files represent both unoptimized and optimized bytecode. To prevent the
653need to constantly regenerate bytecode files, ``.pyc`` files now have an
654optional ``opt-`` tag in their name when the bytecode is optimized. This has the
655side-effect of no more bytecode file name clashes when running under either
Yury Selivanovce917c7312015-09-10 17:35:38 -0400656:option:`-O` or :option:`-OO`. Consequently, bytecode files generated from
657:option:`-O`, and :option:`-OO` may now exist simultaneously.
658:func:`importlib.util.cache_from_source` has an updated API to help with
659this change.
Brett Cannonf299abd2015-04-13 14:21:02 -0400660
661.. seealso::
662
663 :pep:`488` -- Elimination of PYO files
Yury Selivanovdfcfe132015-09-08 15:33:15 -0400664 PEP written and implemented by Brett Cannon.
Brett Cannonf299abd2015-04-13 14:21:02 -0400665
666
Yury Selivanovce917c7312015-09-10 17:35:38 -0400667.. _whatsnew-pep-489:
668
Nick Coghland5cacbb2015-05-23 22:24:10 +1000669PEP 489: Multi-phase extension module initialization
670----------------------------------------------------
671
672:pep:`489` updates extension module initialization to take advantage of the
673two step module loading mechanism introduced by :pep:`451` in Python 3.4.
674
675This change brings the import semantics of extension modules that opt-in to
676using the new mechanism much closer to those of Python source and bytecode
Nick Coghlan2ab5b092015-07-03 19:49:15 +1000677modules, including the ability to use any valid identifier as a module name,
Nick Coghland5cacbb2015-05-23 22:24:10 +1000678rather than being restricted to ASCII.
679
680.. seealso::
681
Yury Selivanovdfcfe132015-09-08 15:33:15 -0400682 :pep:`489` -- Multi-phase extension module initialization
683 PEP written by Petr Viktorin, Stefan Behnel, and Nick Coghlan;
Yury Selivanov1f4d4702015-09-09 09:27:29 -0400684 implemented by Petr Viktorin.
Yury Selivanovdfcfe132015-09-08 15:33:15 -0400685
Nick Coghland5cacbb2015-05-23 22:24:10 +1000686
Victor Stinner01adf062014-03-18 00:53:32 +0100687Other Language Changes
688======================
689
690Some smaller changes made to the core Python language are:
691
Yury Selivanov5c3111e2015-09-10 18:04:35 -0400692* Added the ``"namereplace"`` error handlers. The ``"backslashreplace"``
Yury Selivanova33cb352015-09-13 11:21:25 -0400693 error handlers now work with decoding and translating.
Serhiy Storchaka07985ef2015-01-25 22:56:57 +0200694 (Contributed by Serhiy Storchaka in :issue:`19676` and :issue:`22286`.)
Victor Stinner01adf062014-03-18 00:53:32 +0100695
Serhiy Storchaka1dd49822015-03-20 16:54:57 +0200696* The :option:`-b` option now affects comparisons of :class:`bytes` with
Serhiy Storchaka1c30e7e2015-09-11 20:55:28 +0300697 :class:`int`. (Contributed by Serhiy Storchaka in :issue:`23681`.)
Victor Stinner01adf062014-03-18 00:53:32 +0100698
Yury Selivanova33cb352015-09-13 11:21:25 -0400699* New Kazakh ``kz1048`` and Tajik ``koi8_t`` :ref:`codecs <standard-encodings>`.
700 (Contributed by Serhiy Storchaka in :issue:`22682` and :issue:`22681`.)
Serhiy Storchaka35a361f2015-09-13 12:07:54 +0300701
Raymond Hettingereac503a2015-05-13 01:09:59 -0700702* Property docstrings are now writable. This is especially useful for
703 :func:`collections.namedtuple` docstrings.
704 (Contributed by Berker Peksag in :issue:`24064`.)
705
Yury Selivanov336b37b2015-09-09 12:23:01 -0400706* Circular imports involving relative imports are now supported.
707 (Contributed by Brett Cannon and Antoine Pitrou in :issue:`17636`.)
708
Victor Stinner01adf062014-03-18 00:53:32 +0100709
710New Modules
711===========
712
Yury Selivanov23950372015-09-12 23:46:39 -0400713typing
714------
715
716The new :mod:`typing` :term:`provisional <provisional api>` module
717provides standard definitions and tools for function type annotations.
718See :ref:`Type Hints <whatsnew-pep-484>` for more information.
719
Brett Cannoncc4dfc12015-03-13 10:40:49 -0400720.. _whatsnew-zipapp:
Victor Stinner01adf062014-03-18 00:53:32 +0100721
Brett Cannoncc4dfc12015-03-13 10:40:49 -0400722zipapp
723------
724
725The new :mod:`zipapp` module (specified in :pep:`441`) provides an API and
726command line tool for creating executable Python Zip Applications, which
Yury Selivanovce917c7312015-09-10 17:35:38 -0400727were introduced in Python 2.6 in :issue:`1739468`, but which were not well
728publicized, either at the time or since.
Brett Cannoncc4dfc12015-03-13 10:40:49 -0400729
730With the new module, bundling your application is as simple as putting all
731the files, including a ``__main__.py`` file, into a directory ``myapp``
732and running::
733
734 $ python -m zipapp myapp
735 $ python myapp.pyz
Victor Stinner01adf062014-03-18 00:53:32 +0100736
Yury Selivanovce917c7312015-09-10 17:35:38 -0400737The module implementation has been contributed by Paul Moore in
738:issue:`23491`.
739
740.. seealso::
741
742 :pep:`441` -- Improving Python ZIP Application Support
743
Victor Stinner01adf062014-03-18 00:53:32 +0100744
745Improved Modules
746================
747
Berker Peksag8089cd62015-02-14 01:39:17 +0200748argparse
749--------
750
Yury Selivanov5c3111e2015-09-10 18:04:35 -0400751The :class:`~argparse.ArgumentParser` class now allows to disable
Yury Selivanovce917c7312015-09-10 17:35:38 -0400752:ref:`abbreviated usage <prefix-matching>` of long options by setting
Yury Selivanova88cd642015-09-10 21:26:54 -0400753:ref:`allow_abbrev` to ``False``. (Contributed by Jonathan Paugh,
Yury Selivanovce917c7312015-09-10 17:35:38 -0400754Steven Bethard, paul j3 and Daniel Eriksson in :issue:`14910`.)
755
Yury Selivanov336b37b2015-09-09 12:23:01 -0400756
Yury Selivanov95fd26b2015-09-12 17:50:58 -0400757asyncio
758-------
759
Martin Panter97ce0fa2015-11-14 01:14:54 +0000760Since the :mod:`asyncio` module is :term:`provisional <provisional api>`,
Yury Selivanov95fd26b2015-09-12 17:50:58 -0400761all changes introduced in Python 3.5 have also been backported to Python 3.4.x.
762
Yury Selivanova33cb352015-09-13 11:21:25 -0400763Notable changes in the :mod:`asyncio` module since Python 3.4.0:
Yury Selivanov95fd26b2015-09-12 17:50:58 -0400764
Yury Selivanova33cb352015-09-13 11:21:25 -0400765* New debugging APIs: :meth:`loop.set_debug() <asyncio.BaseEventLoop.set_debug>`
Yury Selivanov72dab132015-09-13 01:39:05 -0400766 and :meth:`loop.get_debug() <asyncio.BaseEventLoop.get_debug>` methods.
Yury Selivanov63ae9f3b2015-09-13 00:29:02 -0400767 (Contributed by Victor Stinner.)
768
Yury Selivanov95fd26b2015-09-12 17:50:58 -0400769* The proactor event loop now supports SSL.
770 (Contributed by Antoine Pitrou and Victor Stinner in :issue:`22560`.)
771
Yury Selivanov72dab132015-09-13 01:39:05 -0400772* A new :meth:`loop.is_closed() <asyncio.BaseEventLoop.is_closed>` method to
Yury Selivanov63ae9f3b2015-09-13 00:29:02 -0400773 check if the event loop is closed.
774 (Contributed by Victor Stinner in :issue:`21326`.)
775
776* A new :meth:`loop.create_task() <asyncio.BaseEventLoop.create_task>`
777 to conveniently create and schedule a new :class:`~asyncio.Task`
778 for a coroutine. The ``create_task`` method is also used by all
Yury Selivanova33cb352015-09-13 11:21:25 -0400779 asyncio functions that wrap coroutines into tasks, such as
780 :func:`asyncio.wait`, :func:`asyncio.gather`, etc.
Yury Selivanov63ae9f3b2015-09-13 00:29:02 -0400781 (Contributed by Victor Stinner.)
782
Yury Selivanova33cb352015-09-13 11:21:25 -0400783* A new :meth:`transport.get_write_buffer_limits() <asyncio.WriteTransport.get_write_buffer_limits>`
Yury Selivanov63ae9f3b2015-09-13 00:29:02 -0400784 method to inquire for *high-* and *low-* water limits of the flow
785 control.
786 (Contributed by Victor Stinner.)
787
788* The :func:`~asyncio.async` function is deprecated in favor of
789 :func:`~asyncio.ensure_future`.
790 (Contributed by Yury Selivanov.)
791
Yury Selivanov72dab132015-09-13 01:39:05 -0400792* New :meth:`loop.set_task_factory() <asyncio.BaseEventLoop.set_task_factory>`
793 and :meth:`loop.set_task_factory() <asyncio.BaseEventLoop.get_task_factory>`
794 methods to customize the task factory that
Yury Selivanov63ae9f3b2015-09-13 00:29:02 -0400795 :meth:`loop.create_task() <asyncio.BaseEventLoop.create_task>` method uses.
796 (Contributed by Yury Selivanov.)
797
Yury Selivanov72dab132015-09-13 01:39:05 -0400798* New :meth:`Queue.join() <asyncio.Queue.join>` and
799 :meth:`Queue.task_done() <asyncio.Queue.task_done>` queue methods.
Yury Selivanov63ae9f3b2015-09-13 00:29:02 -0400800 (Contributed by Victor Stinner.)
801
802* The ``JoinableQueue`` class was removed, in favor of the
803 :class:`asyncio.Queue` class.
804 (Contributed by Victor Stinner.)
805
Yury Selivanov43d71e22015-10-02 15:05:59 -0400806Updates in 3.5.1:
807
808* The :func:`~asyncio.ensure_future` function and all functions that
809 use it, such as :meth:`loop.run_until_complete() <asyncio.BaseEventLoop.run_until_complete>`,
810 now accept all kinds of :term:`awaitable objects <awaitable>`.
811 (Contributed by Yury Selivanov.)
812
Yury Selivanov95fd26b2015-09-12 17:50:58 -0400813
Yury Selivanov100fc3f2015-09-08 22:40:30 -0400814bz2
815---
816
Yury Selivanov5c3111e2015-09-10 18:04:35 -0400817The :meth:`BZ2Decompressor.decompress <bz2.BZ2Decompressor.decompress>`
818method now accepts an optional *max_length* argument to limit the maximum
819size of decompressed data. (Contributed by Nikolaus Rath in :issue:`15955`.)
Yury Selivanovce917c7312015-09-10 17:35:38 -0400820
Yury Selivanov100fc3f2015-09-08 22:40:30 -0400821
Berker Peksagbf5e9602015-02-06 10:21:37 +0200822cgi
823---
824
Serhiy Storchaka35a361f2015-09-13 12:07:54 +0300825The :class:`~cgi.FieldStorage` class now supports the :term:`context manager`
Yury Selivanov5c3111e2015-09-10 18:04:35 -0400826protocol. (Contributed by Berker Peksag in :issue:`20289`.)
Yury Selivanovce917c7312015-09-10 17:35:38 -0400827
Berker Peksagbf5e9602015-02-06 10:21:37 +0200828
Tal Einatd5519ed2015-05-31 22:05:00 +0300829cmath
830-----
831
Yury Selivanova88cd642015-09-10 21:26:54 -0400832A new function :func:`~cmath.isclose` provides a way to test for approximate
Yury Selivanova33cb352015-09-13 11:21:25 -0400833equality. (Contributed by Chris Barker and Tal Einat in :issue:`24270`.)
Tal Einatd5519ed2015-05-31 22:05:00 +0300834
835
R David Murrayc31e6222014-09-29 11:25:00 -0400836code
837----
838
Yury Selivanova33cb352015-09-13 11:21:25 -0400839The :func:`InteractiveInterpreter.showtraceback() <code.InteractiveInterpreter.showtraceback>`
Yury Selivanov5c3111e2015-09-10 18:04:35 -0400840method now prints the full chained traceback, just like the interactive
841interpreter. (Contributed by Claudiu Popa in :issue:`17442`.)
Yury Selivanovce917c7312015-09-10 17:35:38 -0400842
R David Murrayc31e6222014-09-29 11:25:00 -0400843
Raymond Hettingereac503a2015-05-13 01:09:59 -0700844collections
845-----------
846
Yury Selivanov95fd26b2015-09-12 17:50:58 -0400847.. _whatsnew-ordereddict:
848
Yury Selivanov5c3111e2015-09-10 18:04:35 -0400849The :class:`~collections.OrderedDict` class is now implemented in C, which
850makes it 4 to 100 times faster. (Contributed by Eric Snow in :issue:`16991`.)
851
Yury Selivanova33cb352015-09-13 11:21:25 -0400852:meth:`OrderedDict.items() <collections.OrderedDict.items>`,
853:meth:`OrderedDict.keys() <collections.OrderedDict.keys>`,
854:meth:`OrderedDict.values() <collections.OrderedDict.values>` views now support
Yury Selivanov508a81e2015-09-10 23:37:06 -0400855:func:`reversed` iteration.
856(Contributed by Serhiy Storchaka in :issue:`19505`.)
857
Yury Selivanov5c3111e2015-09-10 18:04:35 -0400858The :class:`~collections.deque` class now defines
859:meth:`~collections.deque.index`, :meth:`~collections.deque.insert`, and
Martin Panter97ce0fa2015-11-14 01:14:54 +0000860:meth:`~collections.deque.copy`, and supports the ``+`` and ``*`` operators.
Yury Selivanov508a81e2015-09-10 23:37:06 -0400861This allows deques to be recognized as a :class:`~collections.abc.MutableSequence`
862and improves their substitutability for lists.
Martin Panter0e5eba22015-10-31 12:18:10 +0000863(Contributed by Raymond Hettinger in :issue:`23704`.)
Yury Selivanov5c3111e2015-09-10 18:04:35 -0400864
865Docstrings produced by :func:`~collections.namedtuple` can now be updated::
Raymond Hettingereac503a2015-05-13 01:09:59 -0700866
867 Point = namedtuple('Point', ['x', 'y'])
Raymond Hettinger850be0f2015-11-09 08:24:53 -0800868 Point.__doc__ += ': Cartesian coodinate'
Raymond Hettingereac503a2015-05-13 01:09:59 -0700869 Point.x.__doc__ = 'abscissa'
870 Point.y.__doc__ = 'ordinate'
871
Yury Selivanovce917c7312015-09-10 17:35:38 -0400872(Contributed by Berker Peksag in :issue:`24064`.)
Raymond Hettingereac503a2015-05-13 01:09:59 -0700873
Martin Panter97ce0fa2015-11-14 01:14:54 +0000874The :class:`~collections.UserString` class now implements the
Yury Selivanov5c3111e2015-09-10 18:04:35 -0400875:meth:`__getnewargs__`, :meth:`__rmod__`, :meth:`~str.casefold`,
876:meth:`~str.format_map`, :meth:`~str.isprintable`, and :meth:`~str.maketrans`
Yury Selivanova33cb352015-09-13 11:21:25 -0400877methods to match the corresponding methods of :class:`str`.
Yury Selivanovce917c7312015-09-10 17:35:38 -0400878(Contributed by Joe Jevnik in :issue:`22189`.)
Yury Selivanov336b37b2015-09-09 12:23:01 -0400879
Yury Selivanov336b37b2015-09-09 12:23:01 -0400880
881collections.abc
882---------------
883
Yury Selivanova33cb352015-09-13 11:21:25 -0400884The :meth:`Sequence.index() <collections.abc.Sequence.index>` method now
Yury Selivanov46a8b402015-09-12 15:52:04 -0400885accepts *start* and *stop* arguments to match the corresponding methods
886of :class:`tuple`, :class:`list`, etc.
887(Contributed by Devin Jeanpierre in :issue:`23086`.)
888
Yury Selivanov5c3111e2015-09-10 18:04:35 -0400889A new :class:`~collections.abc.Generator` abstract base class. (Contributed
Yury Selivanovce917c7312015-09-10 17:35:38 -0400890by Stefan Behnel in :issue:`24018`.)
Yury Selivanov336b37b2015-09-09 12:23:01 -0400891
Martin Panter0e5eba22015-10-31 12:18:10 +0000892New :class:`~collections.abc.Awaitable`, :class:`~collections.abc.Coroutine`,
Yury Selivanovce917c7312015-09-10 17:35:38 -0400893:class:`~collections.abc.AsyncIterator`, and
894:class:`~collections.abc.AsyncIterable` abstract base classes.
895(Contributed by Yury Selivanov in :issue:`24184`.)
896
Yury Selivanova33cb352015-09-13 11:21:25 -0400897For earlier Python versions, a backport of the new ABCs is available in an
898external `PyPI package <https://pypi.python.org/pypi/backports_abc>`_.
899
Yury Selivanov336b37b2015-09-09 12:23:01 -0400900
Brett Cannonf1a8df02014-09-12 10:39:48 -0400901compileall
902----------
903
Serhiy Storchaka35a361f2015-09-13 12:07:54 +0300904A new :mod:`compileall` option, :samp:`-j {N}`, allows to run *N* workers
Yury Selivanov5c3111e2015-09-10 18:04:35 -0400905sumultaneously to perform parallel bytecode compilation.
906The :func:`~compileall.compile_dir` function has a corresponding ``workers``
907parameter. (Contributed by Claudiu Popa in :issue:`16104`.)
Brett Cannonf1a8df02014-09-12 10:39:48 -0400908
Yury Selivanov46a8b402015-09-12 15:52:04 -0400909Another new option, ``-r``, allows to control the maximum recursion
910level for subdirectories. (Contributed by Claudiu Popa in :issue:`19628`.)
911
Yury Selivanov5c3111e2015-09-10 18:04:35 -0400912The ``-q`` command line option can now be specified more than once, in
Yury Selivanovce917c7312015-09-10 17:35:38 -0400913which case all output, including errors, will be suppressed. The corresponding
Yury Selivanov5c3111e2015-09-10 18:04:35 -0400914``quiet`` parameter in :func:`~compileall.compile_dir`,
915:func:`~compileall.compile_file`, and :func:`~compileall.compile_path` can now
916accept an integer value indicating the level of output suppression.
Yury Selivanovce917c7312015-09-10 17:35:38 -0400917(Contributed by Thomas Kluyver in :issue:`21338`.)
918
Yury Selivanov100fc3f2015-09-08 22:40:30 -0400919
920concurrent.futures
921------------------
922
Yury Selivanova33cb352015-09-13 11:21:25 -0400923The :meth:`Executor.map() <concurrent.futures.Executor.map>` method now accepts a
Yury Selivanova88cd642015-09-10 21:26:54 -0400924*chunksize* argument to allow batching of tasks to improve performance when
925:meth:`~concurrent.futures.ProcessPoolExecutor` is used.
Yury Selivanov5c3111e2015-09-10 18:04:35 -0400926(Contributed by Dan O'Reilly in :issue:`11271`.)
Yury Selivanovce917c7312015-09-10 17:35:38 -0400927
Martin Panter97ce0fa2015-11-14 01:14:54 +0000928The number of workers in the :class:`~concurrent.futures.ThreadPoolExecutor`
929constructor is optional now. The default value is 5 times the number of CPUs.
Yury Selivanov46a8b402015-09-12 15:52:04 -0400930(Contributed by Claudiu Popa in :issue:`21527`.)
931
932
933configparser
934------------
935
Yury Selivanova33cb352015-09-13 11:21:25 -0400936:mod:`configparser` now provides a way to customize the conversion
Martin Panter97ce0fa2015-11-14 01:14:54 +0000937of values by specifying a dictionary of converters in the
Yury Selivanova33cb352015-09-13 11:21:25 -0400938:class:`~configparser.ConfigParser` constructor, or by defining them
939as methods in ``ConfigParser`` subclasses. Converters defined in
Martin Panter97ce0fa2015-11-14 01:14:54 +0000940a parser instance are inherited by its section proxies.
Yury Selivanov23950372015-09-12 23:46:39 -0400941
942Example::
943
944 >>> import configparser
945 >>> conv = {}
946 >>> conv['list'] = lambda v: [e.strip() for e in v.split() if e.strip()]
947 >>> cfg = configparser.ConfigParser(converters=conv)
948 >>> cfg.read_string("""
949 ... [s]
950 ... list = a b c d e f g
951 ... """)
952 >>> cfg.get('s', 'list')
953 'a b c d e f g'
954 >>> cfg.getlist('s', 'list')
955 ['a', 'b', 'c', 'd', 'e', 'f', 'g']
Yury Selivanova33cb352015-09-13 11:21:25 -0400956 >>> section = cfg['s']
957 >>> section.getlist('list')
958 ['a', 'b', 'c', 'd', 'e', 'f', 'g']
Yury Selivanov23950372015-09-12 23:46:39 -0400959
Yury Selivanov46a8b402015-09-12 15:52:04 -0400960(Contributed by Łukasz Langa in :issue:`18159`.)
961
Yury Selivanov100fc3f2015-09-08 22:40:30 -0400962
Berker Peksagbb44fe02014-11-28 23:28:06 +0200963contextlib
964----------
965
Serhiy Storchaka35a361f2015-09-13 12:07:54 +0300966The new :func:`~contextlib.redirect_stderr` :term:`context manager` (similar to
Yury Selivanov5c3111e2015-09-10 18:04:35 -0400967:func:`~contextlib.redirect_stdout`) makes it easier for utility scripts to
Yury Selivanovce917c7312015-09-10 17:35:38 -0400968handle inflexible APIs that write their output to :data:`sys.stderr` and
Yury Selivanov23950372015-09-12 23:46:39 -0400969don't provide any options to redirect it::
970
971 >>> import contextlib, io, logging
972 >>> f = io.StringIO()
973 >>> with contextlib.redirect_stderr(f):
974 ... logging.warning('warning')
975 ...
976 >>> f.getvalue()
977 'WARNING:root:warning\n'
978
979(Contributed by Berker Peksag in :issue:`22389`.)
Yury Selivanovce917c7312015-09-10 17:35:38 -0400980
Berker Peksagbb44fe02014-11-28 23:28:06 +0200981
Yury Selivanovfe369a62015-09-13 08:29:19 -0400982csv
983---
984
985The :meth:`~csv.csvwriter.writerow` method now supports arbitrary iterables,
986not just sequences. (Contributed by Serhiy Storchaka in :issue:`23171`.)
987
988
Steve Dowerd2bc3892015-04-15 18:06:05 -0400989curses
990------
Yury Selivanovce917c7312015-09-10 17:35:38 -0400991
Martin Panter97ce0fa2015-11-14 01:14:54 +0000992The new :func:`~curses.update_lines_cols` function updates the :envvar:`LINES`
Yury Selivanova88cd642015-09-10 21:26:54 -0400993and :envvar:`COLS` environment variables. This is useful for detecting
Martin Panter97ce0fa2015-11-14 01:14:54 +0000994manual screen resizing. (Contributed by Arnon Yaari in :issue:`4254`.)
Yury Selivanovce917c7312015-09-10 17:35:38 -0400995
Steve Dowerd2bc3892015-04-15 18:06:05 -0400996
Yury Selivanov46a8b402015-09-12 15:52:04 -0400997dbm
998---
999
1000:func:`dumb.open <dbm.dumb.open>` always creates a new database when the flag
Yury Selivanova33cb352015-09-13 11:21:25 -04001001has the value ``"n"``. (Contributed by Claudiu Popa in :issue:`18039`.)
Yury Selivanov46a8b402015-09-12 15:52:04 -04001002
1003
Berker Peksag102029d2015-03-15 01:18:47 +02001004difflib
1005-------
1006
Yury Selivanova88cd642015-09-10 21:26:54 -04001007The charset of HTML documents generated by
Yury Selivanova33cb352015-09-13 11:21:25 -04001008:meth:`HtmlDiff.make_file() <difflib.HtmlDiff.make_file>`
Yury Selivanova88cd642015-09-10 21:26:54 -04001009can now be customized by using a new *charset* keyword-only argument.
1010The default charset of HTML document changed from ``"ISO-8859-1"``
1011to ``"utf-8"``.
Yury Selivanovce917c7312015-09-10 17:35:38 -04001012(Contributed by Berker Peksag in :issue:`2052`.)
Berker Peksag102029d2015-03-15 01:18:47 +02001013
Yury Selivanova88cd642015-09-10 21:26:54 -04001014The :func:`~difflib.diff_bytes` function can now compare lists of byte
1015strings. This fixes a regression from Python 2.
Yury Selivanovce917c7312015-09-10 17:35:38 -04001016(Contributed by Terry J. Reedy and Greg Ward in :issue:`17445`.)
1017
Greg Ward4d9d2562015-04-20 20:21:21 -04001018
Berker Peksag618e3152015-01-27 02:59:09 +02001019distutils
1020---------
1021
Martin Panter97ce0fa2015-11-14 01:14:54 +00001022Both the ``build`` and ``build_ext`` commands now accept a ``-j`` option to
Yury Selivanovce917c7312015-09-10 17:35:38 -04001023enable parallel building of extension modules.
1024(Contributed by Antoine Pitrou in :issue:`5309`.)
Berker Peksag618e3152015-01-27 02:59:09 +02001025
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001026The :mod:`distutils` module now supports ``xz`` compression, and can be
1027enabled by passing ``xztar`` as an argument to ``bdist --format``.
Yury Selivanovce917c7312015-09-10 17:35:38 -04001028(Contributed by Serhiy Storchaka in :issue:`16314`.)
1029
Serhiy Storchakab9cec6a2015-05-16 22:13:27 +03001030
Antoine Pitroub9d9ce72014-05-15 22:47:33 +02001031doctest
1032-------
Giampaolo Rodola'e09fb712014-04-04 15:34:17 +02001033
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001034The :func:`~doctest.DocTestSuite` function returns an empty
Martin Panter97ce0fa2015-11-14 01:14:54 +00001035:class:`unittest.TestSuite` if *module* contains no docstrings, instead of
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001036raising :exc:`ValueError`. (Contributed by Glenn Jones in :issue:`15916`.)
Yury Selivanovce917c7312015-09-10 17:35:38 -04001037
Antoine Pitroub9d9ce72014-05-15 22:47:33 +02001038
R David Murrayb744f3a2015-05-16 15:41:07 -04001039email
1040-----
1041
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001042A new policy option :attr:`Policy.mangle_from_ <email.policy.Policy.mangle_from_>`
1043controls whether or not lines that start with ``"From "`` in email bodies are
1044prefixed with a ``">"`` character by generators. The default is ``True`` for
Yury Selivanovce917c7312015-09-10 17:35:38 -04001045:attr:`~email.policy.compat32` and ``False`` for all other policies.
1046(Contributed by Milan Oberkirch in :issue:`20098`.)
R David Murrayfdb23c22015-05-17 14:24:33 -04001047
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001048A new
Yury Selivanova33cb352015-09-13 11:21:25 -04001049:meth:`Message.get_content_disposition() <email.message.Message.get_content_disposition>`
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001050method provides easy access to a canonical value for the
1051:mailheader:`Content-Disposition` header.
1052(Contributed by Abhilash Raj in :issue:`21083`.)
R David Murrayb744f3a2015-05-16 15:41:07 -04001053
Yury Selivanova88cd642015-09-10 21:26:54 -04001054A new policy option :attr:`EmailPolicy.utf8 <email.policy.EmailPolicy.utf8>`
1055can be set to ``True`` to encode email headers using the UTF-8 charset instead
1056of using encoded words. This allows ``Messages`` to be formatted according to
Yury Selivanovce917c7312015-09-10 17:35:38 -04001057:rfc:`6532` and used with an SMTP server that supports the :rfc:`6531`
Yury Selivanova88cd642015-09-10 21:26:54 -04001058``SMTPUTF8`` extension. (Contributed by R. David Murray in
1059:issue:`24211`.)
Yury Selivanovce917c7312015-09-10 17:35:38 -04001060
Yury Selivanova33cb352015-09-13 11:21:25 -04001061The :class:`mime.text.MIMEText <email.mime.text.MIMEText>` constructor now
1062accepts a :class:`charset.Charset <email.charset.Charset>` instance.
Yury Selivanov46a8b402015-09-12 15:52:04 -04001063(Contributed by Claude Paroz and Berker Peksag in :issue:`16324`.)
1064
R David Murray224ef3e2015-05-17 11:29:21 -04001065
Yury Selivanov4dde5872015-09-11 00:48:21 -04001066enum
1067----
1068
1069The :class:`~enum.Enum` callable has a new parameter *start* to
1070specify the initial number of enum values if only *names* are provided::
1071
1072 >>> Animal = enum.Enum('Animal', 'cat dog', start=10)
1073 >>> Animal.cat
1074 <Animal.cat: 10>
1075 >>> Animal.dog
1076 <Animal.dog: 11>
1077
1078(Contributed by Ethan Furman in :issue:`21706`.)
1079
1080
Yury Selivanov336b37b2015-09-09 12:23:01 -04001081faulthandler
1082------------
1083
Martin Panter97ce0fa2015-11-14 01:14:54 +00001084The :func:`~faulthandler.enable`, :func:`~faulthandler.register`,
Yury Selivanovce917c7312015-09-10 17:35:38 -04001085:func:`~faulthandler.dump_traceback` and
1086:func:`~faulthandler.dump_traceback_later` functions now accept file
1087descriptors in addition to file-like objects.
1088(Contributed by Wei Wu in :issue:`23566`.)
1089
Yury Selivanov336b37b2015-09-09 12:23:01 -04001090
1091functools
1092---------
1093
Yury Selivanov95fd26b2015-09-12 17:50:58 -04001094.. _whatsnew-lrucache:
1095
Martin Panter97ce0fa2015-11-14 01:14:54 +00001096Most of the :func:`~functools.lru_cache` machinery is now implemented in C, making
Yury Selivanova88cd642015-09-10 21:26:54 -04001097it significantly faster. (Contributed by Matt Joiner, Alexey Kachayev, and
Yury Selivanovce917c7312015-09-10 17:35:38 -04001098Serhiy Storchaka in :issue:`14373`.)
1099
Yury Selivanov336b37b2015-09-09 12:23:01 -04001100
Serhiy Storchakac2edcdd2014-09-11 12:17:37 +03001101glob
1102----
1103
Martin Panter97ce0fa2015-11-14 01:14:54 +00001104The :func:`~glob.iglob` and :func:`~glob.glob` functions now support recursive
1105search in subdirectories, using the ``"**"`` pattern.
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001106(Contributed by Serhiy Storchaka in :issue:`13968`.)
Yury Selivanov336b37b2015-09-09 12:23:01 -04001107
Serhiy Storchakac2edcdd2014-09-11 12:17:37 +03001108
Yury Selivanov46a8b402015-09-12 15:52:04 -04001109gzip
1110----
1111
Martin Panter97ce0fa2015-11-14 01:14:54 +00001112The *mode* argument of the :class:`~gzip.GzipFile` constructor now
Yury Selivanov46a8b402015-09-12 15:52:04 -04001113accepts ``"x"`` to request exclusive creation.
1114(Contributed by Tim Heaney in :issue:`19222`.)
1115
1116
Yury Selivanov100fc3f2015-09-08 22:40:30 -04001117heapq
1118-----
1119
Yury Selivanovce917c7312015-09-10 17:35:38 -04001120Element comparison in :func:`~heapq.merge` can now be customized by
Yury Selivanov23950372015-09-12 23:46:39 -04001121passing a :term:`key function` in a new optional *key* keyword argument,
1122and a new optional *reverse* keyword argument can be used to reverse element
1123comparison::
1124
1125 >>> import heapq
1126 >>> a = ['9', '777', '55555']
1127 >>> b = ['88', '6666']
1128 >>> list(heapq.merge(a, b, key=len))
1129 ['9', '88', '777', '6666', '55555']
1130 >>> list(heapq.merge(reversed(a), reversed(b), key=len, reverse=True))
1131 ['55555', '6666', '777', '88', '9']
1132
1133(Contributed by Raymond Hettinger in :issue:`13742`.)
Yury Selivanovce917c7312015-09-10 17:35:38 -04001134
Yury Selivanov100fc3f2015-09-08 22:40:30 -04001135
Yury Selivanov4dde5872015-09-11 00:48:21 -04001136http
1137----
1138
1139A new :class:`HTTPStatus <http.HTTPStatus>` enum that defines a set of
1140HTTP status codes, reason phrases and long descriptions written in English.
1141(Contributed by Demian Brecht in :issue:`21793`.)
1142
1143
Yury Selivanov46a8b402015-09-12 15:52:04 -04001144http.client
1145-----------
1146
1147:meth:`HTTPConnection.getresponse() <http.client.HTTPConnection.getresponse>`
1148now raises a :exc:`~http.client.RemoteDisconnected` exception when a
1149remote server connection is closed unexpectedly. Additionally, if a
1150:exc:`ConnectionError` (of which ``RemoteDisconnected``
1151is a subclass) is raised, the client socket is now closed automatically,
Yury Selivanov23950372015-09-12 23:46:39 -04001152and will reconnect on the next request::
1153
1154 import http.client
1155 conn = http.client.HTTPConnection('www.python.org')
1156 for retries in range(3):
1157 try:
1158 conn.request('GET', '/')
1159 resp = conn.getresponse()
1160 except http.client.RemoteDisconnected:
1161 pass
1162
Yury Selivanov46a8b402015-09-12 15:52:04 -04001163(Contributed by Martin Panter in :issue:`3566`.)
1164
1165
Guido van Rossum7ca13532015-05-23 15:27:51 -07001166idlelib and IDLE
Terry Jan Reedy44825cf2015-05-23 18:19:42 -04001167----------------
1168
1169Since idlelib implements the IDLE shell and editor and is not intended for
Yury Selivanova88cd642015-09-10 21:26:54 -04001170import by other programs, it gets improvements with every release. See
Terry Jan Reedy44825cf2015-05-23 18:19:42 -04001171:file:`Lib/idlelib/NEWS.txt` for a cumulative list of changes since 3.4.0,
1172as well as changes made in future 3.5.x releases. This file is also available
Serhiy Storchaka35a361f2015-09-13 12:07:54 +03001173from the IDLE :menuselection:`Help --> About IDLE` dialog.
Terry Jan Reedy44825cf2015-05-23 18:19:42 -04001174
Yury Selivanovce917c7312015-09-10 17:35:38 -04001175
Serhiy Storchaka38684c32014-09-09 19:07:49 +03001176imaplib
1177-------
1178
Martin Panter97ce0fa2015-11-14 01:14:54 +00001179The :class:`~imaplib.IMAP4` class now supports the :term:`context manager` protocol.
Yury Selivanovce917c7312015-09-10 17:35:38 -04001180When used in a :keyword:`with` statement, the IMAP4 ``LOGOUT``
1181command will be called automatically at the end of the block.
1182(Contributed by Tarek Ziadé and Serhiy Storchaka in :issue:`4972`.)
Serhiy Storchaka38684c32014-09-09 19:07:49 +03001183
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001184The :mod:`imaplib` module now supports :rfc:`5161` (ENABLE Extension)
Yury Selivanova33cb352015-09-13 11:21:25 -04001185and :rfc:`6855` (UTF-8 Support) via the :meth:`IMAP4.enable() <imaplib.IMAP4.enable>`
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001186method. A new :attr:`IMAP4.utf8_enabled <imaplib.IMAP4.utf8_enabled>`
Martin Panter97ce0fa2015-11-14 01:14:54 +00001187attribute tracks whether or not :rfc:`6855` support is enabled.
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001188(Contributed by Milan Oberkirch, R. David Murray, and Maciej Szulik in
1189:issue:`21800`.)
R David Murraya6429db2015-05-10 19:17:23 -04001190
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001191The :mod:`imaplib` module now automatically encodes non-ASCII string usernames
1192and passwords using UTF-8, as recommended by the RFCs. (Contributed by Milan
Yury Selivanovce917c7312015-09-10 17:35:38 -04001193Oberkirch in :issue:`21800`.)
1194
R David Murraya6429db2015-05-10 19:17:23 -04001195
R David Murray2f608202014-06-26 12:27:57 -04001196imghdr
1197------
1198
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001199The :func:`~imghdr.what` function now recognizes the
1200`OpenEXR <http://www.openexr.com>`_ format
1201(contributed by Martin Vignali and Claudiu Popa in :issue:`20295`),
1202and the `WebP <https://en.wikipedia.org/wiki/WebP>`_ format
1203(contributed by Fabrice Aneche and Claudiu Popa in :issue:`20197`.)
Yury Selivanovce917c7312015-09-10 17:35:38 -04001204
R David Murray2f608202014-06-26 12:27:57 -04001205
Antoine Pitroub9d9ce72014-05-15 22:47:33 +02001206importlib
1207---------
1208
Yury Selivanov3b765522015-09-10 19:02:24 -04001209The :class:`util.LazyLoader <importlib.util.LazyLoader>` class allows for
1210lazy loading of modules in applications where startup time is important.
1211(Contributed by Brett Cannon in :issue:`17621`.)
Antoine Pitroub9d9ce72014-05-15 22:47:33 +02001212
Yury Selivanova33cb352015-09-13 11:21:25 -04001213The :func:`abc.InspectLoader.source_to_code() <importlib.abc.InspectLoader.source_to_code>`
Yury Selivanov3b765522015-09-10 19:02:24 -04001214method is now a static method. This makes it easier to initialize a module
1215object with code compiled from a string by running
1216``exec(code, module.__dict__)``.
Yury Selivanovce917c7312015-09-10 17:35:38 -04001217(Contributed by Brett Cannon in :issue:`21156`.)
Antoine Pitroub9d9ce72014-05-15 22:47:33 +02001218
Yury Selivanova33cb352015-09-13 11:21:25 -04001219The new :func:`util.module_from_spec() <importlib.util.module_from_spec>`
Yury Selivanova88cd642015-09-10 21:26:54 -04001220function is now the preferred way to create a new module. As opposed to
1221creating a :class:`types.ModuleType` instance directly, this new function
1222will set the various import-controlled attributes based on the passed-in
1223spec object. (Contributed by Brett Cannon in :issue:`20383`.)
Yury Selivanovce917c7312015-09-10 17:35:38 -04001224
Brett Cannon2a17bde2014-05-30 14:55:29 -04001225
Antoine Pitroub9d9ce72014-05-15 22:47:33 +02001226inspect
1227-------
Victor Stinner01adf062014-03-18 00:53:32 +01001228
Martin Panter97ce0fa2015-11-14 01:14:54 +00001229Both the :class:`~inspect.Signature` and :class:`~inspect.Parameter` classes are
Yury Selivanova88cd642015-09-10 21:26:54 -04001230now picklable and hashable. (Contributed by Yury Selivanov in :issue:`20726`
Yury Selivanovce917c7312015-09-10 17:35:38 -04001231and :issue:`20334`.)
Yury Selivanova5d63dd2014-03-27 11:31:43 -04001232
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001233A new
Yury Selivanova33cb352015-09-13 11:21:25 -04001234:meth:`BoundArguments.apply_defaults() <inspect.BoundArguments.apply_defaults>`
Yury Selivanov23950372015-09-12 23:46:39 -04001235method provides a way to set default values for missing arguments::
1236
1237 >>> def foo(a, b='ham', *args): pass
1238 >>> ba = inspect.signature(foo).bind('spam')
1239 >>> ba.apply_defaults()
1240 >>> ba.arguments
1241 OrderedDict([('a', 'spam'), ('b', 'ham'), ('args', ())])
1242
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001243(Contributed by Yury Selivanov in :issue:`24190`.)
Yury Selivanovb907a512015-05-16 13:45:09 -04001244
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001245A new class method
Yury Selivanova33cb352015-09-13 11:21:25 -04001246:meth:`Signature.from_callable() <inspect.Signature.from_callable>` makes
Yury Selivanovce917c7312015-09-10 17:35:38 -04001247subclassing of :class:`~inspect.Signature` easier. (Contributed
1248by Yury Selivanov and Eric Snow in :issue:`17373`.)
Yury Selivanovda396452014-03-27 12:09:24 -04001249
Serhiy Storchaka35a361f2015-09-13 12:07:54 +03001250The :func:`~inspect.signature` function now accepts a *follow_wrapped*
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001251optional keyword argument, which, when set to ``False``, disables automatic
1252following of ``__wrapped__`` links.
1253(Contributed by Yury Selivanov in :issue:`20691`.)
Yury Selivanovbcd4fc12015-05-20 14:30:08 -04001254
Yury Selivanovce917c7312015-09-10 17:35:38 -04001255A set of new functions to inspect
1256:term:`coroutine functions <coroutine function>` and
Yury Selivanova88cd642015-09-10 21:26:54 -04001257:term:`coroutine objects <coroutine>` has been added:
Yury Selivanovce917c7312015-09-10 17:35:38 -04001258:func:`~inspect.iscoroutine`, :func:`~inspect.iscoroutinefunction`,
1259:func:`~inspect.isawaitable`, :func:`~inspect.getcoroutinelocals`,
1260and :func:`~inspect.getcoroutinestate`.
1261(Contributed by Yury Selivanov in :issue:`24017` and :issue:`24400`.)
Yury Selivanovf3e40fa2015-05-21 11:50:30 -04001262
Martin Panter97ce0fa2015-11-14 01:14:54 +00001263The :func:`~inspect.stack`, :func:`~inspect.trace`,
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001264:func:`~inspect.getouterframes`, and :func:`~inspect.getinnerframes`
1265functions now return a list of named tuples.
Yury Selivanovce917c7312015-09-10 17:35:38 -04001266(Contributed by Daniel Shahaf in :issue:`16808`.)
Yury Selivanov5376ba92015-06-22 12:19:30 -04001267
Yury Selivanov100fc3f2015-09-08 22:40:30 -04001268
Yury Selivanov4dde5872015-09-11 00:48:21 -04001269io
1270--
1271
Yury Selivanova33cb352015-09-13 11:21:25 -04001272A new :meth:`BufferedIOBase.readinto1() <io.BufferedIOBase.readinto1>`
Yury Selivanov4dde5872015-09-11 00:48:21 -04001273method, that uses at most one call to the underlying raw stream's
Yury Selivanova33cb352015-09-13 11:21:25 -04001274:meth:`RawIOBase.read() <io.RawIOBase.read>` or
1275:meth:`RawIOBase.readinto() <io.RawIOBase.readinto>` methods.
Yury Selivanov4dde5872015-09-11 00:48:21 -04001276(Contributed by Nikolaus Rath in :issue:`20578`.)
1277
1278
Antoine Pitrou0dfce562014-05-15 22:55:40 +02001279ipaddress
1280---------
1281
Martin Panter97ce0fa2015-11-14 01:14:54 +00001282Both the :class:`~ipaddress.IPv4Network` and :class:`~ipaddress.IPv6Network` classes
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001283now accept an ``(address, netmask)`` tuple argument, so as to easily construct
Yury Selivanov23950372015-09-12 23:46:39 -04001284network objects from existing addresses::
1285
1286 >>> import ipaddress
1287 >>> ipaddress.IPv4Network(('127.0.0.0', 8))
1288 IPv4Network('127.0.0.0/8')
1289 >>> ipaddress.IPv4Network(('127.0.0.0', '255.0.0.0'))
1290 IPv4Network('127.0.0.0/8')
1291
1292(Contributed by Peter Moody and Antoine Pitrou in :issue:`16531`.)
Yury Selivanovce917c7312015-09-10 17:35:38 -04001293
Martin Panter97ce0fa2015-11-14 01:14:54 +00001294A new :attr:`~ipaddress.IPv4Network.reverse_pointer` attribute for the
Yury Selivanov508a81e2015-09-10 23:37:06 -04001295:class:`~ipaddress.IPv4Network` and :class:`~ipaddress.IPv6Network` classes
Yury Selivanov23950372015-09-12 23:46:39 -04001296returns the name of the reverse DNS PTR record::
1297
1298 >>> import ipaddress
1299 >>> addr = ipaddress.IPv4Address('127.0.0.1')
1300 >>> addr.reverse_pointer
1301 '1.0.0.127.in-addr.arpa'
1302 >>> addr6 = ipaddress.IPv6Address('::1')
1303 >>> addr6.reverse_pointer
1304 '1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa'
1305
Yury Selivanov508a81e2015-09-10 23:37:06 -04001306(Contributed by Leon Weber in :issue:`20480`.)
1307
Antoine Pitrou0dfce562014-05-15 22:55:40 +02001308
Berker Peksag39e4c4d2014-11-10 09:56:54 +02001309json
1310----
1311
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001312The :mod:`json.tool` command line interface now preserves the order of keys in
1313JSON objects passed in input. The new ``--sort-keys`` option can be used
Yury Selivanovce917c7312015-09-10 17:35:38 -04001314to sort the keys alphabetically. (Contributed by Berker Peksag
1315in :issue:`21650`.)
Berker Peksag39e4c4d2014-11-10 09:56:54 +02001316
Serhiy Storchaka35a361f2015-09-13 12:07:54 +03001317JSON decoder now raises :exc:`~json.JSONDecodeError` instead of
Yury Selivanov46a8b402015-09-12 15:52:04 -04001318:exc:`ValueError` to provide better context information about the error.
1319(Contributed by Serhiy Storchaka in :issue:`19361`.)
1320
1321
1322linecache
1323---------
1324
1325A new :func:`~linecache.lazycache` function can be used to capture information
Martin Panter97ce0fa2015-11-14 01:14:54 +00001326about a non-file-based module to permit getting its lines later via
Yury Selivanov46a8b402015-09-12 15:52:04 -04001327:func:`~linecache.getline`. This avoids doing I/O until a line is actually
1328needed, without having to carry the module globals around indefinitely.
1329(Contributed by Robert Collins in :issue:`17911`.)
Yury Selivanovce917c7312015-09-10 17:35:38 -04001330
Serhiy Storchaka47efb4a2015-01-26 13:16:30 +02001331
Yury Selivanov100fc3f2015-09-08 22:40:30 -04001332locale
1333------
1334
Yury Selivanovce917c7312015-09-10 17:35:38 -04001335A new :func:`~locale.delocalize` function can be used to convert a string into
Yury Selivanov23950372015-09-12 23:46:39 -04001336a normalized number string, taking the ``LC_NUMERIC`` settings into account::
1337
1338 >>> import locale
1339 >>> locale.setlocale(locale.LC_NUMERIC, 'de_DE.UTF-8')
1340 'de_DE.UTF-8'
1341 >>> locale.delocalize('1.234,56')
1342 '1234.56'
1343 >>> locale.setlocale(locale.LC_NUMERIC, 'en_US.UTF-8')
1344 'en_US.UTF-8'
1345 >>> locale.delocalize('1,234.56')
1346 '1234.56'
1347
Yury Selivanovce917c7312015-09-10 17:35:38 -04001348(Contributed by Cédric Krier in :issue:`13918`.)
1349
Yury Selivanov100fc3f2015-09-08 22:40:30 -04001350
1351logging
1352-------
1353
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001354All logging methods (:class:`~logging.Logger` :meth:`~logging.Logger.log`,
Yury Selivanovce917c7312015-09-10 17:35:38 -04001355:meth:`~logging.Logger.exception`, :meth:`~logging.Logger.critical`,
1356:meth:`~logging.Logger.debug`, etc.), now accept exception instances
Serhiy Storchaka35a361f2015-09-13 12:07:54 +03001357as an *exc_info* argument, in addition to boolean values and exception
Yury Selivanov6d9dd752015-09-13 01:10:19 -04001358tuples::
1359
1360 >>> import logging
1361 >>> try:
1362 ... 1/0
1363 ... except ZeroDivisionError as ex:
1364 ... logging.error('exception', exc_info=ex)
1365 ERROR:root:exception
1366
1367(Contributed by Yury Selivanov in :issue:`20537`.)
Yury Selivanov100fc3f2015-09-08 22:40:30 -04001368
Yury Selivanova88cd642015-09-10 21:26:54 -04001369The :class:`handlers.HTTPHandler <logging.handlers.HTTPHandler>` class now
1370accepts an optional :class:`ssl.SSLContext` instance to configure SSL
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001371settings used in an HTTP connection.
1372(Contributed by Alex Gaynor in :issue:`22788`.)
Yury Selivanov100fc3f2015-09-08 22:40:30 -04001373
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001374The :class:`handlers.QueueListener <logging.handlers.QueueListener>` class now
1375takes a *respect_handler_level* keyword argument which, if set to ``True``,
1376will pass messages to handlers taking handler levels into account.
1377(Contributed by Vinay Sajip.)
Yury Selivanovce917c7312015-09-10 17:35:38 -04001378
Yury Selivanov336b37b2015-09-09 12:23:01 -04001379
Yury Selivanov100fc3f2015-09-08 22:40:30 -04001380lzma
1381----
1382
Yury Selivanova33cb352015-09-13 11:21:25 -04001383The :meth:`LZMADecompressor.decompress() <lzma.LZMADecompressor.decompress>`
Yury Selivanova88cd642015-09-10 21:26:54 -04001384method now accepts an optional *max_length* argument to limit the maximum
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001385size of decompressed data.
Yury Selivanovce917c7312015-09-10 17:35:38 -04001386(Contributed by Martin Panter in :issue:`15955`.)
1387
Yury Selivanov100fc3f2015-09-08 22:40:30 -04001388
Tal Einatf67b0a32015-05-31 22:18:31 +03001389math
1390----
1391
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001392Two new constants have been added to the :mod:`math` module: :data:`~math.inf`
1393and :data:`~math.nan`. (Contributed by Mark Dickinson in :issue:`23185`.)
Yury Selivanov336b37b2015-09-09 12:23:01 -04001394
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001395A new function :func:`~math.isclose` provides a way to test for approximate
Yury Selivanovce917c7312015-09-10 17:35:38 -04001396equality. (Contributed by Chris Barker and Tal Einat in :issue:`24270`.)
Tal Einatf67b0a32015-05-31 22:18:31 +03001397
Yury Selivanovce917c7312015-09-10 17:35:38 -04001398A new :func:`~math.gcd` function has been added. The :func:`fractions.gcd`
1399function is now deprecated. (Contributed by Mark Dickinson and Serhiy
1400Storchaka in :issue:`22486`.)
1401
Yury Selivanov336b37b2015-09-09 12:23:01 -04001402
Yury Selivanov46a8b402015-09-12 15:52:04 -04001403multiprocessing
1404---------------
1405
Yury Selivanova33cb352015-09-13 11:21:25 -04001406:func:`sharedctypes.synchronized() <multiprocessing.sharedctypes.synchronized>`
Yury Selivanov23950372015-09-12 23:46:39 -04001407objects now support the :term:`context manager` protocol.
1408(Contributed by Charles-François Natali in :issue:`21565`.)
Yury Selivanov46a8b402015-09-12 15:52:04 -04001409
1410
Yury Selivanov336b37b2015-09-09 12:23:01 -04001411operator
1412--------
1413
Yury Selivanova88cd642015-09-10 21:26:54 -04001414:func:`~operator.attrgetter`, :func:`~operator.itemgetter`,
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001415and :func:`~operator.methodcaller` objects now support pickling.
Yury Selivanovce917c7312015-09-10 17:35:38 -04001416(Contributed by Josh Rosenberg and Serhiy Storchaka in :issue:`22955`.)
1417
Yury Selivanov4dde5872015-09-11 00:48:21 -04001418New :func:`~operator.matmul` and :func:`~operator.imatmul` functions
1419to perform matrix multiplication.
1420(Contributed by Benjamin Peterson in :issue:`21176`.)
1421
Yury Selivanov336b37b2015-09-09 12:23:01 -04001422
Zachary Ware63f277b2014-06-19 09:46:37 -05001423os
1424--
1425
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001426The new :func:`~os.scandir` function returning an iterator of
1427:class:`~os.DirEntry` objects has been added. If possible, :func:`~os.scandir`
1428extracts file attributes while scanning a directory, removing the need to
1429perform subsequent system calls to determine file type or attributes, which may
Yury Selivanovce917c7312015-09-10 17:35:38 -04001430significantly improve performance. (Contributed by Ben Hoyt with the help
1431of Victor Stinner in :issue:`22524`.)
Victor Stinner6036e442015-03-08 01:58:04 +01001432
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001433On Windows, a new
1434:attr:`stat_result.st_file_attributes <os.stat_result.st_file_attributes>`
Yury Selivanova33cb352015-09-13 11:21:25 -04001435attribute is now available. It corresponds to the ``dwFileAttributes`` member
1436of the ``BY_HANDLE_FILE_INFORMATION`` structure returned by
Yury Selivanovce917c7312015-09-10 17:35:38 -04001437``GetFileInformationByHandle()``. (Contributed by Ben Hoyt in :issue:`21719`.)
Zachary Ware63f277b2014-06-19 09:46:37 -05001438
Martin Panter97ce0fa2015-11-14 01:14:54 +00001439The :func:`~os.urandom` function now uses the ``getrandom()`` syscall on Linux 3.17
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001440or newer, and ``getentropy()`` on OpenBSD 5.6 and newer, removing the need to
1441use ``/dev/urandom`` and avoiding failures due to potential file descriptor
Yury Selivanovce917c7312015-09-10 17:35:38 -04001442exhaustion. (Contributed by Victor Stinner in :issue:`22181`.)
Victor Stinnerace88482015-07-29 02:28:32 +02001443
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001444New :func:`~os.get_blocking` and :func:`~os.set_blocking` functions allow to
Martin Panter97ce0fa2015-11-14 01:14:54 +00001445get and set a file descriptor's blocking mode (:data:`~os.O_NONBLOCK`.)
Yury Selivanovce917c7312015-09-10 17:35:38 -04001446(Contributed by Victor Stinner in :issue:`22054`.)
Yury Selivanov100fc3f2015-09-08 22:40:30 -04001447
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001448The :func:`~os.truncate` and :func:`~os.ftruncate` functions are now supported
1449on Windows. (Contributed by Steve Dower in :issue:`23668`.)
Serhiy Storchaka38220932015-03-31 15:31:53 +03001450
Yury Selivanova88cd642015-09-10 21:26:54 -04001451There is a new :func:`os.path.commonpath` function returning the longest
Yury Selivanovce917c7312015-09-10 17:35:38 -04001452common sub-path of each passed pathname. Unlike the
Yury Selivanova88cd642015-09-10 21:26:54 -04001453:func:`os.path.commonprefix` function, it always returns a valid
Yury Selivanov23950372015-09-12 23:46:39 -04001454path::
1455
1456 >>> os.path.commonprefix(['/usr/lib', '/usr/local/lib'])
1457 '/usr/l'
1458
1459 >>> os.path.commonpath(['/usr/lib', '/usr/local/lib'])
1460 '/usr'
1461
1462(Contributed by Rafik Draoui and Serhiy Storchaka in :issue:`10395`.)
Yury Selivanovce917c7312015-09-10 17:35:38 -04001463
Serhiy Storchaka38220932015-03-31 15:31:53 +03001464
Yury Selivanov100fc3f2015-09-08 22:40:30 -04001465pathlib
1466-------
1467
Yury Selivanova33cb352015-09-13 11:21:25 -04001468The new :meth:`Path.samefile() <pathlib.Path.samefile>` method can be used
Martin Panter97ce0fa2015-11-14 01:14:54 +00001469to check whether the path points to the same file as another path, which can
1470be either another :class:`~pathlib.Path` object, or a string::
Yury Selivanov6d9dd752015-09-13 01:10:19 -04001471
1472 >>> import pathlib
1473 >>> p1 = pathlib.Path('/etc/hosts')
1474 >>> p2 = pathlib.Path('/etc/../etc/hosts')
1475 >>> p1.samefile(p2)
1476 True
1477
Yury Selivanovce917c7312015-09-10 17:35:38 -04001478(Contributed by Vajrasky Kok and Antoine Pitrou in :issue:`19775`.)
Yury Selivanov100fc3f2015-09-08 22:40:30 -04001479
Berker Peksagad56c922015-10-19 00:56:39 +03001480The :meth:`Path.mkdir() <pathlib.Path.mkdir>` method now accepts a new optional
Berker Peksag5783ee12015-10-18 20:22:15 +03001481*exist_ok* argument to match ``mkdir -p`` and :func:`os.makedirs`
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001482functionality. (Contributed by Berker Peksag in :issue:`21539`.)
Yury Selivanov100fc3f2015-09-08 22:40:30 -04001483
Yury Selivanova33cb352015-09-13 11:21:25 -04001484There is a new :meth:`Path.expanduser() <pathlib.Path.expanduser>` method to
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001485expand ``~`` and ``~user`` prefixes. (Contributed by Serhiy Storchaka and
1486Claudiu Popa in :issue:`19776`.)
Yury Selivanov100fc3f2015-09-08 22:40:30 -04001487
Yury Selivanova33cb352015-09-13 11:21:25 -04001488A new :meth:`Path.home() <pathlib.Path.home>` class method can be used to get
Martin Panter97ce0fa2015-11-14 01:14:54 +00001489a :class:`~pathlib.Path` instance representing the user’s home
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001490directory.
Yury Selivanovce917c7312015-09-10 17:35:38 -04001491(Contributed by Victor Salgado and Mayank Tripathi in :issue:`19777`.)
1492
Yury Selivanova33cb352015-09-13 11:21:25 -04001493New :meth:`Path.write_text() <pathlib.Path.write_text>`,
1494:meth:`Path.read_text() <pathlib.Path.read_text>`,
1495:meth:`Path.write_bytes() <pathlib.Path.write_bytes>`,
1496:meth:`Path.read_bytes() <pathlib.Path.read_bytes>` methods to simplify
Yury Selivanov4dde5872015-09-11 00:48:21 -04001497read/write operations on files.
Yury Selivanov6d9dd752015-09-13 01:10:19 -04001498
1499The following code snippet will create or rewrite existing file
1500``~/spam42``::
1501
1502 >>> import pathlib
1503 >>> p = pathlib.Path('~/spam42')
1504 >>> p.expanduser().write_text('ham')
1505 3
1506
Yury Selivanov4dde5872015-09-11 00:48:21 -04001507(Contributed by Christopher Welborn in :issue:`20218`.)
1508
Yury Selivanov100fc3f2015-09-08 22:40:30 -04001509
Serhiy Storchaka58e41342015-03-31 14:07:24 +03001510pickle
1511------
1512
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001513Nested objects, such as unbound methods or nested classes, can now be pickled
Yury Selivanova88cd642015-09-10 21:26:54 -04001514using :ref:`pickle protocols <pickle-protocols>` older than protocol version 4.
1515Protocol version 4 already supports these cases. (Contributed by Serhiy
1516Storchaka in :issue:`23611`.)
Yury Selivanovce917c7312015-09-10 17:35:38 -04001517
Serhiy Storchaka58e41342015-03-31 14:07:24 +03001518
R David Murrayb8cd3e42015-05-16 15:05:53 -04001519poplib
1520------
1521
Yury Selivanova33cb352015-09-13 11:21:25 -04001522A new :meth:`POP3.utf8() <poplib.POP3.utf8>` command enables :rfc:`6856`
Yury Selivanova88cd642015-09-10 21:26:54 -04001523(Internationalized Email) support, if a POP server supports it.
Yury Selivanovce917c7312015-09-10 17:35:38 -04001524(Contributed by Milan OberKirch in :issue:`21804`.)
1525
R David Murrayb8cd3e42015-05-16 15:05:53 -04001526
Serhiy Storchaka9baa5b22014-09-29 22:49:23 +03001527re
1528--
1529
Yury Selivanov46a8b402015-09-12 15:52:04 -04001530References and conditional references to groups with fixed length are now
Yury Selivanov23950372015-09-12 23:46:39 -04001531allowed in lookbehind assertions::
1532
1533 >>> import re
1534 >>> pat = re.compile(r'(a|b).(?<=\1)c')
1535 >>> pat.match('aac')
1536 <_sre.SRE_Match object; span=(0, 3), match='aac'>
1537 >>> pat.match('bbc')
1538 <_sre.SRE_Match object; span=(0, 3), match='bbc'>
1539
Yury Selivanov46a8b402015-09-12 15:52:04 -04001540(Contributed by Serhiy Storchaka in :issue:`9179`.)
1541
Martin Panter97ce0fa2015-11-14 01:14:54 +00001542The number of capturing groups in regular expressions is no longer limited to
Yury Selivanovce917c7312015-09-10 17:35:38 -04001543100. (Contributed by Serhiy Storchaka in :issue:`22437`.)
Serhiy Storchaka9baa5b22014-09-29 22:49:23 +03001544
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001545The :func:`~re.sub` and :func:`~re.subn` functions now replace unmatched
Yury Selivanova88cd642015-09-10 21:26:54 -04001546groups with empty strings instead of raising an exception.
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001547(Contributed by Serhiy Storchaka in :issue:`1519638`.)
Yury Selivanovce917c7312015-09-10 17:35:38 -04001548
Martin Panter97ce0fa2015-11-14 01:14:54 +00001549The :class:`re.error` exceptions have new attributes,
Yury Selivanov508a81e2015-09-10 23:37:06 -04001550:attr:`~re.error.msg`, :attr:`~re.error.pattern`,
1551:attr:`~re.error.pos`, :attr:`~re.error.lineno`,
Martin Panter97ce0fa2015-11-14 01:14:54 +00001552and :attr:`~re.error.colno`, that provide better context
Yury Selivanov23950372015-09-12 23:46:39 -04001553information about the error::
1554
1555 >>> re.compile("""
1556 ... (?x)
1557 ... .++
1558 ... """)
1559 Traceback (most recent call last):
1560 ...
1561 sre_constants.error: multiple repeat at position 16 (line 3, column 7)
1562
Yury Selivanov508a81e2015-09-10 23:37:06 -04001563(Contributed by Serhiy Storchaka in :issue:`22578`.)
1564
Serhiy Storchaka7438e4b2014-10-10 11:06:31 +03001565
Yury Selivanov100fc3f2015-09-08 22:40:30 -04001566readline
1567--------
1568
Yury Selivanova88cd642015-09-10 21:26:54 -04001569A new :func:`~readline.append_history_file` function can be used to append
1570the specified number of trailing elements in history to the given file.
Yury Selivanovce917c7312015-09-10 17:35:38 -04001571(Contributed by Bruno Cauet in :issue:`22940`.)
1572
Yury Selivanov100fc3f2015-09-08 22:40:30 -04001573
Yury Selivanov508a81e2015-09-10 23:37:06 -04001574selectors
1575---------
1576
Yury Selivanov4dde5872015-09-11 00:48:21 -04001577The new :class:`~selectors.DevpollSelector` supports efficient
1578``/dev/poll`` polling on Solaris.
Yury Selivanov508a81e2015-09-10 23:37:06 -04001579(Contributed by Giampaolo Rodola' in :issue:`18931`.)
1580
1581
R David Murray6ffface2014-06-11 14:40:13 -04001582shutil
1583------
1584
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001585The :func:`~shutil.move` function now accepts a *copy_function* argument,
1586allowing, for example, the :func:`~shutil.copy` function to be used instead of
1587the default :func:`~shutil.copy2` if there is a need to ignore file metadata
1588when moving.
Yury Selivanovce917c7312015-09-10 17:35:38 -04001589(Contributed by Claudiu Popa in :issue:`19840`.)
R David Murray6ffface2014-06-11 14:40:13 -04001590
Yury Selivanova88cd642015-09-10 21:26:54 -04001591The :func:`~shutil.make_archive` function now supports the *xztar* format.
Yury Selivanovce917c7312015-09-10 17:35:38 -04001592(Contributed by Serhiy Storchaka in :issue:`5411`.)
1593
Yury Selivanov100fc3f2015-09-08 22:40:30 -04001594
Antoine Pitroub9d9ce72014-05-15 22:47:33 +02001595signal
1596------
Brett Cannona04dbe42014-04-04 13:53:38 -04001597
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001598On Windows, the :func:`~signal.set_wakeup_fd` function now also supports
1599socket handles. (Contributed by Victor Stinner in :issue:`22018`.)
Victor Stinnerbbe38032015-04-01 16:32:32 +02001600
Yury Selivanova88cd642015-09-10 21:26:54 -04001601Various ``SIG*`` constants in the :mod:`signal` module have been converted into
Yury Selivanovce917c7312015-09-10 17:35:38 -04001602:mod:`Enums <enum>`. This allows meaningful names to be printed
1603during debugging, instead of integer "magic numbers".
1604(Contributed by Giampaolo Rodola' in :issue:`21076`.)
1605
R David Murray1976d9b2014-04-14 20:28:36 -04001606
R David Murray554bcbf2014-06-11 11:18:08 -04001607smtpd
1608-----
1609
Martin Panter97ce0fa2015-11-14 01:14:54 +00001610Both the :class:`~smtpd.SMTPServer` and :class:`~smtpd.SMTPChannel` classes now
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001611accept a *decode_data* keyword argument to determine if the ``DATA`` portion of
1612the SMTP transaction is decoded using the ``"utf-8"`` codec or is instead
Yury Selivanova88cd642015-09-10 21:26:54 -04001613provided to the
Yury Selivanova33cb352015-09-13 11:21:25 -04001614:meth:`SMTPServer.process_message() <smtpd.SMTPServer.process_message>`
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001615method as a byte string. The default is ``True`` for backward compatibility
1616reasons, but will change to ``False`` in Python 3.6. If *decode_data* is set
Yury Selivanova33cb352015-09-13 11:21:25 -04001617to ``False``, the ``process_message`` method must be prepared to accept keyword
1618arguments.
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001619(Contributed by Maciej Szulik in :issue:`19662`.)
R David Murraya33df312015-05-11 12:11:40 -04001620
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001621The :class:`~smtpd.SMTPServer` class now advertises the ``8BITMIME`` extension
1622(:rfc:`6152`) if *decode_data* has been set ``True``. If the client
Yury Selivanovce917c7312015-09-10 17:35:38 -04001623specifies ``BODY=8BITMIME`` on the ``MAIL`` command, it is passed to
Yury Selivanova33cb352015-09-13 11:21:25 -04001624:meth:`SMTPServer.process_message() <smtpd.SMTPServer.process_message>`
Serhiy Storchaka35a361f2015-09-13 12:07:54 +03001625via the *mail_options* keyword.
Yury Selivanovce917c7312015-09-10 17:35:38 -04001626(Contributed by Milan Oberkirch and R. David Murray in :issue:`21795`.)
R David Murraya33df312015-05-11 12:11:40 -04001627
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001628The :class:`~smtpd.SMTPServer` class now also supports the ``SMTPUTF8``
1629extension (:rfc:`6531`: Internationalized Email). If the client specified
1630``SMTPUTF8 BODY=8BITMIME`` on the ``MAIL`` command, they are passed to
Yury Selivanova33cb352015-09-13 11:21:25 -04001631:meth:`SMTPServer.process_message() <smtpd.SMTPServer.process_message>`
Serhiy Storchaka35a361f2015-09-13 12:07:54 +03001632via the *mail_options* keyword. It is the responsibility of the
Yury Selivanova33cb352015-09-13 11:21:25 -04001633``process_message`` method to correctly handle the ``SMTPUTF8`` data.
1634(Contributed by Milan Oberkirch in :issue:`21725`.)
R David Murray554bcbf2014-06-11 11:18:08 -04001635
Yury Selivanovce917c7312015-09-10 17:35:38 -04001636It is now possible to provide, directly or via name resolution, IPv6
1637addresses in the :class:`~smtpd.SMTPServer` constructor, and have it
1638successfully connect. (Contributed by Milan Oberkirch in :issue:`14758`.)
1639
R David Murray6fe56a32014-06-11 13:48:58 -04001640
R David Murray76e13c12014-07-03 14:47:46 -04001641smtplib
1642-------
1643
Yury Selivanova33cb352015-09-13 11:21:25 -04001644A new :meth:`SMTP.auth() <smtplib.SMTP.auth>` method provides a convenient way to
Yury Selivanovce917c7312015-09-10 17:35:38 -04001645implement custom authentication mechanisms. (Contributed by Milan
1646Oberkirch in :issue:`15014`.)
R David Murray76e13c12014-07-03 14:47:46 -04001647
Yury Selivanova33cb352015-09-13 11:21:25 -04001648The :meth:`SMTP.set_debuglevel() <smtplib.SMTP.set_debuglevel>` method now
Yury Selivanova88cd642015-09-10 21:26:54 -04001649accepts an additional debuglevel (2), which enables timestamps in debug
1650messages. (Contributed by Gavin Chappell and Maciej Szulik in :issue:`16914`.)
R David Murray0c49b892015-04-16 17:14:42 -04001651
Martin Panter97ce0fa2015-11-14 01:14:54 +00001652Both the :meth:`SMTP.sendmail() <smtplib.SMTP.sendmail>` and
Yury Selivanova33cb352015-09-13 11:21:25 -04001653:meth:`SMTP.send_message() <smtplib.SMTP.send_message>` methods now
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001654support support :rfc:`6531` (SMTPUTF8).
1655(Contributed by Milan Oberkirch and R. David Murray in :issue:`22027`.)
Yury Selivanovce917c7312015-09-10 17:35:38 -04001656
R David Murraycee7cf62015-05-16 13:58:14 -04001657
R David Murray4487dd02014-10-09 16:59:30 -04001658sndhdr
1659------
1660
Martin Panter97ce0fa2015-11-14 01:14:54 +00001661The :func:`~sndhdr.what` and :func:`~sndhdr.whathdr` functions now return
Yury Selivanova88cd642015-09-10 21:26:54 -04001662a :func:`~collections.namedtuple`. (Contributed by Claudiu Popa in
Yury Selivanovce917c7312015-09-10 17:35:38 -04001663:issue:`18615`.)
1664
R David Murray4487dd02014-10-09 16:59:30 -04001665
Yury Selivanovfe369a62015-09-13 08:29:19 -04001666socket
1667------
1668
1669Functions with timeouts now use a monotonic clock, instead of a system clock.
1670(Contributed by Victor Stinner in :issue:`22043`.)
1671
Yury Selivanova33cb352015-09-13 11:21:25 -04001672A new :meth:`socket.sendfile() <socket.socket.sendfile>` method allows to
Yury Selivanovfe369a62015-09-13 08:29:19 -04001673send a file over a socket by using the high-performance :func:`os.sendfile`
Martin Panter97ce0fa2015-11-14 01:14:54 +00001674function on UNIX, resulting in uploads being from 2 to 3 times faster than when
Yury Selivanova33cb352015-09-13 11:21:25 -04001675using plain :meth:`socket.send() <socket.socket.send>`.
Yury Selivanovfe369a62015-09-13 08:29:19 -04001676(Contributed by Giampaolo Rodola' in :issue:`17552`.)
1677
Yury Selivanova33cb352015-09-13 11:21:25 -04001678The :meth:`socket.sendall() <socket.socket.sendall>` method no longer resets the
Yury Selivanovfe369a62015-09-13 08:29:19 -04001679socket timeout every time bytes are received or sent. The socket timeout is
1680now the maximum total duration to send all data.
1681(Contributed by Victor Stinner in :issue:`23853`.)
1682
Yury Selivanova33cb352015-09-13 11:21:25 -04001683The *backlog* argument of the :meth:`socket.listen() <socket.socket.listen>`
Yury Selivanovfe369a62015-09-13 08:29:19 -04001684method is now optional. By default it is set to
Martin Panter97ce0fa2015-11-14 01:14:54 +00001685:data:`SOMAXCONN <socket.SOMAXCONN>` or to ``128``, whichever is less.
Yury Selivanovfe369a62015-09-13 08:29:19 -04001686(Contributed by Charles-François Natali in :issue:`21455`.)
1687
1688
Victor Stinner287452e2015-07-29 01:39:13 +02001689ssl
1690---
1691
Yury Selivanov95fd26b2015-09-12 17:50:58 -04001692.. _whatsnew-sslmemorybio:
1693
Yury Selivanovce917c7312015-09-10 17:35:38 -04001694Memory BIO Support
1695~~~~~~~~~~~~~~~~~~
Yury Selivanov7d6adab2015-08-05 19:01:51 -04001696
Yury Selivanovce917c7312015-09-10 17:35:38 -04001697(Contributed by Geert Jansen in :issue:`21965`.)
Victor Stinner287452e2015-07-29 01:39:13 +02001698
Yury Selivanovce917c7312015-09-10 17:35:38 -04001699The new :class:`~ssl.SSLObject` class has been added to provide SSL protocol
Yury Selivanova88cd642015-09-10 21:26:54 -04001700support for cases when the network I/O capabilities of :class:`~ssl.SSLSocket`
Martin Panter97ce0fa2015-11-14 01:14:54 +00001701are not necessary or are suboptimal. ``SSLObject`` represents
Yury Selivanova88cd642015-09-10 21:26:54 -04001702an SSL protocol instance, but does not implement any network I/O methods, and
Yury Selivanovce917c7312015-09-10 17:35:38 -04001703instead provides a memory buffer interface. The new :class:`~ssl.MemoryBIO`
1704class can be used to pass data between Python and an SSL protocol instance.
Yury Selivanov100fc3f2015-09-08 22:40:30 -04001705
Yury Selivanovce917c7312015-09-10 17:35:38 -04001706The memory BIO SSL support is primarily intended to be used in frameworks
Yury Selivanova88cd642015-09-10 21:26:54 -04001707implementing asynchronous I/O for which :class:`~ssl.SSLSocket`'s readiness
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001708model ("select/poll") is inefficient.
Yury Selivanov100fc3f2015-09-08 22:40:30 -04001709
Yury Selivanova33cb352015-09-13 11:21:25 -04001710A new :meth:`SSLContext.wrap_bio() <ssl.SSLContext.wrap_bio>` method can be used
1711to create a new ``SSLObject`` instance.
Yury Selivanovce917c7312015-09-10 17:35:38 -04001712
1713
1714Application-Layer Protocol Negotiation Support
1715~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1716
1717(Contributed by Benjamin Peterson in :issue:`20188`.)
1718
Martin Panter97ce0fa2015-11-14 01:14:54 +00001719Where OpenSSL support is present, the :mod:`ssl` module now implements
1720the *Application-Layer Protocol Negotiation* TLS extension as described
Yury Selivanovce917c7312015-09-10 17:35:38 -04001721in :rfc:`7301`.
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001722
Yury Selivanova33cb352015-09-13 11:21:25 -04001723The new :meth:`SSLContext.set_alpn_protocols() <ssl.SSLContext.set_alpn_protocols>`
Yury Selivanova88cd642015-09-10 21:26:54 -04001724can be used to specify which protocols a socket should advertise during
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001725the TLS handshake.
1726
1727The new
Yury Selivanova33cb352015-09-13 11:21:25 -04001728:meth:`SSLSocket.selected_alpn_protocol() <ssl.SSLSocket.selected_alpn_protocol>`
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001729returns the protocol that was selected during the TLS handshake.
Martin Panter97ce0fa2015-11-14 01:14:54 +00001730The :data:`~ssl.HAS_ALPN` flag indicates whether ALPN support is present.
Yury Selivanovce917c7312015-09-10 17:35:38 -04001731
1732
1733Other Changes
1734~~~~~~~~~~~~~
1735
Yury Selivanova33cb352015-09-13 11:21:25 -04001736There is a new :meth:`SSLSocket.version() <ssl.SSLSocket.version>` method to
1737query the actual protocol version in use.
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001738(Contributed by Antoine Pitrou in :issue:`20421`.)
Yury Selivanovce917c7312015-09-10 17:35:38 -04001739
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001740The :class:`~ssl.SSLSocket` class now implements
Yury Selivanova33cb352015-09-13 11:21:25 -04001741a :meth:`SSLSocket.sendfile() <ssl.SSLSocket.sendfile>` method.
Yury Selivanov508a81e2015-09-10 23:37:06 -04001742(Contributed by Giampaolo Rodola' in :issue:`17552`.)
Yury Selivanovce917c7312015-09-10 17:35:38 -04001743
Yury Selivanova33cb352015-09-13 11:21:25 -04001744The :meth:`SSLSocket.send() <ssl.SSLSocket.send>` method now raises either
Martin Panter97ce0fa2015-11-14 01:14:54 +00001745the :exc:`ssl.SSLWantReadError` or :exc:`ssl.SSLWantWriteError` exception on a
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001746non-blocking socket if the operation would block. Previously, it would return
1747``0``. (Contributed by Nikolaus Rath in :issue:`20951`.)
Yury Selivanovce917c7312015-09-10 17:35:38 -04001748
1749The :func:`~ssl.cert_time_to_seconds` function now interprets the input time
1750as UTC and not as local time, per :rfc:`5280`. Additionally, the return
1751value is always an :class:`int`. (Contributed by Akira Li in :issue:`19940`.)
1752
Yury Selivanova33cb352015-09-13 11:21:25 -04001753New :meth:`SSLObject.shared_ciphers() <ssl.SSLObject.shared_ciphers>` and
1754:meth:`SSLSocket.shared_ciphers() <ssl.SSLSocket.shared_ciphers>` methods return
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001755the list of ciphers sent by the client during the handshake.
1756(Contributed by Benjamin Peterson in :issue:`23186`.)
Yury Selivanovce917c7312015-09-10 17:35:38 -04001757
Yury Selivanova33cb352015-09-13 11:21:25 -04001758The :meth:`SSLSocket.do_handshake() <ssl.SSLSocket.do_handshake>`,
1759:meth:`SSLSocket.read() <ssl.SSLSocket.read>`,
1760:meth:`SSLSocket.shutdown() <ssl.SSLSocket.shutdown>`, and
Martin Panter97ce0fa2015-11-14 01:14:54 +00001761:meth:`SSLSocket.write() <ssl.SSLSocket.write>` methods of the :class:`~ssl.SSLSocket`
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001762class no longer reset the socket timeout every time bytes are received or sent.
1763The socket timeout is now the maximum total duration of the method.
1764(Contributed by Victor Stinner in :issue:`23853`.)
Yury Selivanovce917c7312015-09-10 17:35:38 -04001765
1766The :func:`~ssl.match_hostname` function now supports matching of IP addresses.
1767(Contributed by Antoine Pitrou in :issue:`23239`.)
1768
Yury Selivanov336b37b2015-09-09 12:23:01 -04001769
Yury Selivanov508a81e2015-09-10 23:37:06 -04001770sqlite3
1771-------
1772
Martin Panter97ce0fa2015-11-14 01:14:54 +00001773The :class:`~sqlite3.Row` class now fully supports the sequence protocol,
Serhiy Storchaka1c30e7e2015-09-11 20:55:28 +03001774in particular :func:`reversed` iteration and slice indexing.
Yury Selivanov508a81e2015-09-10 23:37:06 -04001775(Contributed by Claudiu Popa in :issue:`10203`; by Lucas Sinclair,
1776Jessica McKellar, and Serhiy Storchaka in :issue:`13583`.)
1777
Yury Selivanov100fc3f2015-09-08 22:40:30 -04001778
Yury Selivanov95fd26b2015-09-12 17:50:58 -04001779.. _whatsnew-subprocess:
1780
Gregory P. Smith6e730002015-04-14 16:14:25 -07001781subprocess
1782----------
1783
Yury Selivanova88cd642015-09-10 21:26:54 -04001784The new :func:`~subprocess.run` function has been added.
Martin Panter0e5eba22015-10-31 12:18:10 +00001785It runs the specified command and returns a
Yury Selivanova88cd642015-09-10 21:26:54 -04001786:class:`~subprocess.CompletedProcess` object, which describes a finished
1787process. The new API is more consistent and is the recommended approach
1788to invoking subprocesses in Python code that does not need to maintain
1789compatibility with earlier Python versions.
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001790(Contributed by Thomas Kluyver in :issue:`23342`.)
Yury Selivanovce917c7312015-09-10 17:35:38 -04001791
Yury Selivanov23950372015-09-12 23:46:39 -04001792Examples::
1793
1794 >>> subprocess.run(["ls", "-l"]) # doesn't capture output
1795 CompletedProcess(args=['ls', '-l'], returncode=0)
1796
1797 >>> subprocess.run("exit 1", shell=True, check=True)
1798 Traceback (most recent call last):
1799 ...
1800 subprocess.CalledProcessError: Command 'exit 1' returned non-zero exit status 1
1801
1802 >>> subprocess.run(["ls", "-l", "/dev/null"], stdout=subprocess.PIPE)
1803 CompletedProcess(args=['ls', '-l', '/dev/null'], returncode=0,
1804 stdout=b'crw-rw-rw- 1 root root 1, 3 Jan 23 16:23 /dev/null\n')
1805
Gregory P. Smith6e730002015-04-14 16:14:25 -07001806
Yury Selivanov4640b302015-05-31 17:21:38 -04001807sys
1808---
1809
Yury Selivanovce917c7312015-09-10 17:35:38 -04001810A new :func:`~sys.set_coroutine_wrapper` function allows setting a global
Yury Selivanova88cd642015-09-10 21:26:54 -04001811hook that will be called whenever a :term:`coroutine object <coroutine>`
1812is created by an :keyword:`async def` function. A corresponding
1813:func:`~sys.get_coroutine_wrapper` can be used to obtain a currently set
Yury Selivanov95fd26b2015-09-12 17:50:58 -04001814wrapper. Both functions are :term:`provisional <provisional api>`,
Yury Selivanov46a8b402015-09-12 15:52:04 -04001815and are intended for debugging purposes only. (Contributed by Yury Selivanov
1816in :issue:`24017`.)
Yury Selivanov4640b302015-05-31 17:21:38 -04001817
Yury Selivanova88cd642015-09-10 21:26:54 -04001818A new :func:`~sys.is_finalizing` function can be used to check if the Python
Yury Selivanovce917c7312015-09-10 17:35:38 -04001819interpreter is :term:`shutting down <interpreter shutdown>`.
1820(Contributed by Antoine Pitrou in :issue:`22696`.)
1821
Yury Selivanov100fc3f2015-09-08 22:40:30 -04001822
Eric V. Smith7a803892015-04-15 10:27:58 -04001823sysconfig
1824---------
1825
Yury Selivanovce917c7312015-09-10 17:35:38 -04001826The name of the user scripts directory on Windows now includes the first
Martin Panter97ce0fa2015-11-14 01:14:54 +00001827two components of the Python version. (Contributed by Paul Moore
Yury Selivanovce917c7312015-09-10 17:35:38 -04001828in :issue:`23437`.)
1829
Eric V. Smith7a803892015-04-15 10:27:58 -04001830
1831tarfile
1832-------
1833
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001834The *mode* argument of the :func:`~tarfile.open` function now accepts ``"x"``
1835to request exclusive creation. (Contributed by Berker Peksag in :issue:`21717`.)
Eric V. Smith7a803892015-04-15 10:27:58 -04001836
Martin Panter97ce0fa2015-11-14 01:14:54 +00001837The :meth:`TarFile.extractall() <tarfile.TarFile.extractall>` and
Yury Selivanova33cb352015-09-13 11:21:25 -04001838:meth:`TarFile.extract() <tarfile.TarFile.extract>` methods now take a keyword
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001839argument *numeric_only*. If set to ``True``, the extracted files and
1840directories will be owned by the numeric ``uid`` and ``gid`` from the tarfile.
1841If set to ``False`` (the default, and the behavior in versions prior to 3.5),
1842they will be owned by the named user and group in the tarfile.
1843(Contributed by Michael Vogt and Eric Smith in :issue:`23193`.)
Yury Selivanovce917c7312015-09-10 17:35:38 -04001844
Yury Selivanova33cb352015-09-13 11:21:25 -04001845The :meth:`TarFile.list() <tarfile.TarFile.list>` now accepts an optional
Yury Selivanov46a8b402015-09-12 15:52:04 -04001846*members* keyword argument that can be set to a subset of the list returned
Yury Selivanova33cb352015-09-13 11:21:25 -04001847by :meth:`TarFile.getmembers() <tarfile.TarFile.getmembers>`.
Yury Selivanov46a8b402015-09-12 15:52:04 -04001848(Contributed by Serhiy Storchaka in :issue:`21549`.)
1849
Eric V. Smith7a803892015-04-15 10:27:58 -04001850
Yury Selivanov100fc3f2015-09-08 22:40:30 -04001851threading
1852---------
1853
Martin Panter97ce0fa2015-11-14 01:14:54 +00001854Both the :meth:`Lock.acquire() <threading.Lock.acquire>` and
Yury Selivanova33cb352015-09-13 11:21:25 -04001855:meth:`RLock.acquire() <threading.RLock.acquire>` methods
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001856now use a monotonic clock for timeout management.
1857(Contributed by Victor Stinner in :issue:`22043`.)
Yury Selivanovce917c7312015-09-10 17:35:38 -04001858
Yury Selivanov100fc3f2015-09-08 22:40:30 -04001859
Victor Stinnerae586492014-09-02 23:18:25 +02001860time
1861----
1862
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001863The :func:`~time.monotonic` function is now always available.
1864(Contributed by Victor Stinner in :issue:`22043`.)
Yury Selivanovce917c7312015-09-10 17:35:38 -04001865
Victor Stinnerae586492014-09-02 23:18:25 +02001866
Yury Selivanov336b37b2015-09-09 12:23:01 -04001867timeit
1868------
1869
Serhiy Storchaka35a361f2015-09-13 12:07:54 +03001870A new command line option ``-u`` or :samp:`--unit={U}` can be used to specify the time
Yury Selivanova88cd642015-09-10 21:26:54 -04001871unit for the timer output. Supported options are ``usec``, ``msec``,
1872or ``sec``. (Contributed by Julian Gindi in :issue:`18983`.)
Yury Selivanovce917c7312015-09-10 17:35:38 -04001873
Yury Selivanov508a81e2015-09-10 23:37:06 -04001874The :func:`~timeit.timeit` function has a new *globals* parameter for
1875specifying the namespace in which the code will be running.
1876(Contributed by Ben Roberts in :issue:`2527`.)
1877
Yury Selivanov336b37b2015-09-09 12:23:01 -04001878
Zachary Ware7dc9dea2015-05-22 11:36:53 -05001879tkinter
1880-------
1881
Yury Selivanovce917c7312015-09-10 17:35:38 -04001882The :mod:`tkinter._fix` module used for setting up the Tcl/Tk environment
1883on Windows has been replaced by a private function in the :mod:`_tkinter`
1884module which makes no permanent changes to environment variables.
1885(Contributed by Zachary Ware in :issue:`20035`.)
1886
Zachary Ware7dc9dea2015-05-22 11:36:53 -05001887
Yury Selivanov95fd26b2015-09-12 17:50:58 -04001888.. _whatsnew-traceback:
1889
Yury Selivanov100fc3f2015-09-08 22:40:30 -04001890traceback
1891---------
1892
Yury Selivanovce917c7312015-09-10 17:35:38 -04001893New :func:`~traceback.walk_stack` and :func:`~traceback.walk_tb`
1894functions to conveniently traverse frame and traceback objects.
1895(Contributed by Robert Collins in :issue:`17911`.)
Yury Selivanov100fc3f2015-09-08 22:40:30 -04001896
Yury Selivanovce917c7312015-09-10 17:35:38 -04001897New lightweight classes: :class:`~traceback.TracebackException`,
Serhiy Storchaka35a361f2015-09-13 12:07:54 +03001898:class:`~traceback.StackSummary`, and :class:`~traceback.FrameSummary`.
Yury Selivanovce917c7312015-09-10 17:35:38 -04001899(Contributed by Robert Collins in :issue:`17911`.)
Yury Selivanov100fc3f2015-09-08 22:40:30 -04001900
Martin Panter97ce0fa2015-11-14 01:14:54 +00001901Both the :func:`~traceback.print_tb` and :func:`~traceback.print_stack` functions
Yury Selivanov5c3111e2015-09-10 18:04:35 -04001902now support negative values for the *limit* argument.
Yury Selivanovce917c7312015-09-10 17:35:38 -04001903(Contributed by Dmitry Kazakov in :issue:`22619`.)
Yury Selivanov336b37b2015-09-09 12:23:01 -04001904
1905
Yury Selivanovf3e40fa2015-05-21 11:50:30 -04001906types
1907-----
1908
Yury Selivanov1c73e692015-09-10 18:59:42 -04001909A new :func:`~types.coroutine` function to transform
1910:term:`generator <generator iterator>` and
1911:class:`generator-like <collections.abc.Generator>` objects into
1912:term:`awaitables <awaitable>`.
1913(Contributed by Yury Selivanov in :issue:`24017`.)
Yury Selivanovf3e40fa2015-05-21 11:50:30 -04001914
Martin Panter97ce0fa2015-11-14 01:14:54 +00001915A new type called :class:`~types.CoroutineType`, which is used for
1916:term:`coroutine` objects created by :keyword:`async def` functions.
Yury Selivanov1c73e692015-09-10 18:59:42 -04001917(Contributed by Yury Selivanov in :issue:`24400`.)
Yury Selivanovce917c7312015-09-10 17:35:38 -04001918
Yury Selivanov5376ba92015-06-22 12:19:30 -04001919
Benjamin Peterson48013832015-06-27 15:45:56 -05001920unicodedata
1921-----------
1922
Yury Selivanovce917c7312015-09-10 17:35:38 -04001923The :mod:`unicodedata` module now uses data from `Unicode 8.0.0
1924<http://unicode.org/versions/Unicode8.0.0/>`_.
1925
Benjamin Peterson48013832015-06-27 15:45:56 -05001926
Yury Selivanov336b37b2015-09-09 12:23:01 -04001927unittest
1928--------
1929
Yury Selivanova33cb352015-09-13 11:21:25 -04001930The :meth:`TestLoader.loadTestsFromModule() <unittest.TestLoader.loadTestsFromModule>`
Yury Selivanov46a8b402015-09-12 15:52:04 -04001931method now accepts a keyword-only argument *pattern* which is passed to
1932``load_tests`` as the third argument. Found packages are now checked for
1933``load_tests`` regardless of whether their path matches *pattern*, because it
1934is impossible for a package name to match the default pattern.
1935(Contributed by Robert Collins and Barry A. Warsaw in :issue:`16662`.)
1936
Martin Panter97ce0fa2015-11-14 01:14:54 +00001937Unittest discovery errors now are exposed in the
Yury Selivanov46a8b402015-09-12 15:52:04 -04001938:data:`TestLoader.errors <unittest.TestLoader.errors>` attribute of the
1939:class:`~unittest.TestLoader` instance.
1940(Contributed by Robert Collins in :issue:`19746`.)
1941
Yury Selivanovdddfffe2015-09-11 01:23:10 -04001942A new command line option ``--locals`` to show local variables in
Yury Selivanovce917c7312015-09-10 17:35:38 -04001943tracebacks. (Contributed by Robert Collins in :issue:`22936`.)
1944
Benjamin Peterson48013832015-06-27 15:45:56 -05001945
Yury Selivanov508a81e2015-09-10 23:37:06 -04001946unittest.mock
1947-------------
1948
Berker Peksag878bc872015-09-15 20:06:28 +03001949The :class:`~unittest.mock.Mock` class has the following improvements:
Yury Selivanov508a81e2015-09-10 23:37:06 -04001950
Martin Panter97ce0fa2015-11-14 01:14:54 +00001951* The class constructor has a new *unsafe* parameter, which causes mock
Yury Selivanov508a81e2015-09-10 23:37:06 -04001952 objects to raise :exc:`AttributeError` on attribute names starting
1953 with ``"assert"``.
1954 (Contributed by Kushal Das in :issue:`21238`.)
1955
Yury Selivanova33cb352015-09-13 11:21:25 -04001956* A new :meth:`Mock.assert_not_called() <unittest.mock.Mock.assert_not_called>`
Yury Selivanov508a81e2015-09-10 23:37:06 -04001957 method to check if the mock object was called.
1958 (Contributed by Kushal Das in :issue:`21262`.)
1959
1960The :class:`~unittest.mock.MagicMock` class now supports :meth:`__truediv__`,
1961:meth:`__divmod__` and :meth:`__matmul__` operators.
1962(Contributed by Johannes Baiter in :issue:`20968`, and Håkan Lövdahl
1963in :issue:`23581` and :issue:`23568`.)
1964
Yury Selivanov46a8b402015-09-12 15:52:04 -04001965It is no longer necessary to explicitly pass ``create=True`` to the
1966:func:`~unittest.mock.patch` function when patching builtin names.
1967(Contributed by Kushal Das in :issue:`17660`.)
1968
Yury Selivanov508a81e2015-09-10 23:37:06 -04001969
Yury Selivanovfe369a62015-09-13 08:29:19 -04001970urllib
1971------
1972
1973A new
1974:class:`request.HTTPPasswordMgrWithPriorAuth <urllib.request.HTTPPasswordMgrWithPriorAuth>`
1975class allows HTTP Basic Authentication credentials to be managed so as to
1976eliminate unnecessary ``401`` response handling, or to unconditionally send
1977credentials on the first request in order to communicate with servers that
1978return a ``404`` response instead of a ``401`` if the ``Authorization`` header
1979is not sent. (Contributed by Matej Cepl in :issue:`19494` and Akshit Khurana in
1980:issue:`7159`.)
1981
1982A new *quote_via* argument for the
Yury Selivanova33cb352015-09-13 11:21:25 -04001983:func:`parse.urlencode() <urllib.parse.urlencode>`
Yury Selivanovfe369a62015-09-13 08:29:19 -04001984function provides a way to control the encoding of query parts if needed.
1985(Contributed by Samwyse and Arnon Yaari in :issue:`13866`.)
1986
Yury Selivanova33cb352015-09-13 11:21:25 -04001987The :func:`request.urlopen() <urllib.request.urlopen>` function accepts an
Yury Selivanovfe369a62015-09-13 08:29:19 -04001988:class:`ssl.SSLContext` object as a *context* argument, which will be used for
1989the HTTPS connection. (Contributed by Alex Gaynor in :issue:`22366`.)
1990
Yury Selivanova33cb352015-09-13 11:21:25 -04001991The :func:`parse.urljoin() <urllib.parse.urljoin>` was updated to use the
Yury Selivanovfe369a62015-09-13 08:29:19 -04001992:rfc:`3986` semantics for the resolution of relative URLs, rather than
1993:rfc:`1808` and :rfc:`2396`.
1994(Contributed by Demian Brecht and Senthil Kumaran in :issue:`22118`.)
1995
1996
Berker Peksag3e887222014-07-02 08:37:22 +03001997wsgiref
1998-------
1999
Yury Selivanov5c3111e2015-09-10 18:04:35 -04002000The *headers* argument of the :class:`headers.Headers <wsgiref.headers.Headers>`
2001class constructor is now optional.
Yury Selivanovce917c7312015-09-10 17:35:38 -04002002(Contributed by Pablo Torres Navarrete and SilentGhost in :issue:`5800`.)
2003
Berker Peksag3e887222014-07-02 08:37:22 +03002004
Antoine Pitroub9d9ce72014-05-15 22:47:33 +02002005xmlrpc
2006------
2007
Serhiy Storchaka35a361f2015-09-13 12:07:54 +03002008The :class:`client.ServerProxy <xmlrpc.client.ServerProxy>` class now supports
Martin Panter97ce0fa2015-11-14 01:14:54 +00002009the :term:`context manager` protocol.
Yury Selivanovce917c7312015-09-10 17:35:38 -04002010(Contributed by Claudiu Popa in :issue:`20627`.)
Brett Cannon6eaac132014-05-09 12:28:22 -04002011
Martin Panter97ce0fa2015-11-14 01:14:54 +00002012The :class:`client.ServerProxy <xmlrpc.client.ServerProxy>` constructor now accepts
Yury Selivanov5c3111e2015-09-10 18:04:35 -04002013an optional :class:`ssl.SSLContext` instance.
Yury Selivanovce917c7312015-09-10 17:35:38 -04002014(Contributed by Alex Gaynor in :issue:`22960`.)
2015
Yury Selivanov100fc3f2015-09-08 22:40:30 -04002016
Serhiy Storchaka61de0872015-04-02 21:00:13 +03002017xml.sax
2018-------
2019
Yury Selivanov5c3111e2015-09-10 18:04:35 -04002020SAX parsers now support a character stream of the
2021:class:`xmlreader.InputSource <xml.sax.xmlreader.InputSource>` object.
Yury Selivanovce917c7312015-09-10 17:35:38 -04002022(Contributed by Serhiy Storchaka in :issue:`2175`.)
2023
Yury Selivanov46a8b402015-09-12 15:52:04 -04002024:func:`~xml.sax.parseString` now accepts a :class:`str` instance.
2025(Contributed by Serhiy Storchaka in :issue:`10590`.)
2026
Serhiy Storchaka61de0872015-04-02 21:00:13 +03002027
Serhiy Storchaka77d89972015-03-23 01:09:35 +02002028zipfile
2029-------
2030
Yury Selivanovce917c7312015-09-10 17:35:38 -04002031ZIP output can now be written to unseekable streams.
2032(Contributed by Serhiy Storchaka in :issue:`23252`.)
Serhiy Storchaka77d89972015-03-23 01:09:35 +02002033
Yury Selivanova33cb352015-09-13 11:21:25 -04002034The *mode* argument of :meth:`ZipFile.open() <zipfile.ZipFile.open>` method now
Yury Selivanov5c3111e2015-09-10 18:04:35 -04002035accepts ``"x"`` to request exclusive creation.
Yury Selivanovce917c7312015-09-10 17:35:38 -04002036(Contributed by Serhiy Storchaka in :issue:`21717`.)
Serhiy Storchaka764fc9b2015-03-25 10:09:41 +02002037
Victor Stinner01adf062014-03-18 00:53:32 +01002038
Yury Selivanov336b37b2015-09-09 12:23:01 -04002039Other module-level changes
2040==========================
2041
Martin Panter97ce0fa2015-11-14 01:14:54 +00002042Many functions in the :mod:`mmap`, :mod:`ossaudiodev`, :mod:`socket`,
Serhiy Storchaka1c30e7e2015-09-11 20:55:28 +03002043:mod:`ssl`, and :mod:`codecs` modules now accept writable
2044:term:`bytes-like objects <bytes-like object>`.
Yury Selivanovce917c7312015-09-10 17:35:38 -04002045(Contributed by Serhiy Storchaka in :issue:`23001`.)
Yury Selivanov336b37b2015-09-09 12:23:01 -04002046
2047
Victor Stinner01adf062014-03-18 00:53:32 +01002048Optimizations
2049=============
2050
Yury Selivanova88cd642015-09-10 21:26:54 -04002051The :func:`os.walk` function has been sped up by 3 to 5 times on POSIX systems,
2052and by 7 to 20 times on Windows. This was done using the new :func:`os.scandir`
Yury Selivanov5c3111e2015-09-10 18:04:35 -04002053function, which exposes file information from the underlying ``readdir`` or
Yury Selivanova88cd642015-09-10 21:26:54 -04002054``FindFirstFile``/``FindNextFile`` system calls. (Contributed by
Yury Selivanov5c3111e2015-09-10 18:04:35 -04002055Ben Hoyt with help from Victor Stinner in :issue:`23605`.)
Victor Stinner01adf062014-03-18 00:53:32 +01002056
Yury Selivanov5c3111e2015-09-10 18:04:35 -04002057Construction of ``bytes(int)`` (filled by zero bytes) is faster and uses less
2058memory for large objects. ``calloc()`` is used instead of ``malloc()`` to
2059allocate memory for these objects.
Yury Selivanova88cd642015-09-10 21:26:54 -04002060(Contributed by Victor Stinner in :issue:`21233`.)
Victor Stinner37f20342015-03-10 13:29:41 +01002061
Yury Selivanov5c3111e2015-09-10 18:04:35 -04002062Some operations on :mod:`ipaddress` :class:`~ipaddress.IPv4Network` and
2063:class:`~ipaddress.IPv6Network` have been massively sped up, such as
2064:meth:`~ipaddress.IPv4Network.subnets`, :meth:`~ipaddress.IPv4Network.supernet`,
2065:func:`~ipaddress.summarize_address_range`, :func:`~ipaddress.collapse_addresses`.
2066The speed up can range from 3 to 15 times.
Yury Selivanova88cd642015-09-10 21:26:54 -04002067(Contributed by Antoine Pitrou, Michel Albert, and Markus in
2068:issue:`21486`, :issue:`21487`, :issue:`20826`, :issue:`23266`.)
Victor Stinner01adf062014-03-18 00:53:32 +01002069
Yury Selivanov5c3111e2015-09-10 18:04:35 -04002070Pickling of :mod:`ipaddress` objects was optimized to produce significantly
2071smaller output. (Contributed by Serhiy Storchaka in :issue:`23133`.)
Yury Selivanov100fc3f2015-09-08 22:40:30 -04002072
Yury Selivanov5c3111e2015-09-10 18:04:35 -04002073Many operations on :class:`io.BytesIO` are now 50% to 100% faster.
2074(Contributed by Serhiy Storchaka in :issue:`15381` and David Wilson in
2075:issue:`22003`.)
Antoine Pitrou0dfce562014-05-15 22:55:40 +02002076
Yury Selivanov5c3111e2015-09-10 18:04:35 -04002077The :func:`marshal.dumps` function is now faster: 65-85% with versions 3
2078and 4, 20-25% with versions 0 to 2 on typical data, and up to 5 times in
2079best cases.
2080(Contributed by Serhiy Storchaka in :issue:`20416` and :issue:`23344`.)
Serhiy Storchaka87d0b452015-02-03 11:30:10 +02002081
Yury Selivanov5c3111e2015-09-10 18:04:35 -04002082The UTF-32 encoder is now 3 to 7 times faster.
2083(Contributed by Serhiy Storchaka in :issue:`15027`.)
Serhiy Storchakace921c622015-02-11 15:53:31 +02002084
Yury Selivanov5c3111e2015-09-10 18:04:35 -04002085Regular expressions are now parsed up to 10% faster.
2086(Contributed by Serhiy Storchaka in :issue:`19380`.)
Serhiy Storchaka0d4df752015-05-12 23:12:45 +03002087
Yury Selivanov5c3111e2015-09-10 18:04:35 -04002088The :func:`json.dumps` function was optimized to run with
2089``ensure_ascii=False`` as fast as with ``ensure_ascii=True``.
2090(Contributed by Naoki Inada in :issue:`23206`.)
Yury Selivanov100fc3f2015-09-08 22:40:30 -04002091
Yury Selivanov5c3111e2015-09-10 18:04:35 -04002092The :c:func:`PyObject_IsInstance` and :c:func:`PyObject_IsSubclass`
2093functions have been sped up in the common case that the second argument
2094has :class:`type` as its metaclass.
2095(Contributed Georg Brandl by in :issue:`22540`.)
Yury Selivanov100fc3f2015-09-08 22:40:30 -04002096
Yury Selivanov5c3111e2015-09-10 18:04:35 -04002097Method caching was slightly improved, yielding up to 5% performance
2098improvement in some benchmarks.
2099(Contributed by Antoine Pitrou in :issue:`22847`.)
Yury Selivanov336b37b2015-09-09 12:23:01 -04002100
Martin Panter97ce0fa2015-11-14 01:14:54 +00002101Objects from the :mod:`random` module now use 50% less memory on 64-bit
Yury Selivanov5c3111e2015-09-10 18:04:35 -04002102builds. (Contributed by Serhiy Storchaka in :issue:`23488`.)
Yury Selivanov336b37b2015-09-09 12:23:01 -04002103
Yury Selivanov5c3111e2015-09-10 18:04:35 -04002104The :func:`property` getter calls are up to 25% faster.
2105(Contributed by Joe Jevnik in :issue:`23910`.)
Yury Selivanov336b37b2015-09-09 12:23:01 -04002106
Yury Selivanov5c3111e2015-09-10 18:04:35 -04002107Instantiation of :class:`fractions.Fraction` is now up to 30% faster.
2108(Contributed by Stefan Behnel in :issue:`22464`.)
Yury Selivanov88d073d2015-09-09 22:46:40 -04002109
Yury Selivanov508a81e2015-09-10 23:37:06 -04002110String methods :meth:`~str.find`, :meth:`~str.rfind`, :meth:`~str.split`,
Martin Panter97ce0fa2015-11-14 01:14:54 +00002111:meth:`~str.partition` and the :keyword:`in` string operator are now significantly
Yury Selivanov508a81e2015-09-10 23:37:06 -04002112faster for searching 1-character substrings.
2113(Contributed by Serhiy Storchaka in :issue:`23573`.)
2114
Victor Stinner01adf062014-03-18 00:53:32 +01002115
2116Build and C API Changes
2117=======================
2118
Yury Selivanovc9739902015-09-10 18:26:44 -04002119New ``calloc`` functions were added:
Victor Stinnerdb067af2014-05-02 22:31:14 +02002120
Yury Selivanova7672ba2015-09-13 01:40:36 -04002121* :c:func:`PyMem_RawCalloc`,
2122* :c:func:`PyMem_Calloc`,
2123* :c:func:`PyObject_Calloc`,
2124* :c:func:`_PyObject_GC_Calloc`.
Yury Selivanov508a81e2015-09-10 23:37:06 -04002125
2126(Contributed by Victor Stinner in :issue:`21233`.)
2127
2128New encoding/decoding helper functions:
2129
Yury Selivanova7672ba2015-09-13 01:40:36 -04002130* :c:func:`Py_DecodeLocale` (replaced ``_Py_char2wchar()``),
2131* :c:func:`Py_EncodeLocale` (replaced ``_Py_wchar2char()``).
Yury Selivanov508a81e2015-09-10 23:37:06 -04002132
2133(Contributed by Victor Stinner in :issue:`18395`.)
2134
Yury Selivanovdddfffe2015-09-11 01:23:10 -04002135A new :c:func:`PyCodec_NameReplaceErrors` function to replace the unicode
Yury Selivanov4dde5872015-09-11 00:48:21 -04002136encode error with ``\N{...}`` escapes.
2137(Contributed by Serhiy Storchaka in :issue:`19676`.)
2138
Yury Selivanovdddfffe2015-09-11 01:23:10 -04002139A new :c:func:`PyErr_FormatV` function similar to :c:func:`PyErr_Format`,
Yury Selivanov4dde5872015-09-11 00:48:21 -04002140but accepts a ``va_list`` argument.
2141(Contributed by Antoine Pitrou in :issue:`18711`.)
2142
Yury Selivanovdddfffe2015-09-11 01:23:10 -04002143A new :c:data:`PyExc_RecursionError` exception.
Yury Selivanov4dde5872015-09-11 00:48:21 -04002144(Contributed by Georg Brandl in :issue:`19235`.)
2145
2146New :c:func:`PyModule_FromDefAndSpec`, :c:func:`PyModule_FromDefAndSpec2`,
Yury Selivanova33cb352015-09-13 11:21:25 -04002147and :c:func:`PyModule_ExecDef` functions introduced by :pep:`489` --
2148multi-phase extension module initialization.
Yury Selivanov4dde5872015-09-11 00:48:21 -04002149(Contributed by Petr Viktorin in :issue:`24268`.)
2150
2151New :c:func:`PyNumber_MatrixMultiply` and
2152:c:func:`PyNumber_InPlaceMatrixMultiply` functions to perform matrix
2153multiplication.
2154(Contributed by Benjamin Peterson in :issue:`21176`. See also :pep:`465`
2155for details.)
2156
Martin Panter97ce0fa2015-11-14 01:14:54 +00002157The :c:member:`PyTypeObject.tp_finalize` slot is now part of the stable ABI.
Victor Stinner01adf062014-03-18 00:53:32 +01002158
Yury Selivanov5c3111e2015-09-10 18:04:35 -04002159Windows builds now require Microsoft Visual C++ 14.0, which
2160is available as part of `Visual Studio 2015 <http://www.visualstudio.com>`_.
Victor Stinner01adf062014-03-18 00:53:32 +01002161
Martin Panter97ce0fa2015-11-14 01:14:54 +00002162Extension modules now include a platform information tag in their filename on
Yury Selivanovc9739902015-09-10 18:26:44 -04002163some platforms (the tag is optional, and CPython will import extensions without
Martin Panter97ce0fa2015-11-14 01:14:54 +00002164it, although if the tag is present and mismatched, the extension won't be
Yury Selivanovc9739902015-09-10 18:26:44 -04002165loaded):
2166
2167* On Linux, extension module filenames end with
2168 ``.cpython-<major><minor>m-<architecture>-<os>.pyd``:
2169
2170 * ``<major>`` is the major number of the Python version;
2171 for Python 3.5 this is ``3``.
2172
2173 * ``<minor>`` is the minor number of the Python version;
2174 for Python 3.5 this is ``5``.
2175
2176 * ``<architecture>`` is the hardware architecture the extension module
2177 was built to run on. It's most commonly either ``i386`` for 32-bit Intel
2178 platforms or ``x86_64`` for 64-bit Intel (and AMD) platforms.
2179
2180 * ``<os>`` is always ``linux-gnu``, except for extensions built to
2181 talk to the 32-bit ABI on 64-bit platforms, in which case it is
2182 ``linux-gnu32`` (and ``<architecture>`` will be ``x86_64``).
2183
2184* On Windows, extension module filenames end with
Yury Selivanova88cd642015-09-10 21:26:54 -04002185 ``<debug>.cp<major><minor>-<platform>.pyd``:
Yury Selivanovc9739902015-09-10 18:26:44 -04002186
2187 * ``<major>`` is the major number of the Python version;
2188 for Python 3.5 this is ``3``.
2189
2190 * ``<minor>`` is the minor number of the Python version;
2191 for Python 3.5 this is ``5``.
2192
2193 * ``<platform>`` is the platform the extension module was built for,
2194 either ``win32`` for Win32, ``win_amd64`` for Win64, ``win_ia64`` for
2195 Windows Itanium 64, and ``win_arm`` for Windows on ARM.
2196
2197 * If built in debug mode, ``<debug>`` will be ``_d``,
2198 otherwise it will be blank.
2199
2200* On OS X platforms, extension module filenames now end with ``-darwin.so``.
2201
2202* On all other platforms, extension module filenames are the same as they were
2203 with Python 3.4.
2204
Yury Selivanovce917c7312015-09-10 17:35:38 -04002205
Victor Stinner01adf062014-03-18 00:53:32 +01002206Deprecated
2207==========
2208
Yury Selivanov8fa6d4f2015-05-28 17:09:14 -04002209New Keywords
2210------------
2211
Yury Selivanov13b74ae2015-08-03 14:55:58 -04002212``async`` and ``await`` are not recommended to be used as variable, class,
2213function or module names. Introduced by :pep:`492` in Python 3.5, they will
2214become proper keywords in Python 3.7.
Yury Selivanov8fa6d4f2015-05-28 17:09:14 -04002215
2216
Yury Selivanov95fd26b2015-09-12 17:50:58 -04002217Deprecated Python Behavior
2218--------------------------
2219
Martin Panter97ce0fa2015-11-14 01:14:54 +00002220Raising the :exc:`StopIteration` exception inside a generator will now generate a silent
Yury Selivanov95fd26b2015-09-12 17:50:58 -04002221:exc:`PendingDeprecationWarning`, which will become a non-silent deprecation
2222warning in Python 3.6 and will trigger a :exc:`RuntimeError` in Python 3.7.
2223See :ref:`PEP 479: Change StopIteration handling inside generators <whatsnew-pep-479>`
2224for details.
2225
2226
Victor Stinner01adf062014-03-18 00:53:32 +01002227Unsupported Operating Systems
2228-----------------------------
2229
Yury Selivanova88cd642015-09-10 21:26:54 -04002230Windows XP is no longer supported by Microsoft, thus, per :PEP:`11`, CPython
22313.5 is no longer officially supported on this OS.
Victor Stinner01adf062014-03-18 00:53:32 +01002232
2233
2234Deprecated Python modules, functions and methods
2235------------------------------------------------
2236
Yury Selivanov5c3111e2015-09-10 18:04:35 -04002237The :mod:`formatter` module has now graduated to full deprecation and is still
2238slated for removal in Python 3.6.
Victor Stinner01adf062014-03-18 00:53:32 +01002239
Yury Selivanov5c3111e2015-09-10 18:04:35 -04002240The :func:`asyncio.async` function is deprecated in favor of
2241:func:`~asyncio.ensure_future`.
Yury Selivanov336b37b2015-09-09 12:23:01 -04002242
Yury Selivanov5c3111e2015-09-10 18:04:35 -04002243The :mod:`smtpd` module has in the past always decoded the DATA portion of
2244email messages using the ``utf-8`` codec. This can now be controlled by the
2245new *decode_data* keyword to :class:`~smtpd.SMTPServer`. The default value is
2246``True``, but this default is deprecated. Specify the *decode_data* keyword
2247with an appropriate value to avoid the deprecation warning.
R David Murray554bcbf2014-06-11 11:18:08 -04002248
Yury Selivanov5c3111e2015-09-10 18:04:35 -04002249Directly assigning values to the :attr:`~http.cookies.Morsel.key`,
2250:attr:`~http.cookies.Morsel.value` and
Yury Selivanova33cb352015-09-13 11:21:25 -04002251:attr:`~http.cookies.Morsel.coded_value` of :class:`http.cookies.Morsel`
2252objects is deprecated. Use the :meth:`~http.cookies.Morsel.set` method
Yury Selivanov5c3111e2015-09-10 18:04:35 -04002253instead. In addition, the undocumented *LegalChars* parameter of
Yury Selivanova33cb352015-09-13 11:21:25 -04002254:meth:`~http.cookies.Morsel.set` is deprecated, and is now ignored.
Serhiy Storchaka9c1a9b22015-03-18 10:59:57 +02002255
Yury Selivanov5c3111e2015-09-10 18:04:35 -04002256Passing a format string as keyword argument *format_string* to the
2257:meth:`~string.Formatter.format` method of the :class:`string.Formatter`
2258class has been deprecated.
Yury Selivanov46a8b402015-09-12 15:52:04 -04002259(Contributed by Serhiy Storchaka in :issue:`23671`.)
Serhiy Storchakab876df42015-03-24 22:30:46 +02002260
Yury Selivanov5c3111e2015-09-10 18:04:35 -04002261The :func:`platform.dist` and :func:`platform.linux_distribution` functions
2262are now deprecated and will be removed in Python 3.7. Linux distributions use
2263too many different ways of describing themselves, so the functionality is
2264left to a package.
2265(Contributed by Vajrasky Kok and Berker Peksag in :issue:`1322`.)
Victor Stinner01adf062014-03-18 00:53:32 +01002266
Yury Selivanov5c3111e2015-09-10 18:04:35 -04002267The previously undocumented ``from_function`` and ``from_builtin`` methods of
Yury Selivanova33cb352015-09-13 11:21:25 -04002268:class:`inspect.Signature` are deprecated. Use the new
2269:meth:`Signature.from_callable() <inspect.Signature.from_callable>`
2270method instead. (Contributed by Yury Selivanov in :issue:`24248`.)
Yury Selivanov57c74fc2015-05-20 23:07:02 -04002271
Yury Selivanov5c3111e2015-09-10 18:04:35 -04002272The :func:`inspect.getargspec` function is deprecated and scheduled to be
2273removed in Python 3.6. (See :issue:`20438` for details.)
Yury Selivanov945fff42015-05-22 16:28:05 -04002274
Yury Selivanov5c3111e2015-09-10 18:04:35 -04002275The :mod:`inspect` :func:`~inspect.getfullargspec`,
2276:func:`~inspect.getargvalues`, :func:`~inspect.getcallargs`,
2277:func:`~inspect.getargvalues`, :func:`~inspect.formatargspec`, and
2278:func:`~inspect.formatargvalues` functions are deprecated in favor of
Martin Panter97ce0fa2015-11-14 01:14:54 +00002279the :func:`inspect.signature` API.
Yury Selivanov5c3111e2015-09-10 18:04:35 -04002280(Contributed by Yury Selivanov in :issue:`20438`.)
Yury Selivanov945fff42015-05-22 16:28:05 -04002281
Serhiy Storchaka35a361f2015-09-13 12:07:54 +03002282Use of :const:`re.LOCALE` flag with str patterns or :const:`re.ASCII` is now
Yury Selivanov5c3111e2015-09-10 18:04:35 -04002283deprecated. (Contributed by Serhiy Storchaka in :issue:`22407`.)
Yury Selivanov100fc3f2015-09-08 22:40:30 -04002284
Yury Selivanov46a8b402015-09-12 15:52:04 -04002285Use of unrecognized special sequences consisting of ``'\'`` and an ASCII letter
2286in regular expression patterns and replacement patterns now raises a
2287deprecation warning and will be forbidden in Python 3.6.
2288(Contributed by Serhiy Storchaka in :issue:`23622`.)
2289
2290The undocumented and unofficial *use_load_tests* default argument of the
2291:meth:`unittest.TestLoader.loadTestsFromModule` method now is
2292deprecated and ignored.
2293(Contributed by Robert Collins and Barry A. Warsaw in :issue:`16662`.)
2294
Victor Stinner01adf062014-03-18 00:53:32 +01002295
R David Murraydf75fee2014-10-03 13:02:47 -04002296Removed
2297=======
2298
Berker Peksag8f791d32014-11-01 10:45:57 +02002299API and Feature Removals
2300------------------------
2301
2302The following obsolete and previously deprecated APIs and features have been
2303removed:
2304
R David Murraydf75fee2014-10-03 13:02:47 -04002305* The ``__version__`` attribute has been dropped from the email package. The
2306 email code hasn't been shipped separately from the stdlib for a long time,
2307 and the ``__version__`` string was not updated in the last few releases.
2308
Berker Peksag8f791d32014-11-01 10:45:57 +02002309* The internal ``Netrc`` class in the :mod:`ftplib` module was deprecated in
Serhiy Storchakac1ded292014-11-02 19:22:02 +02002310 3.4, and has now been removed.
2311 (Contributed by Matt Chaput in :issue:`6623`.)
R David Murraydf75fee2014-10-03 13:02:47 -04002312
Brett Cannonf299abd2015-04-13 14:21:02 -04002313* The concept of ``.pyo`` files has been removed.
2314
Yury Selivanov46a8b402015-09-12 15:52:04 -04002315* The JoinableQueue class in the provisional :mod:`asyncio` module was
2316 deprecated in 3.4.4 and is now removed.
Serhiy Storchaka1c30e7e2015-09-11 20:55:28 +03002317 (Contributed by A. Jesse Jiryu Davis in :issue:`23464`.)
R David Murraye81a7732015-04-12 18:47:56 -04002318
2319
Victor Stinner01adf062014-03-18 00:53:32 +01002320Porting to Python 3.5
2321=====================
2322
2323This section lists previously described changes and other bugfixes
2324that may require changes to your code.
2325
Yury Selivanov95fd26b2015-09-12 17:50:58 -04002326
2327Changes in Python behavior
2328--------------------------
2329
2330* Due to an oversight, earlier Python versions erroneously accepted the
2331 following syntax::
2332
2333 f(1 for x in [1], *args)
2334 f(1 for x in [1], **kwargs)
2335
2336 Python 3.5 now correctly raises a :exc:`SyntaxError`, as generator
2337 expressions must be put in parentheses if not a sole argument to a function.
2338
2339
Victor Stinnerdb067af2014-05-02 22:31:14 +02002340Changes in the Python API
2341-------------------------
2342
Victor Stinner6752d652015-07-29 01:11:10 +02002343* :pep:`475`: System calls are now retried when interrupted by a signal instead
2344 of raising :exc:`InterruptedError` if the Python signal handler does not
2345 raise an exception.
Victor Stinnera766ddf2015-03-26 23:50:57 +01002346
Benjamin Petersonee6bdc02014-03-20 18:00:35 -05002347* Before Python 3.5, a :class:`datetime.time` object was considered to be false
2348 if it represented midnight in UTC. This behavior was considered obscure and
2349 error-prone and has been removed in Python 3.5. See :issue:`13936` for full
2350 details.
Antoine Pitrou92c4d452014-04-29 10:05:59 +02002351
Yury Selivanov5c3111e2015-09-10 18:04:35 -04002352* The :meth:`ssl.SSLSocket.send()` method now raises either
2353 :exc:`ssl.SSLWantReadError` or :exc:`ssl.SSLWantWriteError`
Serhiy Storchaka1c30e7e2015-09-11 20:55:28 +03002354 on a non-blocking socket if the operation would block. Previously,
2355 it would return ``0``. (Contributed by Nikolaus Rath in :issue:`20951`.)
Victor Stinnerdb067af2014-05-02 22:31:14 +02002356
Martin Panter97ce0fa2015-11-14 01:14:54 +00002357* The ``__name__`` attribute of generators is now set from the function name,
Victor Stinner40ee3012014-06-16 15:59:28 +02002358 instead of being set from the code name. Use ``gen.gi_code.co_name`` to
2359 retrieve the code name. Generators also have a new ``__qualname__``
2360 attribute, the qualified name, which is now used for the representation
Serhiy Storchaka1c30e7e2015-09-11 20:55:28 +03002361 of a generator (``repr(gen)``).
2362 (Contributed by Victor Stinner in :issue:`21205`.)
Victor Stinner40ee3012014-06-16 15:59:28 +02002363
Ezio Melotti045160b2014-08-02 18:54:30 +03002364* The deprecated "strict" mode and argument of :class:`~html.parser.HTMLParser`,
2365 :meth:`HTMLParser.error`, and the :exc:`HTMLParserError` exception have been
Serhiy Storchakac1ded292014-11-02 19:22:02 +02002366 removed. (Contributed by Ezio Melotti in :issue:`15114`.)
Ezio Melotti045160b2014-08-02 18:54:30 +03002367 The *convert_charrefs* argument of :class:`~html.parser.HTMLParser` is
Serhiy Storchakac1ded292014-11-02 19:22:02 +02002368 now ``True`` by default. (Contributed by Berker Peksag in :issue:`21047`.)
Ezio Melotti045160b2014-08-02 18:54:30 +03002369
R David Murray861470c2014-10-05 11:47:01 -04002370* Although it is not formally part of the API, it is worth noting for porting
2371 purposes (ie: fixing tests) that error messages that were previously of the
2372 form "'sometype' does not support the buffer protocol" are now of the form "a
Serhiy Storchaka1c30e7e2015-09-11 20:55:28 +03002373 :term:`bytes-like object` is required, not 'sometype'".
2374 (Contributed by Ezio Melotti in :issue:`16518`.)
R David Murray861470c2014-10-05 11:47:01 -04002375
Brett Cannonb6e25562014-11-21 12:19:28 -05002376* If the current directory is set to a directory that no longer exists then
2377 :exc:`FileNotFoundError` will no longer be raised and instead
2378 :meth:`~importlib.machinery.FileFinder.find_spec` will return ``None``
Martin Panter97ce0fa2015-11-14 01:14:54 +00002379 **without** caching ``None`` in :data:`sys.path_importer_cache`, which is
Brett Cannonb6e25562014-11-21 12:19:28 -05002380 different than the typical case (:issue:`22834`).
2381
Berker Peksag088ca8b2015-02-06 10:17:49 +02002382* HTTP status code and messages from :mod:`http.client` and :mod:`http.server`
2383 were refactored into a common :class:`~http.HTTPStatus` enum. The values in
2384 :mod:`http.client` and :mod:`http.server` remain available for backwards
2385 compatibility. (Contributed by Demian Brecht in :issue:`21793`.)
Serhiy Storchakae4db7692014-12-23 16:28:28 +02002386
Yury Selivanova33cb352015-09-13 11:21:25 -04002387* When an import loader defines :meth:`importlib.machinery.Loader.exec_module`
Brett Cannon02d84542015-01-09 11:39:21 -05002388 it is now expected to also define
2389 :meth:`~importlib.machinery.Loader.create_module` (raises a
2390 :exc:`DeprecationWarning` now, will be an error in Python 3.6). If the loader
2391 inherits from :class:`importlib.abc.Loader` then there is nothing to do, else
2392 simply define :meth:`~importlib.machinery.Loader.create_module` to return
Serhiy Storchaka1c30e7e2015-09-11 20:55:28 +03002393 ``None``. (Contributed by Brett Cannon in :issue:`23014`.)
Brett Cannon02d84542015-01-09 11:39:21 -05002394
Yury Selivanov5c3111e2015-09-10 18:04:35 -04002395* The :func:`re.split` function always ignored empty pattern matches, so the
2396 ``"x*"`` pattern worked the same as ``"x+"``, and the ``"\b"`` pattern never
2397 worked. Now :func:`re.split` raises a warning if the pattern could match
Martin Panter97ce0fa2015-11-14 01:14:54 +00002398 an empty string. For compatibility, use patterns that never match an empty
Yury Selivanov5c3111e2015-09-10 18:04:35 -04002399 string (e.g. ``"x+"`` instead of ``"x*"``). Patterns that could only match
2400 an empty string (such as ``"\b"``) now raise an error.
Yury Selivanov46a8b402015-09-12 15:52:04 -04002401 (Contributed by Serhiy Storchaka in :issue:`22818`.)
Serhiy Storchaka83e80272015-02-03 11:04:19 +02002402
Yury Selivanova33cb352015-09-13 11:21:25 -04002403* The :class:`http.cookies.Morsel` dict-like interface has been made self
R David Murray1813c172015-03-29 17:09:21 -04002404 consistent: morsel comparison now takes the :attr:`~http.cookies.Morsel.key`
2405 and :attr:`~http.cookies.Morsel.value` into account,
2406 :meth:`~http.cookies.Morsel.copy` now results in a
R David Murrayba6ea9b2015-03-30 11:48:50 -04002407 :class:`~http.cookies.Morsel` instance rather than a :class:`dict`, and
2408 :meth:`~http.cookies.Morsel.update` will now raise an exception if any of the
R David Murray1813c172015-03-29 17:09:21 -04002409 keys in the update dictionary are invalid. In addition, the undocumented
2410 *LegalChars* parameter of :func:`~http.cookies.Morsel.set` is deprecated and
Serhiy Storchaka1c30e7e2015-09-11 20:55:28 +03002411 is now ignored. (Contributed by Demian Brecht in :issue:`2211`.)
R David Murray1813c172015-03-29 17:09:21 -04002412
Brett Cannonf299abd2015-04-13 14:21:02 -04002413* :pep:`488` has removed ``.pyo`` files from Python and introduced the optional
2414 ``opt-`` tag in ``.pyc`` file names. The
2415 :func:`importlib.util.cache_from_source` has gained an *optimization*
2416 parameter to help control the ``opt-`` tag. Because of this, the
2417 *debug_override* parameter of the function is now deprecated. `.pyo` files
2418 are also no longer supported as a file argument to the Python interpreter and
2419 thus serve no purpose when distributed on their own (i.e. sourcless code
2420 distribution). Due to the fact that the magic number for bytecode has changed
2421 in Python 3.5, all old `.pyo` files from previous versions of Python are
2422 invalid regardless of this PEP.
2423
Yury Selivanov4dde5872015-09-11 00:48:21 -04002424* The :mod:`socket` module now exports the :data:`~socket.CAN_RAW_FD_FRAMES`
2425 constant on linux 3.6 and greater.
Larry Hastingsa6cc5512015-04-13 17:48:40 -04002426
Yury Selivanova33cb352015-09-13 11:21:25 -04002427* The :func:`ssl.cert_time_to_seconds` function now interprets the input time
Yury Selivanova88cd642015-09-10 21:26:54 -04002428 as UTC and not as local time, per :rfc:`5280`. Additionally, the return
2429 value is always an :class:`int`. (Contributed by Akira Li in :issue:`19940`.)
2430
Zachary Ware3d3aedc2015-07-07 00:07:25 -05002431* The ``pygettext.py`` Tool now uses the standard +NNNN format for timezones in
R David Murray2b781292015-04-16 12:15:09 -04002432 the POT-Creation-Date header.
2433
Martin Panter97ce0fa2015-11-14 01:14:54 +00002434* The :mod:`smtplib` module now uses :data:`sys.stderr` instead of the previous
2435 module-level :data:`stderr` variable for debug output. If your (test)
2436 program depends on patching the module-level variable to capture the debug
R David Murray0c49b892015-04-16 17:14:42 -04002437 output, you will need to update it to capture sys.stderr instead.
2438
Serhiy Storchakad4ea03c2015-05-31 09:15:51 +03002439* The :meth:`str.startswith` and :meth:`str.endswith` methods no longer return
2440 ``True`` when finding the empty string and the indexes are completely out of
Serhiy Storchaka1c30e7e2015-09-11 20:55:28 +03002441 range. (Contributed by Serhiy Storchaka in :issue:`24284`.)
Serhiy Storchakad4ea03c2015-05-31 09:15:51 +03002442
Berker Peksag4333d8b2015-07-30 18:06:09 +03002443* The :func:`inspect.getdoc` function now returns documentation strings
2444 inherited from base classes. Documentation strings no longer need to be
2445 duplicated if the inherited documentation is appropriate. To suppress an
2446 inherited string, an empty string must be specified (or the documentation
2447 may be filled in). This change affects the output of the :mod:`pydoc`
Serhiy Storchaka1c30e7e2015-09-11 20:55:28 +03002448 module and the :func:`help` function.
2449 (Contributed by Serhiy Storchaka in :issue:`15582`.)
Berker Peksag4333d8b2015-07-30 18:06:09 +03002450
Berker Peksag9b93c6b2015-09-22 13:08:16 +03002451* Nested :func:`functools.partial` calls are now flattened. If you were
2452 relying on the previous behavior, you can now either add an attribute to a
2453 :func:`functools.partial` object or you can create a subclass of
2454 :func:`functools.partial`.
2455 (Contributed by Alexander Belopolsky in :issue:`7830`.)
2456
Victor Stinnerdb067af2014-05-02 22:31:14 +02002457Changes in the C API
2458--------------------
2459
Stefan Krahf5324d72015-01-29 14:29:51 +01002460* The undocumented :c:member:`~PyMemoryViewObject.format` member of the
2461 (non-public) :c:type:`PyMemoryViewObject` structure has been removed.
Stefan Krahf5324d72015-01-29 14:29:51 +01002462 All extensions relying on the relevant parts in ``memoryobject.h``
2463 must be rebuilt.
2464
Victor Stinnerd8f0d922014-06-02 21:57:10 +02002465* The :c:type:`PyMemAllocator` structure was renamed to
2466 :c:type:`PyMemAllocatorEx` and a new ``calloc`` field was added.
Serhiy Storchakadf4518c2014-11-18 23:34:33 +02002467
2468* Removed non-documented macro :c:macro:`PyObject_REPR` which leaked references.
2469 Use format character ``%R`` in :c:func:`PyUnicode_FromFormat`-like functions
2470 to format the :func:`repr` of the object.
Yury Selivanov508a81e2015-09-10 23:37:06 -04002471 (Contributed by Serhiy Storchaka in :issue:`22453`.)
Serhiy Storchaka490055a2015-03-01 10:03:02 +02002472
2473* Because the lack of the :attr:`__module__` attribute breaks pickling and
Martin Panter97ce0fa2015-11-14 01:14:54 +00002474 introspection, a deprecation warning is now raised for builtin types without
2475 the :attr:`__module__` attribute. This would be an AttributeError in
2476 the future.
Serhiy Storchaka1c30e7e2015-09-11 20:55:28 +03002477 (Contributed by Serhiy Storchaka in :issue:`20204`.)
Yury Selivanov50960882015-05-12 00:15:05 -04002478
Martin Panter97ce0fa2015-11-14 01:14:54 +00002479* As part of the :pep:`492` implementation, the ``tp_reserved`` slot of
Yury Selivanovf3e40fa2015-05-21 11:50:30 -04002480 :c:type:`PyTypeObject` was replaced with a
Yury Selivanov27947d52015-06-23 15:09:58 -04002481 :c:member:`tp_as_async` slot. Refer to :ref:`coro-objects` for
Yury Selivanov5376ba92015-06-22 12:19:30 -04002482 new types, structures and functions.
Yury Selivanov336b37b2015-09-09 12:23:01 -04002483