Zachary Ware | 569db2c | 2015-05-22 11:42:20 -0500 | [diff] [blame] | 1 | **************************** |
Victor Stinner | 01adf06 | 2014-03-18 00:53:32 +0100 | [diff] [blame] | 2 | What's New In Python 3.5 |
| 3 | **************************** |
| 4 | |
| 5 | :Release: |release| |
| 6 | :Date: |today| |
Yury Selivanov | 1f4d470 | 2015-09-09 09:27:29 -0400 | [diff] [blame^] | 7 | :Editor: Elvis Pranskevichus <elprans@gmail.com> |
Yury Selivanov | dfcfe13 | 2015-09-08 15:33:15 -0400 | [diff] [blame] | 8 | |
Victor Stinner | 01adf06 | 2014-03-18 00:53:32 +0100 | [diff] [blame] | 9 | .. Rules for maintenance: |
| 10 | |
| 11 | * Anyone can add text to this document. Do not spend very much time |
| 12 | on the wording of your changes, because your text will probably |
| 13 | get rewritten to some degree. |
| 14 | |
| 15 | * The maintainer will go through Misc/NEWS periodically and add |
| 16 | changes; it's therefore more important to add your changes to |
| 17 | Misc/NEWS than to this file. |
| 18 | |
| 19 | * This is not a complete list of every single change; completeness |
| 20 | is the purpose of Misc/NEWS. Some changes I consider too small |
| 21 | or esoteric to include. If such a change is added to the text, |
| 22 | I'll just remove it. (This is another reason you shouldn't spend |
| 23 | too much time on writing your addition.) |
| 24 | |
| 25 | * If you want to draw your new text to the attention of the |
| 26 | maintainer, add 'XXX' to the beginning of the paragraph or |
| 27 | section. |
| 28 | |
| 29 | * It's OK to just add a fragmentary note about a change. For |
| 30 | example: "XXX Describe the transmogrify() function added to the |
| 31 | socket module." The maintainer will research the change and |
| 32 | write the necessary text. |
| 33 | |
| 34 | * You can comment out your additions if you like, but it's not |
| 35 | necessary (especially when a final release is some months away). |
| 36 | |
| 37 | * Credit the author of a patch or bugfix. Just the name is |
| 38 | sufficient; the e-mail address isn't necessary. |
| 39 | |
| 40 | * It's helpful to add the bug/patch number as a comment: |
| 41 | |
| 42 | XXX Describe the transmogrify() function added to the socket |
| 43 | module. |
| 44 | (Contributed by P.Y. Developer in :issue:`12345`.) |
| 45 | |
| 46 | This saves the maintainer the effort of going through the Mercurial log |
| 47 | when researching a change. |
| 48 | |
| 49 | This article explains the new features in Python 3.5, compared to 3.4. |
Victor Stinner | 01adf06 | 2014-03-18 00:53:32 +0100 | [diff] [blame] | 50 | For full details, see the :source:`Misc/NEWS` file. |
| 51 | |
Benjamin Peterson | 52d1493 | 2015-03-27 16:07:35 -0400 | [diff] [blame] | 52 | .. note:: |
| 53 | |
| 54 | Prerelease users should be aware that this document is currently in draft |
| 55 | form. It will be updated substantially as Python 3.5 moves towards release, |
| 56 | so it's worth checking back even after reading earlier versions. |
Victor Stinner | 01adf06 | 2014-03-18 00:53:32 +0100 | [diff] [blame] | 57 | |
| 58 | |
| 59 | .. seealso:: |
| 60 | |
Berker Peksag | fa0423b | 2014-10-09 11:38:19 +0300 | [diff] [blame] | 61 | :pep:`478` - Python 3.5 Release Schedule |
Victor Stinner | 01adf06 | 2014-03-18 00:53:32 +0100 | [diff] [blame] | 62 | |
| 63 | |
| 64 | Summary -- Release highlights |
| 65 | ============================= |
| 66 | |
Victor Stinner | 93692bb | 2015-03-30 15:04:45 +0200 | [diff] [blame] | 67 | .. This section singles out the most important changes in Python 3.5. |
Victor Stinner | 01adf06 | 2014-03-18 00:53:32 +0100 | [diff] [blame] | 68 | Brevity is key. |
| 69 | |
| 70 | New syntax features: |
| 71 | |
Benjamin Peterson | 14ef1a1 | 2015-05-13 11:19:27 -0400 | [diff] [blame] | 72 | * :pep:`465`, a new matrix multiplication operator: ``a @ b``. |
| 73 | * :pep:`492`, coroutines with async and await syntax. |
Yury Selivanov | a5a0062 | 2015-08-04 12:52:16 -0400 | [diff] [blame] | 74 | * :pep:`448`, additional unpacking generalizations. |
Victor Stinner | 01adf06 | 2014-03-18 00:53:32 +0100 | [diff] [blame] | 75 | |
| 76 | New library modules: |
| 77 | |
Brett Cannon | cc4dfc1 | 2015-03-13 10:40:49 -0400 | [diff] [blame] | 78 | * :mod:`zipapp`: :ref:`Improving Python ZIP Application Support |
| 79 | <whatsnew-zipapp>` (:pep:`441`). |
Victor Stinner | 01adf06 | 2014-03-18 00:53:32 +0100 | [diff] [blame] | 80 | |
| 81 | New built-in features: |
| 82 | |
Victor Stinner | 93692bb | 2015-03-30 15:04:45 +0200 | [diff] [blame] | 83 | * ``bytes % args``, ``bytearray % args``: :pep:`461` - Adding ``%`` formatting |
Yury Selivanov | 40301c0 | 2015-09-08 23:28:06 -0400 | [diff] [blame] | 84 | to bytes and bytearray. |
| 85 | |
Gregory P. Smith | 8cb6569 | 2015-04-25 23:22:26 +0000 | [diff] [blame] | 86 | * ``b'\xf0\x9f\x90\x8d'.hex()``, ``bytearray(b'\xf0\x9f\x90\x8d').hex()``, |
| 87 | ``memoryview(b'\xf0\x9f\x90\x8d').hex()``: :issue:`9951` - A ``hex`` method |
| 88 | has been added to bytes, bytearray, and memoryview. |
Yury Selivanov | 40301c0 | 2015-09-08 23:28:06 -0400 | [diff] [blame] | 89 | |
Yury Selivanov | e13f8f3 | 2015-07-03 00:23:30 -0400 | [diff] [blame] | 90 | * Generators have new ``gi_yieldfrom`` attribute, which returns the |
| 91 | object being iterated by ``yield from`` expressions. (Contributed |
| 92 | by Benno Leslie and Yury Selivanov in :issue:`24450`.) |
Yury Selivanov | 40301c0 | 2015-09-08 23:28:06 -0400 | [diff] [blame] | 93 | |
Yury Selivanov | f488fb4 | 2015-07-03 01:04:23 -0400 | [diff] [blame] | 94 | * New :exc:`RecursionError` exception. (Contributed by Georg Brandl |
| 95 | in :issue:`19235`.) |
Victor Stinner | 01adf06 | 2014-03-18 00:53:32 +0100 | [diff] [blame] | 96 | |
| 97 | Implementation improvements: |
| 98 | |
Victor Stinner | 7143029 | 2014-03-18 01:18:21 +0100 | [diff] [blame] | 99 | * When the ``LC_TYPE`` locale is the POSIX locale (``C`` locale), |
| 100 | :py:data:`sys.stdin` and :py:data:`sys.stdout` are now using the |
| 101 | ``surrogateescape`` error handler, instead of the ``strict`` error handler |
| 102 | (:issue:`19977`). |
Victor Stinner | 01adf06 | 2014-03-18 00:53:32 +0100 | [diff] [blame] | 103 | |
Brett Cannon | f299abd | 2015-04-13 14:21:02 -0400 | [diff] [blame] | 104 | * :pep:`488`, the elimination of ``.pyo`` files. |
Yury Selivanov | 40301c0 | 2015-09-08 23:28:06 -0400 | [diff] [blame] | 105 | |
Nick Coghlan | d5cacbb | 2015-05-23 22:24:10 +1000 | [diff] [blame] | 106 | * :pep:`489`, multi-phase initialization of extension modules. |
Brett Cannon | f299abd | 2015-04-13 14:21:02 -0400 | [diff] [blame] | 107 | |
Victor Stinner | 01adf06 | 2014-03-18 00:53:32 +0100 | [diff] [blame] | 108 | Significantly Improved Library Modules: |
| 109 | |
Yury Selivanov | 5844436 | 2015-05-30 10:49:09 -0400 | [diff] [blame] | 110 | * :class:`collections.OrderedDict` is now implemented in C, which improves |
| 111 | its performance between 4x to 100x times. Contributed by Eric Snow in |
| 112 | :issue:`16991`. |
| 113 | |
Gregory P. Smith | ad577b9 | 2015-05-22 16:18:14 -0700 | [diff] [blame] | 114 | * You may now pass bytes to the :mod:`tempfile` module's APIs and it will |
| 115 | return the temporary pathname as bytes instead of str. It also accepts |
| 116 | a value of ``None`` on parameters where only str was accepted in the past to |
| 117 | do the right thing based on the types of the other inputs. Two functions, |
| 118 | :func:`gettempdirb` and :func:`gettempprefixb`, have been added to go along |
| 119 | with this. This behavior matches that of the :mod:`os` APIs. |
Victor Stinner | 01adf06 | 2014-03-18 00:53:32 +0100 | [diff] [blame] | 120 | |
Yury Selivanov | 7d6adab | 2015-08-05 19:01:51 -0400 | [diff] [blame] | 121 | * :mod:`ssl` module gained support for Memory BIO, which decouples SSL |
| 122 | protocol handling from network IO. (Contributed by Geert Jansen in |
| 123 | :issue:`21965`.) |
| 124 | |
Yury Selivanov | 40301c0 | 2015-09-08 23:28:06 -0400 | [diff] [blame] | 125 | * :mod:`traceback` has new lightweight and convenient to work with |
| 126 | classes :class:`~traceback.TracebackException`, |
| 127 | :class:`~traceback.StackSummary`, and :class:`traceback.FrameSummary`. |
| 128 | (Contributed by Robert Collins in :issue:`17911`.) |
| 129 | |
Victor Stinner | 01adf06 | 2014-03-18 00:53:32 +0100 | [diff] [blame] | 130 | Security improvements: |
| 131 | |
Yury Selivanov | 100fc3f | 2015-09-08 22:40:30 -0400 | [diff] [blame] | 132 | * SSLv3 is now disabled throughout the standard library. |
| 133 | It can still be enabled by instantiating a :class:`ssl.SSLContext` |
| 134 | manually. (See :issue:`22638` for more details; this change was |
| 135 | backported to CPython 3.4 and 2.7.) |
| 136 | |
| 137 | * HTTP cookie parsing is now stricter, in order to protect |
| 138 | against potential injection attacks. (Contributed by Antoine Pitrou |
| 139 | in :issue:`22796`.) |
Victor Stinner | 01adf06 | 2014-03-18 00:53:32 +0100 | [diff] [blame] | 140 | |
Steve Dower | 313fbf4 | 2015-07-17 16:48:48 -0700 | [diff] [blame] | 141 | Windows improvements: |
| 142 | |
| 143 | * A new installer for Windows has replaced the old MSI. See :ref:`using-on-windows` |
| 144 | for more information. |
Yury Selivanov | 40301c0 | 2015-09-08 23:28:06 -0400 | [diff] [blame] | 145 | |
Steve Dower | 313fbf4 | 2015-07-17 16:48:48 -0700 | [diff] [blame] | 146 | * Windows builds now use Microsoft Visual C++ 14.0, and extension modules |
| 147 | should use the same. |
| 148 | |
Yury Selivanov | 0ac5f28 | 2015-09-08 23:40:46 -0400 | [diff] [blame] | 149 | Please read on for a comprehensive list of user-facing changes, including many |
| 150 | other smaller improvements, CPython optimizations, deprecations, and potential |
| 151 | porting issues. |
Victor Stinner | 01adf06 | 2014-03-18 00:53:32 +0100 | [diff] [blame] | 152 | |
| 153 | |
Yury Selivanov | dfcfe13 | 2015-09-08 15:33:15 -0400 | [diff] [blame] | 154 | New Features |
| 155 | ============ |
| 156 | |
| 157 | .. _whatsnew-pep-492: |
| 158 | |
Yury Selivanov | f3e40fa | 2015-05-21 11:50:30 -0400 | [diff] [blame] | 159 | PEP 492 - Coroutines with async and await syntax |
| 160 | ------------------------------------------------ |
| 161 | |
Yury Selivanov | dfcfe13 | 2015-09-08 15:33:15 -0400 | [diff] [blame] | 162 | :pep:`492` greatly improves support for asynchronous programming in Python |
| 163 | by adding :term:`awaitable objects <awaitable>`, |
| 164 | :term:`coroutine functions <coroutine function>`, |
| 165 | :term:`asynchronous iteration <asynchronous iterable>`, |
| 166 | and :term:`asynchronous context managers <asynchronous context manager>`. |
Yury Selivanov | f3e40fa | 2015-05-21 11:50:30 -0400 | [diff] [blame] | 167 | |
Yury Selivanov | dfcfe13 | 2015-09-08 15:33:15 -0400 | [diff] [blame] | 168 | Coroutine functions are declared using the new :keyword:`async def` syntax:: |
Yury Selivanov | f3e40fa | 2015-05-21 11:50:30 -0400 | [diff] [blame] | 169 | |
Yury Selivanov | dfcfe13 | 2015-09-08 15:33:15 -0400 | [diff] [blame] | 170 | >>> async def coro(): |
| 171 | ... return 'spam' |
Yury Selivanov | f3e40fa | 2015-05-21 11:50:30 -0400 | [diff] [blame] | 172 | |
Yury Selivanov | dfcfe13 | 2015-09-08 15:33:15 -0400 | [diff] [blame] | 173 | Inside a coroutine function, a new :keyword:`await` expression can be used |
| 174 | to suspend coroutine execution until the result is available. Any object |
| 175 | can be *awaited*, as long as it implements the :term:`awaitable` protocol by |
| 176 | defining the :meth:`__await__` method. |
| 177 | |
| 178 | PEP 492 also adds :keyword:`async for` statement for convenient iteration |
| 179 | over asynchronous iterables. |
| 180 | |
| 181 | An example of a simple HTTP client written using the new syntax:: |
| 182 | |
| 183 | import asyncio |
| 184 | |
| 185 | async def http_get(domain): |
| 186 | reader, writer = await asyncio.open_connection(domain, 80) |
| 187 | |
| 188 | writer.write(b'\r\n'.join([ |
| 189 | b'GET / HTTP/1.1', |
| 190 | b'Host: %b' % domain.encode('latin-1'), |
| 191 | b'Connection: close', |
| 192 | b'', b'' |
| 193 | ])) |
| 194 | |
| 195 | async for line in reader: |
| 196 | print('>>>', line) |
| 197 | |
| 198 | writer.close() |
| 199 | |
| 200 | loop = asyncio.get_event_loop() |
| 201 | try: |
| 202 | loop.run_until_complete(http_get('example.com')) |
| 203 | finally: |
| 204 | loop.close() |
| 205 | |
| 206 | |
| 207 | Similarly to asynchronous iteration, there is a new syntax for asynchronous |
| 208 | context managers:: |
| 209 | |
| 210 | >>> import asyncio |
| 211 | >>> async def coro1(lock): |
| 212 | ... print('coro1: waiting for lock') |
| 213 | ... async with lock: |
| 214 | ... print('coro1: holding the lock') |
| 215 | ... await asyncio.sleep(1) |
| 216 | ... print('coro1: releasing the lock') |
| 217 | ... |
| 218 | >>> async def coro2(lock): |
| 219 | ... print('coro2: waiting for lock') |
| 220 | ... async with lock: |
| 221 | ... print('coro2: holding the lock') |
| 222 | ... await asyncio.sleep(1) |
| 223 | ... print('coro2: releasing the lock') |
| 224 | ... |
| 225 | >>> loop = asyncio.get_event_loop() |
| 226 | >>> lock = asyncio.Lock() |
| 227 | >>> coros = asyncio.gather(coro1(lock), coro2(lock), loop=loop) |
| 228 | >>> loop.run_until_complete(coros) |
| 229 | coro1: waiting for lock |
| 230 | coro1: holding the lock |
| 231 | coro2: waiting for lock |
| 232 | coro1: releasing the lock |
| 233 | coro2: holding the lock |
| 234 | coro2: releasing the lock |
| 235 | >>> loop.close() |
| 236 | |
| 237 | Note that both :keyword:`async for` and :keyword:`async with` can only |
| 238 | be used inside a coroutine function declared with :keyword:`async def`. |
| 239 | |
| 240 | Coroutine functions are intended to be ran inside a compatible event loop, |
| 241 | such as :class:`asyncio.Loop`. |
Yury Selivanov | f3e40fa | 2015-05-21 11:50:30 -0400 | [diff] [blame] | 242 | |
| 243 | .. seealso:: |
| 244 | |
| 245 | :pep:`492` -- Coroutines with async and await syntax |
Yury Selivanov | dfcfe13 | 2015-09-08 15:33:15 -0400 | [diff] [blame] | 246 | PEP written and implemented by Yury Selivanov. |
Yury Selivanov | f3e40fa | 2015-05-21 11:50:30 -0400 | [diff] [blame] | 247 | |
| 248 | |
Yury Selivanov | dfcfe13 | 2015-09-08 15:33:15 -0400 | [diff] [blame] | 249 | PEP 465 - A dedicated infix operator for matrix multiplication |
| 250 | -------------------------------------------------------------- |
Victor Stinner | 93692bb | 2015-03-30 15:04:45 +0200 | [diff] [blame] | 251 | |
Yury Selivanov | dfcfe13 | 2015-09-08 15:33:15 -0400 | [diff] [blame] | 252 | :pep:`465` adds the ``@`` infix operator for matrix multiplication. |
| 253 | Currently, no builtin Python types implement the new operator, however, it |
| 254 | can be implemented by defining :meth:`__matmul__`, :meth:`__rmatmul__`, |
| 255 | and :meth:`__imatmul__` for regular, reflected, and in-place matrix |
| 256 | multiplication. The semantics of these methods is similar to that of |
| 257 | methods defining other infix arithmetic operators. |
| 258 | |
| 259 | Matrix multiplication is a notably common operation in many fields of |
| 260 | mathematics, science, engineering, and the addition of ``@`` allows writing |
| 261 | cleaner code:: |
| 262 | |
Yury Selivanov | 0ac5f28 | 2015-09-08 23:40:46 -0400 | [diff] [blame] | 263 | S = (H @ beta - r).T @ inv(H @ V @ H.T) @ (H @ beta - r) |
| 264 | |
| 265 | instead of:: |
| 266 | |
| 267 | S = dot((dot(H, beta) - r).T, |
| 268 | dot(inv(dot(dot(H, V), H.T)), dot(H, beta) - r)) |
Yury Selivanov | dfcfe13 | 2015-09-08 15:33:15 -0400 | [diff] [blame] | 269 | |
| 270 | An upcoming release of NumPy 1.10 will add support for the new operator:: |
| 271 | |
| 272 | >>> import numpy |
| 273 | |
| 274 | >>> x = numpy.ones(3) |
| 275 | >>> x |
| 276 | array([ 1., 1., 1.]) |
| 277 | |
| 278 | >>> m = numpy.eye(3) |
| 279 | >>> m |
| 280 | array([[ 1., 0., 0.], |
| 281 | [ 0., 1., 0.], |
| 282 | [ 0., 0., 1.]]) |
| 283 | |
| 284 | >>> x @ m |
| 285 | array([ 1., 1., 1.]) |
| 286 | |
| 287 | |
| 288 | .. seealso:: |
| 289 | |
| 290 | :pep:`465` -- A dedicated infix operator for matrix multiplication |
| 291 | PEP written by Nathaniel J. Smith; implemented by Benjamin Peterson. |
| 292 | |
| 293 | |
| 294 | PEP 448 - Additional Unpacking Generalizations |
| 295 | ---------------------------------------------- |
| 296 | |
| 297 | :pep:`448` extends the allowed uses of the ``*`` iterable unpacking |
| 298 | operator and ``**`` dictionary unpacking operator. It is now possible |
| 299 | to use an arbitrary number of unpackings in function calls:: |
| 300 | |
| 301 | >>> print(*[1], *[2], 3, *[4, 5]) |
| 302 | 1 2 3 4 5 |
| 303 | |
| 304 | >>> def fn(a, b, c, d): |
| 305 | ... print(a, b, c, d) |
| 306 | ... |
| 307 | |
| 308 | >>> fn(**{'a': 1, 'c': 3}, **{'b': 2, 'd': 4}) |
| 309 | 1 2 3 4 |
| 310 | |
| 311 | Similarly, tuple, list, set, and dictionary displays allow multiple |
| 312 | unpackings:: |
| 313 | |
| 314 | >>> *range(4), 4 |
| 315 | (0, 1, 2, 3, 4) |
| 316 | >>> [*range(4), 4] |
| 317 | [0, 1, 2, 3, 4] |
| 318 | >>> {*range(4), 4, *(5, 6, 7)} |
| 319 | {0, 1, 2, 3, 4, 5, 6, 7} |
| 320 | >>> {'x': 1, **{'y': 2}} |
| 321 | {'x': 1, 'y': 2} |
| 322 | |
| 323 | .. seealso:: |
| 324 | |
| 325 | :pep:`448` -- Additional Unpacking Generalizations |
| 326 | PEP written by Joshua Landau; implemented by Neil Girdhar, |
| 327 | Thomas Wouters, and Joshua Landau. |
| 328 | |
| 329 | |
| 330 | PEP 461 - % formatting support for bytes and bytearray |
| 331 | ------------------------------------------------------ |
| 332 | |
| 333 | PEP 461 adds % formatting to :class:`bytes` and :class:`bytearray`, aiding in |
| 334 | handling data that is a mixture of binary and ASCII compatible text. This |
| 335 | feature also eases porting such code from Python 2. |
Victor Stinner | 93692bb | 2015-03-30 15:04:45 +0200 | [diff] [blame] | 336 | |
| 337 | Examples:: |
| 338 | |
| 339 | >>> b'Hello %s!' % b'World' |
| 340 | b'Hello World!' |
| 341 | >>> b'x=%i y=%f' % (1, 2.5) |
| 342 | b'x=1 y=2.500000' |
| 343 | |
| 344 | Unicode is not allowed for ``%s``, but it is accepted by ``%a`` (equivalent of |
| 345 | ``repr(obj).encode('ascii', 'backslashreplace')``):: |
| 346 | |
| 347 | >>> b'Hello %s!' % 'World' |
| 348 | Traceback (most recent call last): |
| 349 | File "<stdin>", line 1, in <module> |
| 350 | TypeError: %b requires bytes, or an object that implements __bytes__, not 'str' |
| 351 | >>> b'price: %a' % '10€' |
| 352 | b"price: '10\\u20ac'" |
| 353 | |
| 354 | .. seealso:: |
| 355 | |
| 356 | :pep:`461` -- Adding % formatting to bytes and bytearray |
Yury Selivanov | dfcfe13 | 2015-09-08 15:33:15 -0400 | [diff] [blame] | 357 | PEP written by Ethan Furman; implemented by Neil Schemenauer and |
| 358 | Ethan Furman. |
Yury Selivanov | 216d999 | 2015-08-04 12:42:20 -0400 | [diff] [blame] | 359 | |
| 360 | |
Yury Selivanov | 5df36af | 2015-08-04 12:46:57 -0400 | [diff] [blame] | 361 | PEP 484 - Type Hints |
| 362 | -------------------- |
| 363 | |
| 364 | This PEP introduces a provisional module to provide these standard |
| 365 | definitions and tools, along with some conventions for situations |
| 366 | where annotations are not available. |
| 367 | |
| 368 | For example, here is a simple function whose argument and return type |
| 369 | are declared in the annotations:: |
| 370 | |
Yury Selivanov | dfcfe13 | 2015-09-08 15:33:15 -0400 | [diff] [blame] | 371 | def greeting(name: str) -> str: |
| 372 | return 'Hello ' + name |
Yury Selivanov | 5df36af | 2015-08-04 12:46:57 -0400 | [diff] [blame] | 373 | |
| 374 | The type system supports unions, generic types, and a special type |
| 375 | named ``Any`` which is consistent with (i.e. assignable to and from) all |
| 376 | types. |
| 377 | |
| 378 | .. seealso:: |
| 379 | |
Yury Selivanov | 40c0ce4 | 2015-08-05 12:46:29 -0400 | [diff] [blame] | 380 | * :mod:`typing` module documentation |
Yury Selivanov | dfcfe13 | 2015-09-08 15:33:15 -0400 | [diff] [blame] | 381 | * :pep:`484` -- Type Hints |
| 382 | PEP written by Guido van Rossum, Jukka Lehtosalo, and Łukasz Langa; |
| 383 | implemented by Guido van Rossum. |
Yury Selivanov | 5df36af | 2015-08-04 12:46:57 -0400 | [diff] [blame] | 384 | |
| 385 | |
Victor Stinner | 6036e44 | 2015-03-08 01:58:04 +0100 | [diff] [blame] | 386 | PEP 471 - os.scandir() function -- a better and faster directory iterator |
| 387 | ------------------------------------------------------------------------- |
| 388 | |
Victor Stinner | 37f2034 | 2015-03-10 13:29:41 +0100 | [diff] [blame] | 389 | :pep:`471` adds a new directory iteration function, :func:`os.scandir`, |
| 390 | to the standard library. Additionally, :func:`os.walk` is now |
| 391 | implemented using :func:`os.scandir`, which speeds it up by 3-5 times |
| 392 | on POSIX systems and by 7-20 times on Windows systems. |
| 393 | |
Victor Stinner | 6036e44 | 2015-03-08 01:58:04 +0100 | [diff] [blame] | 394 | .. seealso:: |
| 395 | |
Yury Selivanov | dfcfe13 | 2015-09-08 15:33:15 -0400 | [diff] [blame] | 396 | :pep:`471` -- os.scandir() function -- a better and faster directory iterator |
| 397 | PEP written and implemented by Ben Hoyt with the help of Victor Stinner. |
Victor Stinner | 6036e44 | 2015-03-08 01:58:04 +0100 | [diff] [blame] | 398 | |
| 399 | |
Charles-François Natali | 6e6c59b | 2015-02-07 13:27:50 +0000 | [diff] [blame] | 400 | PEP 475: Retry system calls failing with EINTR |
| 401 | ---------------------------------------------- |
| 402 | |
Victor Stinner | f70e1ca | 2015-03-30 21:16:11 +0200 | [diff] [blame] | 403 | :pep:`475` adds support for automatic retry of system calls failing with |
| 404 | :py:data:`~errno.EINTR`: this means that user code doesn't have to deal with |
| 405 | EINTR or :exc:`InterruptedError` manually, and should make it more robust |
| 406 | against asynchronous signal reception. |
Charles-François Natali | 6e6c59b | 2015-02-07 13:27:50 +0000 | [diff] [blame] | 407 | |
Victor Stinner | 6752d65 | 2015-07-29 01:11:10 +0200 | [diff] [blame] | 408 | Examples of functions which are now retried when interrupted by a signal |
| 409 | instead of raising :exc:`InterruptedError` if the Python signal handler does |
| 410 | not raise an exception: |
| 411 | |
Yury Selivanov | 0ac5f28 | 2015-09-08 23:40:46 -0400 | [diff] [blame] | 412 | * :func:`open`, :func:`os.open`, :func:`io.open`; |
Victor Stinner | 6752d65 | 2015-07-29 01:11:10 +0200 | [diff] [blame] | 413 | |
Yury Selivanov | 0ac5f28 | 2015-09-08 23:40:46 -0400 | [diff] [blame] | 414 | * functions of the :mod:`faulthandler` module; |
Victor Stinner | 6752d65 | 2015-07-29 01:11:10 +0200 | [diff] [blame] | 415 | |
Yury Selivanov | 0ac5f28 | 2015-09-08 23:40:46 -0400 | [diff] [blame] | 416 | * :mod:`os` functions: :func:`~os.fchdir`, :func:`~os.fchmod`, |
| 417 | :func:`~os.fchown`, :func:`~os.fdatasync`, :func:`~os.fstat`, |
| 418 | :func:`~os.fstatvfs`, :func:`~os.fsync`, :func:`~os.ftruncate`, |
| 419 | :func:`~os.mkfifo`, :func:`~os.mknod`, :func:`~os.posix_fadvise`, |
| 420 | :func:`~os.posix_fallocate`, :func:`~os.pread`, :func:`~os.pwrite`, |
| 421 | :func:`~os.read`, :func:`~os.readv`, :func:`~os.sendfile`, |
| 422 | :func:`~os.wait3`, :func:`~os.wait4`, :func:`~os.wait`, |
| 423 | :func:`~os.waitid`, :func:`~os.waitpid`, :func:`~os.write`, |
| 424 | :func:`~os.writev`; |
Victor Stinner | 6752d65 | 2015-07-29 01:11:10 +0200 | [diff] [blame] | 425 | |
Yury Selivanov | 0ac5f28 | 2015-09-08 23:40:46 -0400 | [diff] [blame] | 426 | * special cases: :func:`os.close` and :func:`os.dup2` now ignore |
| 427 | :py:data:`~errno.EINTR` error, the syscall is not retried (see the PEP |
| 428 | for the rationale); |
Victor Stinner | 6752d65 | 2015-07-29 01:11:10 +0200 | [diff] [blame] | 429 | |
Yury Selivanov | 0ac5f28 | 2015-09-08 23:40:46 -0400 | [diff] [blame] | 430 | * :mod:`select` functions: :func:`~select.devpoll.poll`, |
| 431 | :func:`~select.epoll.poll`, :func:`~select.kqueue.control`, |
| 432 | :func:`~select.poll.poll`, :func:`~select.select`; |
Victor Stinner | 6752d65 | 2015-07-29 01:11:10 +0200 | [diff] [blame] | 433 | |
Yury Selivanov | 0ac5f28 | 2015-09-08 23:40:46 -0400 | [diff] [blame] | 434 | * :func:`socket.socket` methods: :meth:`~socket.socket.accept`, |
| 435 | :meth:`~socket.socket.connect` (except for non-blocking sockets), |
| 436 | :meth:`~socket.socket.recv`, :meth:`~socket.socket.recvfrom`, |
| 437 | :meth:`~socket.socket.recvmsg`, :meth:`~socket.socket.send`, |
| 438 | :meth:`~socket.socket.sendall`, :meth:`~socket.socket.sendmsg`, |
| 439 | :meth:`~socket.socket.sendto`; |
Victor Stinner | 6752d65 | 2015-07-29 01:11:10 +0200 | [diff] [blame] | 440 | |
Yury Selivanov | 0ac5f28 | 2015-09-08 23:40:46 -0400 | [diff] [blame] | 441 | * :func:`signal.sigtimedwait`, :func:`signal.sigwaitinfo`; |
| 442 | |
| 443 | * :func:`time.sleep`. |
Victor Stinner | 6752d65 | 2015-07-29 01:11:10 +0200 | [diff] [blame] | 444 | |
Charles-François Natali | 6e6c59b | 2015-02-07 13:27:50 +0000 | [diff] [blame] | 445 | .. seealso:: |
| 446 | |
| 447 | :pep:`475` -- Retry system calls failing with EINTR |
Yury Selivanov | dfcfe13 | 2015-09-08 15:33:15 -0400 | [diff] [blame] | 448 | PEP and implementation written by Charles-François Natali and |
| 449 | Victor Stinner, with the help of Antoine Pitrou (the french connection). |
Victor Stinner | 01adf06 | 2014-03-18 00:53:32 +0100 | [diff] [blame] | 450 | |
| 451 | |
Yury Selivanov | 8d006e7 | 2015-05-22 11:30:45 -0400 | [diff] [blame] | 452 | PEP 479: Change StopIteration handling inside generators |
| 453 | -------------------------------------------------------- |
| 454 | |
| 455 | :pep:`479` changes the behavior of generators: when a :exc:`StopIteration` |
| 456 | exception is raised inside a generator, it is replaced with a |
| 457 | :exc:`RuntimeError`. To enable the feature a ``__future__`` import should |
| 458 | be used:: |
| 459 | |
| 460 | from __future__ import generator_stop |
| 461 | |
| 462 | Without a ``__future__`` import, a :exc:`PendingDeprecationWarning` will be |
| 463 | raised. |
| 464 | |
Yury Selivanov | 8d006e7 | 2015-05-22 11:30:45 -0400 | [diff] [blame] | 465 | .. seealso:: |
| 466 | |
| 467 | :pep:`479` -- Change StopIteration handling inside generators |
Yury Selivanov | dfcfe13 | 2015-09-08 15:33:15 -0400 | [diff] [blame] | 468 | PEP written by Chris Angelico and Guido van Rossum. Implemented by |
| 469 | Chris Angelico, Yury Selivanov and Nick Coghlan. |
Yury Selivanov | 8d006e7 | 2015-05-22 11:30:45 -0400 | [diff] [blame] | 470 | |
| 471 | |
Steve Dower | 76998fe | 2015-02-26 14:25:33 -0800 | [diff] [blame] | 472 | PEP 486: Make the Python Launcher aware of virtual environments |
| 473 | --------------------------------------------------------------- |
| 474 | |
| 475 | :pep:`486` makes the Windows launcher (see :pep:`397`) aware of an active |
| 476 | virtual environment. When the default interpreter would be used and the |
| 477 | ``VIRTUAL_ENV`` environment variable is set, the interpreter in the virtual |
| 478 | environment will be used. |
| 479 | |
| 480 | .. seealso:: |
| 481 | |
| 482 | :pep:`486` -- Make the Python Launcher aware of virtual environments |
Yury Selivanov | dfcfe13 | 2015-09-08 15:33:15 -0400 | [diff] [blame] | 483 | PEP written and implemented by Paul Moore. |
Steve Dower | 76998fe | 2015-02-26 14:25:33 -0800 | [diff] [blame] | 484 | |
Brett Cannon | f299abd | 2015-04-13 14:21:02 -0400 | [diff] [blame] | 485 | |
| 486 | PEP 488: Elimination of PYO files |
| 487 | --------------------------------- |
| 488 | |
| 489 | :pep:`488` does away with the concept of ``.pyo`` files. This means that |
Benjamin Peterson | e328323 | 2015-05-26 21:40:28 -0500 | [diff] [blame] | 490 | ``.pyc`` files represent both unoptimized and optimized bytecode. To prevent the |
| 491 | need to constantly regenerate bytecode files, ``.pyc`` files now have an |
| 492 | optional ``opt-`` tag in their name when the bytecode is optimized. This has the |
| 493 | side-effect of no more bytecode file name clashes when running under either |
| 494 | ``-O`` or ``-OO``. Consequently, bytecode files generated from ``-O``, and |
| 495 | ``-OO`` may now exist simultaneously. :func:`importlib.util.cache_from_source` |
| 496 | has an updated API to help with this change. |
Brett Cannon | f299abd | 2015-04-13 14:21:02 -0400 | [diff] [blame] | 497 | |
| 498 | .. seealso:: |
| 499 | |
| 500 | :pep:`488` -- Elimination of PYO files |
Yury Selivanov | dfcfe13 | 2015-09-08 15:33:15 -0400 | [diff] [blame] | 501 | PEP written and implemented by Brett Cannon. |
Brett Cannon | f299abd | 2015-04-13 14:21:02 -0400 | [diff] [blame] | 502 | |
| 503 | |
Nick Coghlan | d5cacbb | 2015-05-23 22:24:10 +1000 | [diff] [blame] | 504 | PEP 489: Multi-phase extension module initialization |
| 505 | ---------------------------------------------------- |
| 506 | |
| 507 | :pep:`489` updates extension module initialization to take advantage of the |
| 508 | two step module loading mechanism introduced by :pep:`451` in Python 3.4. |
| 509 | |
| 510 | This change brings the import semantics of extension modules that opt-in to |
| 511 | using the new mechanism much closer to those of Python source and bytecode |
Nick Coghlan | 2ab5b09 | 2015-07-03 19:49:15 +1000 | [diff] [blame] | 512 | modules, including the ability to use any valid identifier as a module name, |
Nick Coghlan | d5cacbb | 2015-05-23 22:24:10 +1000 | [diff] [blame] | 513 | rather than being restricted to ASCII. |
| 514 | |
| 515 | .. seealso:: |
| 516 | |
Yury Selivanov | dfcfe13 | 2015-09-08 15:33:15 -0400 | [diff] [blame] | 517 | :pep:`489` -- Multi-phase extension module initialization |
| 518 | PEP written by Petr Viktorin, Stefan Behnel, and Nick Coghlan; |
Yury Selivanov | 1f4d470 | 2015-09-09 09:27:29 -0400 | [diff] [blame^] | 519 | implemented by Petr Viktorin. |
Yury Selivanov | dfcfe13 | 2015-09-08 15:33:15 -0400 | [diff] [blame] | 520 | |
Nick Coghlan | d5cacbb | 2015-05-23 22:24:10 +1000 | [diff] [blame] | 521 | |
Tal Einat | d5519ed | 2015-05-31 22:05:00 +0300 | [diff] [blame] | 522 | PEP 485: A function for testing approximate equality |
| 523 | ---------------------------------------------------- |
| 524 | |
| 525 | :pep:`485` adds the :func:`math.isclose` and :func:`cmath.isclose` |
| 526 | functions which tell whether two values are approximately equal or |
| 527 | "close" to each other. Whether or not two values are considered |
| 528 | close is determined according to given absolute and relative tolerances. |
| 529 | |
| 530 | .. seealso:: |
| 531 | |
| 532 | :pep:`485` -- A function for testing approximate equality |
Yury Selivanov | dfcfe13 | 2015-09-08 15:33:15 -0400 | [diff] [blame] | 533 | PEP written by Christopher Barker; implemented by Chris Barker and |
| 534 | Tal Einat. |
| 535 | |
Tal Einat | d5519ed | 2015-05-31 22:05:00 +0300 | [diff] [blame] | 536 | |
Victor Stinner | 01adf06 | 2014-03-18 00:53:32 +0100 | [diff] [blame] | 537 | Other Language Changes |
| 538 | ====================== |
| 539 | |
| 540 | Some smaller changes made to the core Python language are: |
| 541 | |
Serhiy Storchaka | 07985ef | 2015-01-25 22:56:57 +0200 | [diff] [blame] | 542 | * Added the ``'namereplace'`` error handlers. The ``'backslashreplace'`` |
| 543 | error handlers now works with decoding and translating. |
| 544 | (Contributed by Serhiy Storchaka in :issue:`19676` and :issue:`22286`.) |
Victor Stinner | 01adf06 | 2014-03-18 00:53:32 +0100 | [diff] [blame] | 545 | |
Serhiy Storchaka | 1dd4982 | 2015-03-20 16:54:57 +0200 | [diff] [blame] | 546 | * The :option:`-b` option now affects comparisons of :class:`bytes` with |
| 547 | :class:`int`. (Contributed by Serhiy Storchaka in :issue:`23681`) |
Victor Stinner | 01adf06 | 2014-03-18 00:53:32 +0100 | [diff] [blame] | 548 | |
Serhiy Storchaka | ad8a1c3 | 2015-05-12 23:16:55 +0300 | [diff] [blame] | 549 | * New Kazakh :ref:`codec <standard-encodings>` ``kz1048``. (Contributed by |
| 550 | Serhiy Storchaka in :issue:`22682`.) |
| 551 | |
Raymond Hettinger | eac503a | 2015-05-13 01:09:59 -0700 | [diff] [blame] | 552 | * Property docstrings are now writable. This is especially useful for |
| 553 | :func:`collections.namedtuple` docstrings. |
| 554 | (Contributed by Berker Peksag in :issue:`24064`.) |
| 555 | |
Serhiy Storchaka | f0eeedf | 2015-05-12 23:24:19 +0300 | [diff] [blame] | 556 | * New Tajik :ref:`codec <standard-encodings>` ``koi8_t``. (Contributed by |
| 557 | Serhiy Storchaka in :issue:`22681`.) |
| 558 | |
Victor Stinner | 01adf06 | 2014-03-18 00:53:32 +0100 | [diff] [blame] | 559 | |
| 560 | New Modules |
| 561 | =========== |
| 562 | |
Brett Cannon | cc4dfc1 | 2015-03-13 10:40:49 -0400 | [diff] [blame] | 563 | .. _whatsnew-zipapp: |
Victor Stinner | 01adf06 | 2014-03-18 00:53:32 +0100 | [diff] [blame] | 564 | |
Brett Cannon | cc4dfc1 | 2015-03-13 10:40:49 -0400 | [diff] [blame] | 565 | zipapp |
| 566 | ------ |
| 567 | |
| 568 | The new :mod:`zipapp` module (specified in :pep:`441`) provides an API and |
| 569 | command line tool for creating executable Python Zip Applications, which |
| 570 | were introduced in Python 2.6 in :issue:`1739468` but which were not well |
| 571 | publicised, either at the time or since. |
| 572 | |
| 573 | With the new module, bundling your application is as simple as putting all |
| 574 | the files, including a ``__main__.py`` file, into a directory ``myapp`` |
| 575 | and running:: |
| 576 | |
| 577 | $ python -m zipapp myapp |
| 578 | $ python myapp.pyz |
Victor Stinner | 01adf06 | 2014-03-18 00:53:32 +0100 | [diff] [blame] | 579 | |
| 580 | |
| 581 | Improved Modules |
| 582 | ================ |
| 583 | |
Berker Peksag | 8089cd6 | 2015-02-14 01:39:17 +0200 | [diff] [blame] | 584 | argparse |
| 585 | -------- |
| 586 | |
| 587 | * :class:`~argparse.ArgumentParser` now allows to disable |
| 588 | :ref:`abbreviated usage <prefix-matching>` of long options by setting |
| 589 | :ref:`allow_abbrev` to ``False``. |
| 590 | (Contributed by Jonathan Paugh, Steven Bethard, paul j3 and Daniel Eriksson.) |
| 591 | |
Yury Selivanov | 100fc3f | 2015-09-08 22:40:30 -0400 | [diff] [blame] | 592 | bz2 |
| 593 | --- |
| 594 | |
| 595 | * New option *max_length* for :meth:`~bz2.BZ2Decompressor.decompress` |
| 596 | to limit the maximum size of decompressed data. |
| 597 | (Contributed by Nikolaus Rath in :issue:`15955`.) |
| 598 | |
Berker Peksag | bf5e960 | 2015-02-06 10:21:37 +0200 | [diff] [blame] | 599 | cgi |
| 600 | --- |
| 601 | |
Berker Peksag | bd09d7b | 2015-02-11 15:32:34 +0200 | [diff] [blame] | 602 | * :class:`~cgi.FieldStorage` now supports the context management protocol. |
Berker Peksag | bf5e960 | 2015-02-06 10:21:37 +0200 | [diff] [blame] | 603 | (Contributed by Berker Peksag in :issue:`20289`.) |
| 604 | |
Tal Einat | d5519ed | 2015-05-31 22:05:00 +0300 | [diff] [blame] | 605 | cmath |
| 606 | ----- |
| 607 | |
| 608 | * :func:`cmath.isclose` function added. |
| 609 | (Contributed by Chris Barker and Tal Einat in :issue:`24270`.) |
| 610 | |
| 611 | |
R David Murray | c31e622 | 2014-09-29 11:25:00 -0400 | [diff] [blame] | 612 | code |
| 613 | ---- |
| 614 | |
| 615 | * The :func:`code.InteractiveInterpreter.showtraceback` method now prints |
Serhiy Storchaka | c1ded29 | 2014-11-02 19:22:02 +0200 | [diff] [blame] | 616 | the full chained traceback, just like the interactive interpreter. |
Berker Peksag | 088ca8b | 2015-02-06 10:17:49 +0200 | [diff] [blame] | 617 | (Contributed by Claudiu Popa in :issue:`17442`.) |
R David Murray | c31e622 | 2014-09-29 11:25:00 -0400 | [diff] [blame] | 618 | |
Raymond Hettinger | eac503a | 2015-05-13 01:09:59 -0700 | [diff] [blame] | 619 | collections |
| 620 | ----------- |
| 621 | |
| 622 | * You can now update docstrings produced by :func:`collections.namedtuple`:: |
| 623 | |
| 624 | Point = namedtuple('Point', ['x', 'y']) |
| 625 | Point.__doc__ = 'ordered pair' |
| 626 | Point.x.__doc__ = 'abscissa' |
| 627 | Point.y.__doc__ = 'ordinate' |
| 628 | |
| 629 | (Contributed by Berker Peksag in :issue:`24064`.) |
| 630 | |
Brett Cannon | f1a8df0 | 2014-09-12 10:39:48 -0400 | [diff] [blame] | 631 | compileall |
| 632 | ---------- |
| 633 | |
| 634 | * :func:`compileall.compile_dir` and :mod:`compileall`'s command-line interface |
| 635 | can now do parallel bytecode compilation. |
Serhiy Storchaka | c1ded29 | 2014-11-02 19:22:02 +0200 | [diff] [blame] | 636 | (Contributed by Claudiu Popa in :issue:`16104`.) |
Brett Cannon | f1a8df0 | 2014-09-12 10:39:48 -0400 | [diff] [blame] | 637 | |
Yury Selivanov | 100fc3f | 2015-09-08 22:40:30 -0400 | [diff] [blame] | 638 | * *quiet* parameter of :func:`compileall.compile_dir`, |
| 639 | :func:`compileall.compile_file`, and :func:`compileall.compile_path` |
| 640 | functions now has a multilevel value. New ``-qq`` command line option |
| 641 | is available for suppressing the output. |
| 642 | (Contributed by Thomas Kluyver in :issue:`21338`.) |
| 643 | |
| 644 | concurrent.futures |
| 645 | ------------------ |
| 646 | |
| 647 | * :meth:`~concurrent.futures.Executor.map` now takes a *chunksize* |
| 648 | argument to allow batching of tasks in child processes and improve |
| 649 | performance of ProcessPoolExecutor. |
| 650 | (Contributed by Dan O'Reilly in :issue:`11271`.) |
| 651 | |
Berker Peksag | bb44fe0 | 2014-11-28 23:28:06 +0200 | [diff] [blame] | 652 | contextlib |
| 653 | ---------- |
| 654 | |
| 655 | * The new :func:`contextlib.redirect_stderr` context manager(similar to |
| 656 | :func:`contextlib.redirect_stdout`) makes it easier for utility scripts to |
| 657 | handle inflexible APIs that write their output to :data:`sys.stderr` and |
| 658 | don't provide any options to redirect it. |
| 659 | (Contributed by Berker Peksag in :issue:`22389`.) |
| 660 | |
Steve Dower | d2bc389 | 2015-04-15 18:06:05 -0400 | [diff] [blame] | 661 | curses |
| 662 | ------ |
| 663 | * The new :func:`curses.update_lines_cols` function updates the variables |
| 664 | :envvar:`curses.LINES` and :envvar:`curses.COLS`. |
| 665 | |
Berker Peksag | 102029d | 2015-03-15 01:18:47 +0200 | [diff] [blame] | 666 | difflib |
| 667 | ------- |
| 668 | |
| 669 | * The charset of the HTML document generated by :meth:`difflib.HtmlDiff.make_file` |
| 670 | can now be customized by using *charset* keyword-only parameter. The default |
| 671 | charset of HTML document changed from ``'ISO-8859-1'`` to ``'utf-8'``. |
| 672 | (Contributed by Berker Peksag in :issue:`2052`.) |
| 673 | |
Greg Ward | 4d9d256 | 2015-04-20 20:21:21 -0400 | [diff] [blame] | 674 | * It's now possible to compare lists of byte strings with |
| 675 | :func:`difflib.diff_bytes` (fixes a regression from Python 2). |
| 676 | |
Berker Peksag | 618e315 | 2015-01-27 02:59:09 +0200 | [diff] [blame] | 677 | distutils |
| 678 | --------- |
| 679 | |
| 680 | * The ``build`` and ``build_ext`` commands now accept a ``-j`` |
| 681 | option to enable parallel building of extension modules. |
| 682 | (Contributed by Antoine Pitrou in :issue:`5309`.) |
| 683 | |
Serhiy Storchaka | b9cec6a | 2015-05-16 22:13:27 +0300 | [diff] [blame] | 684 | * Added support for the LZMA compression. |
| 685 | (Contributed by Serhiy Storchaka in :issue:`16314`.) |
| 686 | |
Antoine Pitrou | b9d9ce7 | 2014-05-15 22:47:33 +0200 | [diff] [blame] | 687 | doctest |
| 688 | ------- |
Giampaolo Rodola' | e09fb71 | 2014-04-04 15:34:17 +0200 | [diff] [blame] | 689 | |
Antoine Pitrou | b9d9ce7 | 2014-05-15 22:47:33 +0200 | [diff] [blame] | 690 | * :func:`doctest.DocTestSuite` returns an empty :class:`unittest.TestSuite` if |
Serhiy Storchaka | c1ded29 | 2014-11-02 19:22:02 +0200 | [diff] [blame] | 691 | *module* contains no docstrings instead of raising :exc:`ValueError`. |
| 692 | (Contributed by Glenn Jones in :issue:`15916`.) |
Antoine Pitrou | b9d9ce7 | 2014-05-15 22:47:33 +0200 | [diff] [blame] | 693 | |
R David Murray | b744f3a | 2015-05-16 15:41:07 -0400 | [diff] [blame] | 694 | email |
| 695 | ----- |
| 696 | |
R David Murray | fdb23c2 | 2015-05-17 14:24:33 -0400 | [diff] [blame] | 697 | * A new policy option :attr:`~email.policy.Policy.mangle_from_` controls |
| 698 | whether or not lines that start with "From " in email bodies are prefixed with |
| 699 | a '>' character by generators. The default is ``True`` for |
| 700 | :attr:`~email.policy.compat32` and ``False`` for all other policies. |
| 701 | (Contributed by Milan Oberkirch in :issue:`20098`.) |
| 702 | |
R David Murray | b744f3a | 2015-05-16 15:41:07 -0400 | [diff] [blame] | 703 | * A new method :meth:`~email.message.Message.get_content_disposition` provides |
| 704 | easy access to a canonical value for the :mailheader:`Content-Disposition` |
| 705 | header (``None`` if there is no such header). (Contributed by Abhilash Raj |
| 706 | in :issue:`21083`.) |
| 707 | |
R David Murray | 224ef3e | 2015-05-17 11:29:21 -0400 | [diff] [blame] | 708 | * A new policy option :attr:`~email.policy.EmailPolicy.utf8` can be set |
| 709 | ``True`` to encode email headers using the utf8 charset instead of using |
| 710 | encoded words. This allows ``Messages`` to be formatted according to |
| 711 | :rfc:`6532` and used with an SMTP server that supports the :rfc:`6531` |
| 712 | ``SMTPUTF8`` extension. (Contributed by R. David Murray in :issue:`24211`.) |
| 713 | |
Serhiy Storchaka | c2edcdd | 2014-09-11 12:17:37 +0300 | [diff] [blame] | 714 | glob |
| 715 | ---- |
| 716 | |
| 717 | * :func:`~glob.iglob` and :func:`~glob.glob` now support recursive search in |
| 718 | subdirectories using the "``**``" pattern. |
| 719 | (Contributed by Serhiy Storchaka in :issue:`13968`.) |
| 720 | |
Yury Selivanov | 100fc3f | 2015-09-08 22:40:30 -0400 | [diff] [blame] | 721 | heapq |
| 722 | ----- |
| 723 | |
| 724 | * :func:`~heapq.merge` has two new optional parameters ``reverse`` and |
| 725 | ``key``. (Contributed by Raymond Hettinger in :issue:`13742`.) |
| 726 | |
Guido van Rossum | 7ca1353 | 2015-05-23 15:27:51 -0700 | [diff] [blame] | 727 | idlelib and IDLE |
Terry Jan Reedy | 44825cf | 2015-05-23 18:19:42 -0400 | [diff] [blame] | 728 | ---------------- |
| 729 | |
| 730 | Since idlelib implements the IDLE shell and editor and is not intended for |
| 731 | import by other programs, it gets improvements with every release. See |
| 732 | :file:`Lib/idlelib/NEWS.txt` for a cumulative list of changes since 3.4.0, |
| 733 | as well as changes made in future 3.5.x releases. This file is also available |
| 734 | from the IDLE Help -> About Idle dialog. |
| 735 | |
Serhiy Storchaka | 38684c3 | 2014-09-09 19:07:49 +0300 | [diff] [blame] | 736 | imaplib |
| 737 | ------- |
| 738 | |
| 739 | * :class:`IMAP4` now supports the context management protocol. When used in a |
| 740 | :keyword:`with` statement, the IMAP4 ``LOGOUT`` command will be called |
| 741 | automatically at the end of the block. (Contributed by Tarek Ziadé and |
Serhiy Storchaka | c1ded29 | 2014-11-02 19:22:02 +0200 | [diff] [blame] | 742 | Serhiy Storchaka in :issue:`4972`.) |
Serhiy Storchaka | 38684c3 | 2014-09-09 19:07:49 +0300 | [diff] [blame] | 743 | |
R David Murray | a6429db | 2015-05-10 19:17:23 -0400 | [diff] [blame] | 744 | * :mod:`imaplib` now supports :rfc:`5161`: the :meth:`~imaplib.IMAP4.enable` |
| 745 | extension), and :rfc:`6855`: utf-8 support (internationalized email, via the |
| 746 | ``UTF8=ACCEPT`` argument to :meth:`~imaplib.IMAP4.enable`). A new attribute, |
| 747 | :attr:`~imaplib.IMAP4.utf8_enabled`, tracks whether or not :rfc:`6855` |
| 748 | support is enabled. Milan Oberkirch, R. David Murray, and Maciej Szulik in |
| 749 | :issue:`21800`.) |
| 750 | |
| 751 | * :mod:`imaplib` now automatically encodes non-ASCII string usernames and |
| 752 | passwords using ``UTF8``, as recommended by the RFCs. (Contributed by Milan |
| 753 | Oberkirch in :issue:`21800`.) |
| 754 | |
R David Murray | 2f60820 | 2014-06-26 12:27:57 -0400 | [diff] [blame] | 755 | imghdr |
| 756 | ------ |
| 757 | |
| 758 | * :func:`~imghdr.what` now recognizes the `OpenEXR <http://www.openexr.com>`_ |
Yury Selivanov | 100fc3f | 2015-09-08 22:40:30 -0400 | [diff] [blame] | 759 | format (contributed by Martin Vignali and Claudiu Popa in :issue:`20295`), |
| 760 | and the `WebP <https://en.wikipedia.org/wiki/WebP>`_ format (contributed |
| 761 | by Fabrice Aneche and Claudiu Popa in :issue:`20197`.) |
R David Murray | 2f60820 | 2014-06-26 12:27:57 -0400 | [diff] [blame] | 762 | |
Antoine Pitrou | b9d9ce7 | 2014-05-15 22:47:33 +0200 | [diff] [blame] | 763 | importlib |
| 764 | --------- |
| 765 | |
| 766 | * :class:`importlib.util.LazyLoader` allows for the lazy loading of modules in |
Serhiy Storchaka | c1ded29 | 2014-11-02 19:22:02 +0200 | [diff] [blame] | 767 | applications where startup time is paramount. |
| 768 | (Contributed by Brett Cannon in :issue:`17621`.) |
Antoine Pitrou | b9d9ce7 | 2014-05-15 22:47:33 +0200 | [diff] [blame] | 769 | |
| 770 | * :func:`importlib.abc.InspectLoader.source_to_code` is now a |
| 771 | static method to make it easier to work with source code in a string. |
| 772 | With a module object that you want to initialize you can then use |
| 773 | ``exec(code, module.__dict__)`` to execute the code in the module. |
| 774 | |
Brett Cannon | 2a17bde | 2014-05-30 14:55:29 -0400 | [diff] [blame] | 775 | * :func:`importlib.util.module_from_spec` is now the preferred way to create a |
| 776 | new module. Compared to :class:`types.ModuleType`, this new function will set |
| 777 | the various import-controlled attributes based on the passed-in spec object. |
Yury Selivanov | 100fc3f | 2015-09-08 22:40:30 -0400 | [diff] [blame] | 778 | (Contributed by Brett Cannon in :issue:`20383`.) |
Brett Cannon | 2a17bde | 2014-05-30 14:55:29 -0400 | [diff] [blame] | 779 | |
Antoine Pitrou | b9d9ce7 | 2014-05-15 22:47:33 +0200 | [diff] [blame] | 780 | inspect |
| 781 | ------- |
Victor Stinner | 01adf06 | 2014-03-18 00:53:32 +0100 | [diff] [blame] | 782 | |
Yury Selivanov | a5d63dd | 2014-03-27 11:31:43 -0400 | [diff] [blame] | 783 | * :class:`inspect.Signature` and :class:`inspect.Parameter` are now |
Serhiy Storchaka | c1ded29 | 2014-11-02 19:22:02 +0200 | [diff] [blame] | 784 | picklable and hashable. (Contributed by Yury Selivanov in :issue:`20726` |
| 785 | and :issue:`20334`.) |
Yury Selivanov | a5d63dd | 2014-03-27 11:31:43 -0400 | [diff] [blame] | 786 | |
Yury Selivanov | b907a51 | 2015-05-16 13:45:09 -0400 | [diff] [blame] | 787 | * New method :meth:`inspect.BoundArguments.apply_defaults`. (Contributed |
| 788 | by Yury Selivanov in :issue:`24190`.) |
| 789 | |
Yury Selivanov | da39645 | 2014-03-27 12:09:24 -0400 | [diff] [blame] | 790 | * New class method :meth:`inspect.Signature.from_callable`, which makes |
Serhiy Storchaka | c1ded29 | 2014-11-02 19:22:02 +0200 | [diff] [blame] | 791 | subclassing of :class:`~inspect.Signature` easier. (Contributed |
| 792 | by Yury Selivanov and Eric Snow in :issue:`17373`.) |
Yury Selivanov | da39645 | 2014-03-27 12:09:24 -0400 | [diff] [blame] | 793 | |
Yury Selivanov | bcd4fc1 | 2015-05-20 14:30:08 -0400 | [diff] [blame] | 794 | * New argument ``follow_wrapped`` for :func:`inspect.signature`. |
| 795 | (Contributed by Yury Selivanov in :issue:`20691`.) |
| 796 | |
Yury Selivanov | fdbeb2b | 2015-07-03 13:11:35 -0400 | [diff] [blame] | 797 | * New :func:`~inspect.iscoroutine`, :func:`~inspect.iscoroutinefunction` |
| 798 | and :func:`~inspect.isawaitable` functions. (Contributed by |
| 799 | Yury Selivanov in :issue:`24017`.) |
Yury Selivanov | f3e40fa | 2015-05-21 11:50:30 -0400 | [diff] [blame] | 800 | |
Yury Selivanov | 5376ba9 | 2015-06-22 12:19:30 -0400 | [diff] [blame] | 801 | * New :func:`~inspect.getcoroutinelocals` and :func:`~inspect.getcoroutinestate` |
| 802 | functions. (Contributed by Yury Selivanov in :issue:`24400`.) |
| 803 | |
Yury Selivanov | 100fc3f | 2015-09-08 22:40:30 -0400 | [diff] [blame] | 804 | * :func:`~inspect.stack`, :func:`~inspect.trace`, :func:`~inspect.getouterframes`, |
| 805 | and :func:`~inspect.getinnerframes` now return a list of named tuples. |
| 806 | (Contributed by Daniel Shahaf in :issue:`16808`.) |
| 807 | |
Antoine Pitrou | 0dfce56 | 2014-05-15 22:55:40 +0200 | [diff] [blame] | 808 | ipaddress |
| 809 | --------- |
| 810 | |
| 811 | * :class:`ipaddress.IPv4Network` and :class:`ipaddress.IPv6Network` now |
| 812 | accept an ``(address, netmask)`` tuple argument, so as to easily construct |
Serhiy Storchaka | c1ded29 | 2014-11-02 19:22:02 +0200 | [diff] [blame] | 813 | network objects from existing addresses. (Contributed by Peter Moody |
| 814 | and Antoine Pitrou in :issue:`16531`.) |
Antoine Pitrou | 0dfce56 | 2014-05-15 22:55:40 +0200 | [diff] [blame] | 815 | |
Berker Peksag | 39e4c4d | 2014-11-10 09:56:54 +0200 | [diff] [blame] | 816 | json |
| 817 | ---- |
| 818 | |
| 819 | * The output of :mod:`json.tool` command line interface is now in the same |
| 820 | order as the input. Use the :option:`--sort-keys` option to sort the output |
| 821 | of dictionaries alphabetically by key. (Contributed by Berker Peksag in |
| 822 | :issue:`21650`.) |
| 823 | |
Serhiy Storchaka | 47efb4a | 2015-01-26 13:16:30 +0200 | [diff] [blame] | 824 | * JSON decoder now raises :exc:`json.JSONDecodeError` instead of |
| 825 | :exc:`ValueError`. (Contributed by Serhiy Storchaka in :issue:`19361`.) |
| 826 | |
Yury Selivanov | 100fc3f | 2015-09-08 22:40:30 -0400 | [diff] [blame] | 827 | locale |
| 828 | ------ |
| 829 | |
| 830 | * New :func:`~locale.delocalize` function to convert a string into a |
| 831 | normalized number string, following the ``LC_NUMERIC`` settings. |
| 832 | (Contributed by Cédric Krier in :issue:`13918`.) |
| 833 | |
| 834 | logging |
| 835 | ------- |
| 836 | |
| 837 | * All logging methods :meth:`~logging.Logger.log`, :meth:`~logging.Logger.exception`, |
| 838 | :meth:`~logging.Logger.critical`, :meth:`~logging.Logger.debug`, etc, |
| 839 | now accept exception instances for ``exc_info`` parameter, in addition |
| 840 | to boolean values and exception tuples. |
| 841 | (Contributed by Yury Selivanov in :issue:`20537`.) |
| 842 | |
| 843 | * :class:`~logging.handlers.HTTPHandler` now accepts optional |
| 844 | :class:`ssl.SSLContext` instance to configure the SSL settings used |
| 845 | for HTTP connection. |
| 846 | (Contributed by Alex Gaynor in :issue:`22788`.) |
| 847 | |
| 848 | lzma |
| 849 | ---- |
| 850 | |
| 851 | * New option *max_length* for :meth:`~lzma.LZMADecompressor.decompress` |
| 852 | to limit the maximum size of decompressed data. |
| 853 | (Contributed by Martin Panter in :issue:`15955`.) |
| 854 | |
| 855 | |
Tal Einat | f67b0a3 | 2015-05-31 22:18:31 +0300 | [diff] [blame] | 856 | math |
| 857 | ---- |
| 858 | |
| 859 | * :data:`math.inf` and :data:`math.nan` constants added. (Contributed by Mark |
| 860 | Dickinson in :issue:`23185`.) |
| 861 | * :func:`math.isclose` function added. |
| 862 | (Contributed by Chris Barker and Tal Einat in :issue:`24270`.) |
| 863 | |
Zachary Ware | 63f277b | 2014-06-19 09:46:37 -0500 | [diff] [blame] | 864 | os |
| 865 | -- |
| 866 | |
Victor Stinner | 37f2034 | 2015-03-10 13:29:41 +0100 | [diff] [blame] | 867 | * New :func:`os.scandir` function that exposes file information from |
| 868 | the operating system when listing a directory. :func:`os.scandir` |
| 869 | returns an iterator of :class:`os.DirEntry` objects corresponding to |
| 870 | the entries in the directory given by *path*. (Contributed by Ben |
| 871 | Hoyt with the help of Victor Stinner in :issue:`22524`.) |
Victor Stinner | 6036e44 | 2015-03-08 01:58:04 +0100 | [diff] [blame] | 872 | |
Victor Stinner | e1d24f7 | 2014-07-24 12:44:07 +0200 | [diff] [blame] | 873 | * :class:`os.stat_result` now has a :attr:`~os.stat_result.st_file_attributes` |
Serhiy Storchaka | c1ded29 | 2014-11-02 19:22:02 +0200 | [diff] [blame] | 874 | attribute on Windows. (Contributed by Ben Hoyt in :issue:`21719`.) |
Zachary Ware | 63f277b | 2014-06-19 09:46:37 -0500 | [diff] [blame] | 875 | |
Victor Stinner | ace8848 | 2015-07-29 02:28:32 +0200 | [diff] [blame] | 876 | * :func:`os.urandom`: On Linux 3.17 and newer, the ``getrandom()`` syscall is |
| 877 | now used when available. On OpenBSD 5.6 and newer, the C ``getentropy()`` |
| 878 | function is now used. These functions avoid the usage of an internal file |
| 879 | descriptor. |
| 880 | |
Yury Selivanov | 100fc3f | 2015-09-08 22:40:30 -0400 | [diff] [blame] | 881 | * New :func:`os.get_blocking` and :func:`os.set_blocking` functions to |
| 882 | get and set the blocking mode of file descriptors. |
| 883 | (Contributed by Victor Stinner in :issue:`22054`.) |
| 884 | |
Serhiy Storchaka | 3822093 | 2015-03-31 15:31:53 +0300 | [diff] [blame] | 885 | os.path |
| 886 | ------- |
| 887 | |
| 888 | * New :func:`~os.path.commonpath` function that extracts common path prefix. |
| 889 | Unlike the :func:`~os.path.commonprefix` function, it always returns a valid |
Larry Hastings | d5b129c | 2015-08-24 12:49:22 -0700 | [diff] [blame] | 890 | path. (Contributed by Rafik Draoui and Serhiy Storchaka in :issue:`10395`.) |
Serhiy Storchaka | 3822093 | 2015-03-31 15:31:53 +0300 | [diff] [blame] | 891 | |
Yury Selivanov | 100fc3f | 2015-09-08 22:40:30 -0400 | [diff] [blame] | 892 | pathlib |
| 893 | ------- |
| 894 | |
| 895 | * New :meth:`~pathlib.Path.samefile` method to check if other path object |
| 896 | points to the same file. (Contributed by Vajrasky Kok and Antoine Pitrou |
| 897 | in :issue:`19775`.) |
| 898 | |
| 899 | * :meth:`~pathlib.Path.mkdir` has a new optional parameter ``exist_ok`` |
| 900 | to mimic ``mkdir -p`` and :func:`os.makrdirs` functionality. |
| 901 | (Contributed by Berker Peksag in :issue:`21539`.) |
| 902 | |
| 903 | * New :meth:`~pathlib.Path.expanduser` to expand ``~`` and ``~user`` |
| 904 | constructs. |
| 905 | (Contributed by Serhiy Storchaka and Claudiu Popa in :issue:`19776`.) |
| 906 | |
| 907 | * New class method :meth:`~pathlib.Path.home` to get an instance of |
| 908 | :class:`~pathlib.Path` object representing the user’s home directory. |
| 909 | (Contributed by Victor Salgado and Mayank Tripathi in :issue:`19777`.) |
| 910 | |
Serhiy Storchaka | 58e4134 | 2015-03-31 14:07:24 +0300 | [diff] [blame] | 911 | pickle |
| 912 | ------ |
| 913 | |
| 914 | * Serializing more "lookupable" objects (such as unbound methods or nested |
| 915 | classes) now are supported with pickle protocols < 4. |
| 916 | (Contributed by Serhiy Storchaka in :issue:`23611`.) |
| 917 | |
R David Murray | b8cd3e4 | 2015-05-16 15:05:53 -0400 | [diff] [blame] | 918 | poplib |
| 919 | ------ |
| 920 | |
| 921 | * A new command :meth:`~poplib.POP3.utf8` enables :rfc:`6856` |
| 922 | (internationalized email) support if the POP server supports it. (Contributed |
| 923 | by Milan OberKirch in :issue:`21804`.) |
| 924 | |
Serhiy Storchaka | 9baa5b2 | 2014-09-29 22:49:23 +0300 | [diff] [blame] | 925 | re |
| 926 | -- |
| 927 | |
| 928 | * Number of capturing groups in regular expression is no longer limited by 100. |
| 929 | (Contributed by Serhiy Storchaka in :issue:`22437`.) |
| 930 | |
Serhiy Storchaka | 7438e4b | 2014-10-10 11:06:31 +0300 | [diff] [blame] | 931 | * Now unmatched groups are replaced with empty strings in :func:`re.sub` |
| 932 | and :func:`re.subn`. (Contributed by Serhiy Storchaka in :issue:`1519638`.) |
| 933 | |
Yury Selivanov | 100fc3f | 2015-09-08 22:40:30 -0400 | [diff] [blame] | 934 | readline |
| 935 | -------- |
| 936 | |
| 937 | * New :func:`~readline.append_history_file` function. |
| 938 | (Contributed by Bruno Cauet in :issue:`22940`.) |
| 939 | |
R David Murray | 6ffface | 2014-06-11 14:40:13 -0400 | [diff] [blame] | 940 | shutil |
| 941 | ------ |
| 942 | |
| 943 | * :func:`~shutil.move` now accepts a *copy_function* argument, allowing, |
| 944 | for example, :func:`~shutil.copy` to be used instead of the default |
| 945 | :func:`~shutil.copy2` if there is a need to ignore metadata. (Contributed by |
| 946 | Claudiu Popa in :issue:`19840`.) |
| 947 | |
Yury Selivanov | 100fc3f | 2015-09-08 22:40:30 -0400 | [diff] [blame] | 948 | * :func:`~shutil.make_archive` now supports *xztar* format. |
| 949 | (Contributed by Serhiy Storchaka in :issue:`5411`.) |
| 950 | |
Antoine Pitrou | b9d9ce7 | 2014-05-15 22:47:33 +0200 | [diff] [blame] | 951 | signal |
| 952 | ------ |
Brett Cannon | a04dbe4 | 2014-04-04 13:53:38 -0400 | [diff] [blame] | 953 | |
Victor Stinner | bbe3803 | 2015-04-01 16:32:32 +0200 | [diff] [blame] | 954 | * On Windows, :func:`signal.set_wakeup_fd` now also supports socket handles. |
| 955 | (Contributed by Victor Stinner in :issue:`22018`.) |
| 956 | |
Antoine Pitrou | b9d9ce7 | 2014-05-15 22:47:33 +0200 | [diff] [blame] | 957 | * Different constants of :mod:`signal` module are now enumeration values using |
| 958 | the :mod:`enum` module. This allows meaningful names to be printed during |
Serhiy Storchaka | c1ded29 | 2014-11-02 19:22:02 +0200 | [diff] [blame] | 959 | debugging, instead of integer “magic numbers”. (Contributed by Giampaolo |
| 960 | Rodola' in :issue:`21076`.) |
R David Murray | 1976d9b | 2014-04-14 20:28:36 -0400 | [diff] [blame] | 961 | |
R David Murray | 554bcbf | 2014-06-11 11:18:08 -0400 | [diff] [blame] | 962 | smtpd |
| 963 | ----- |
| 964 | |
| 965 | * Both :class:`~smtpd.SMTPServer` and :class:`smtpd.SMTPChannel` now accept a |
| 966 | *decode_data* keyword to determine if the DATA portion of the SMTP |
| 967 | transaction is decoded using the ``utf-8`` codec or is instead provided to |
| 968 | :meth:`~smtpd.SMTPServer.process_message` as a byte string. The default |
| 969 | is ``True`` for backward compatibility reasons, but will change to ``False`` |
R David Murray | a33df31 | 2015-05-11 12:11:40 -0400 | [diff] [blame] | 970 | in Python 3.6. If *decode_data* is set to ``False``, the |
| 971 | :meth:`~smtpd.SMTPServer.process_message` method must be prepared to accept |
| 972 | keyword arguments. (Contributed by Maciej Szulik in :issue:`19662`.) |
| 973 | |
| 974 | * :class:`~smtpd.SMTPServer` now advertises the ``8BITMIME`` extension |
| 975 | (:rfc:`6152`) if if *decode_data* has been set ``True``. If the client |
| 976 | specifies ``BODY=8BITMIME`` on the ``MAIL`` command, it is passed to |
| 977 | :meth:`~smtpd.SMTPServer.process_message` via the ``mail_options`` keyword. |
| 978 | (Contributed by Milan Oberkirch and R. David Murray in :issue:`21795`.) |
| 979 | |
| 980 | * :class:`~smtpd.SMTPServer` now supports the ``SMTPUTF8`` extension |
| 981 | (:rfc:`6531`: Internationalized Email). If the client specified ``SMTPUTF8 |
| 982 | BODY=8BITMIME`` on the ``MAIL`` command, they are passed to |
| 983 | :meth:`~smtpd.SMTPServer.process_message` via the ``mail_options`` keyword. |
| 984 | It is the responsibility of the :meth:`~smtpd.SMTPServer.process_message` |
| 985 | method to correctly handle the ``SMTPUTF8`` data. (Contributed by Milan |
| 986 | Oberkirch in :issue:`21725`.) |
R David Murray | 554bcbf | 2014-06-11 11:18:08 -0400 | [diff] [blame] | 987 | |
R David Murray | 6fe56a3 | 2014-06-11 13:48:58 -0400 | [diff] [blame] | 988 | * It is now possible to provide, directly or via name resolution, IPv6 |
| 989 | addresses in the :class:`~smtpd.SMTPServer` constructor, and have it |
| 990 | successfully connect. (Contributed by Milan Oberkirch in :issue:`14758`.) |
| 991 | |
R David Murray | 76e13c1 | 2014-07-03 14:47:46 -0400 | [diff] [blame] | 992 | smtplib |
| 993 | ------- |
| 994 | |
| 995 | * A new :meth:`~smtplib.SMTP.auth` method provides a convenient way to |
Serhiy Storchaka | c1ded29 | 2014-11-02 19:22:02 +0200 | [diff] [blame] | 996 | implement custom authentication mechanisms. |
| 997 | (Contributed by Milan Oberkirch in :issue:`15014`.) |
R David Murray | 76e13c1 | 2014-07-03 14:47:46 -0400 | [diff] [blame] | 998 | |
R David Murray | 0c49b89 | 2015-04-16 17:14:42 -0400 | [diff] [blame] | 999 | * Additional debuglevel (2) shows timestamps for debug messages in |
| 1000 | :class:`smtplib.SMTP`. (Contributed by Gavin Chappell and Maciej Szulik in |
| 1001 | :issue:`16914`.) |
| 1002 | |
R David Murray | 8308444 | 2015-05-17 19:27:22 -0400 | [diff] [blame] | 1003 | * :mod:`smtplib` now supports :rfc:`6531` (SMTPUTF8) in both the |
| 1004 | :meth:`~smtplib.SMTP.sendmail` and :meth:`~smtplib.SMTP.send_message` |
| 1005 | commands. (Contributed by Milan Oberkirch and R. David Murray in |
| 1006 | :issue:`22027`.) |
R David Murray | cee7cf6 | 2015-05-16 13:58:14 -0400 | [diff] [blame] | 1007 | |
R David Murray | 4487dd0 | 2014-10-09 16:59:30 -0400 | [diff] [blame] | 1008 | sndhdr |
| 1009 | ------ |
| 1010 | |
| 1011 | * :func:`~sndhdr.what` and :func:`~sndhdr.whathdr` now return |
Serhiy Storchaka | c1ded29 | 2014-11-02 19:22:02 +0200 | [diff] [blame] | 1012 | :func:`~collections.namedtuple`. |
| 1013 | (Contributed by Claudiu Popa in :issue:`18615`.) |
R David Murray | 4487dd0 | 2014-10-09 16:59:30 -0400 | [diff] [blame] | 1014 | |
Victor Stinner | 287452e | 2015-07-29 01:39:13 +0200 | [diff] [blame] | 1015 | ssl |
| 1016 | --- |
| 1017 | |
Yury Selivanov | 7d6adab | 2015-08-05 19:01:51 -0400 | [diff] [blame] | 1018 | * The :meth:`~ssl.SSLSocket.do_handshake`, :meth:`~ssl.SSLSocket.read`, |
| 1019 | :meth:`~ssl.SSLSocket.shutdown`, and :meth:`~ssl.SSLSocket.write` methods of |
| 1020 | :class:`ssl.SSLSocket` don't reset the socket timeout anymore each time bytes |
| 1021 | are received or sent. The socket timeout is now the maximum total duration of |
| 1022 | the method. |
| 1023 | |
| 1024 | * Memory BIO Support: new classes :class:`~ssl.SSLObject`, |
| 1025 | :class:`~ssl.MemoryBIO`, and new |
| 1026 | :meth:`SSLContext.wrap_bio <ssl.SSLContext.wrap_bio>` method. |
| 1027 | (Contributed by Geert Jansen in :issue:`21965`.) |
Victor Stinner | 287452e | 2015-07-29 01:39:13 +0200 | [diff] [blame] | 1028 | |
Yury Selivanov | 100fc3f | 2015-09-08 22:40:30 -0400 | [diff] [blame] | 1029 | * New :meth:`~ssl.SSLSocket.version` to query the actual protocol version |
| 1030 | in use. (Contributed by Antoine Pitrou in :issue:`20421`.) |
| 1031 | |
| 1032 | * New :meth:`~ssl.SSLObject.shared_ciphers` and |
| 1033 | :meth:`~ssl.SSLSocket.shared_ciphers` methods to fetch the client's |
| 1034 | list of ciphers sent at handshake. |
| 1035 | (Contributed by Benjamin Peterson in :issue:`23186`.) |
| 1036 | |
Giampaolo Rodola' | 915d141 | 2014-06-11 03:54:30 +0200 | [diff] [blame] | 1037 | socket |
| 1038 | ------ |
| 1039 | |
| 1040 | * New :meth:`socket.socket.sendfile` method allows to send a file over a socket |
| 1041 | by using high-performance :func:`os.sendfile` function on UNIX resulting in |
| 1042 | uploads being from 2x to 3x faster than when using plain |
| 1043 | :meth:`socket.socket.send`. |
Serhiy Storchaka | c1ded29 | 2014-11-02 19:22:02 +0200 | [diff] [blame] | 1044 | (Contributed by Giampaolo Rodola' in :issue:`17552`.) |
Giampaolo Rodola' | 915d141 | 2014-06-11 03:54:30 +0200 | [diff] [blame] | 1045 | |
Victor Stinner | 9881013 | 2015-07-29 01:41:25 +0200 | [diff] [blame] | 1046 | * The :meth:`socket.socket.sendall` method don't reset the socket timeout |
| 1047 | anymore each time bytes are received or sent. The socket timeout is now the |
| 1048 | maximum total duration to send all data. |
| 1049 | |
Yury Selivanov | 100fc3f | 2015-09-08 22:40:30 -0400 | [diff] [blame] | 1050 | * Functions with timeouts now use a monotonic clock, instead of a |
| 1051 | system clock. (Contributed by Victor Stinner in :issue:`22043`.) |
| 1052 | |
Gregory P. Smith | 6e73000 | 2015-04-14 16:14:25 -0700 | [diff] [blame] | 1053 | subprocess |
| 1054 | ---------- |
| 1055 | |
| 1056 | * The new :func:`subprocess.run` function runs subprocesses and returns a |
| 1057 | :class:`subprocess.CompletedProcess` object. It Provides a more consistent |
| 1058 | API than :func:`~subprocess.call`, :func:`~subprocess.check_call` and |
| 1059 | :func:`~subprocess.check_output`. |
| 1060 | |
Yury Selivanov | 4640b30 | 2015-05-31 17:21:38 -0400 | [diff] [blame] | 1061 | sys |
| 1062 | --- |
| 1063 | |
| 1064 | * New :func:`~sys.set_coroutine_wrapper` and :func:`~sys.get_coroutine_wrapper` |
| 1065 | functions. (Contributed by Yury Selivanov in :issue:`24017`.) |
| 1066 | |
Yury Selivanov | 100fc3f | 2015-09-08 22:40:30 -0400 | [diff] [blame] | 1067 | * New :func:`~sys.is_finalizing` to check for :term:`interpreter shutdown`. |
| 1068 | (Contributed by Antoine Pitrou in :issue:`22696`.) |
| 1069 | |
Eric V. Smith | 7a80389 | 2015-04-15 10:27:58 -0400 | [diff] [blame] | 1070 | sysconfig |
| 1071 | --------- |
| 1072 | |
| 1073 | * The user scripts directory on Windows is now versioned. |
| 1074 | (Contributed by Paul Moore in :issue:`23437`.) |
| 1075 | |
| 1076 | tarfile |
| 1077 | ------- |
| 1078 | |
| 1079 | * The :func:`tarfile.open` function now supports ``'x'`` (exclusive creation) |
| 1080 | mode. (Contributed by Berker Peksag in :issue:`21717`.) |
| 1081 | |
| 1082 | * The :meth:`~tarfile.TarFile.extractall` and :meth:`~tarfile.TarFile.extract` |
| 1083 | methods now take a keyword parameter *numeric_only*. If set to ``True``, |
| 1084 | the extracted files and directories will be owned by the numeric uid and gid |
| 1085 | from the tarfile. If set to ``False`` (the default, and the behavior in |
Yury Selivanov | 100fc3f | 2015-09-08 22:40:30 -0400 | [diff] [blame] | 1086 | versions prior to 3.5), they will be owned by the named user and group in the |
Eric V. Smith | 7a80389 | 2015-04-15 10:27:58 -0400 | [diff] [blame] | 1087 | tarfile. (Contributed by Michael Vogt and Eric Smith in :issue:`23193`.) |
| 1088 | |
Yury Selivanov | 100fc3f | 2015-09-08 22:40:30 -0400 | [diff] [blame] | 1089 | threading |
| 1090 | --------- |
| 1091 | |
| 1092 | * :meth:`~threading.Lock.acquire` and :meth:`~threading.RLock.acquire` |
| 1093 | now use a monotonic clock for managing timeouts. |
| 1094 | (Contributed by Victor Stinner in :issue:`22043`.) |
| 1095 | |
Victor Stinner | ae58649 | 2014-09-02 23:18:25 +0200 | [diff] [blame] | 1096 | time |
| 1097 | ---- |
| 1098 | |
Berker Peksag | 882c95c | 2014-10-09 11:46:56 +0300 | [diff] [blame] | 1099 | * The :func:`time.monotonic` function is now always available. (Contributed by |
| 1100 | Victor Stinner in :issue:`22043`.) |
Victor Stinner | ae58649 | 2014-09-02 23:18:25 +0200 | [diff] [blame] | 1101 | |
Zachary Ware | 7dc9dea | 2015-05-22 11:36:53 -0500 | [diff] [blame] | 1102 | tkinter |
| 1103 | ------- |
| 1104 | |
Nick Coghlan | d5cacbb | 2015-05-23 22:24:10 +1000 | [diff] [blame] | 1105 | * The :mod:`tkinter._fix` module used for setting up the Tcl/Tk environment |
Berker Peksag | 1a90b17 | 2015-05-24 00:26:05 +0300 | [diff] [blame] | 1106 | on Windows has been replaced by a private function in the :mod:`_tkinter` |
Zachary Ware | 7dc9dea | 2015-05-22 11:36:53 -0500 | [diff] [blame] | 1107 | module which makes no permanent changes to environment variables. |
| 1108 | (Contributed by Zachary Ware in :issue:`20035`.) |
| 1109 | |
Yury Selivanov | 100fc3f | 2015-09-08 22:40:30 -0400 | [diff] [blame] | 1110 | traceback |
| 1111 | --------- |
| 1112 | |
| 1113 | * New :func:`~traceback.walk_stack` and :func:`~traceback.walk_tb` |
| 1114 | functions to conveniently traverse frame and traceback objects. |
| 1115 | (Contributed by Robert Collins in :issue:`17911`.) |
| 1116 | |
| 1117 | * New lightweight classes: :class:`~traceback.TracebackException`, |
| 1118 | :class:`~traceback.StackSummary`, and :class:`traceback.FrameSummary`. |
| 1119 | (Contributed by Robert Collins in :issue:`17911`.) |
| 1120 | |
Yury Selivanov | f3e40fa | 2015-05-21 11:50:30 -0400 | [diff] [blame] | 1121 | types |
| 1122 | ----- |
| 1123 | |
| 1124 | * New :func:`~types.coroutine` function. (Contributed by Yury Selivanov |
| 1125 | in :issue:`24017`.) |
| 1126 | |
Yury Selivanov | 5376ba9 | 2015-06-22 12:19:30 -0400 | [diff] [blame] | 1127 | * New :class:`~types.CoroutineType`. (Contributed by Yury Selivanov |
| 1128 | in :issue:`24400`.) |
| 1129 | |
Berker Peksag | bd09d7b | 2015-02-11 15:32:34 +0200 | [diff] [blame] | 1130 | urllib |
| 1131 | ------ |
Nick Coghlan | c216c48 | 2014-11-12 23:33:50 +1000 | [diff] [blame] | 1132 | |
R David Murray | 4c7f995 | 2015-04-16 16:36:18 -0400 | [diff] [blame] | 1133 | * A new :class:`~urllib.request.HTTPPasswordMgrWithPriorAuth` allows HTTP Basic |
| 1134 | Authentication credentials to be managed so as to eliminate unnecessary |
| 1135 | ``401`` response handling, or to unconditionally send credentials |
| 1136 | on the first request in order to communicate with servers that return a |
| 1137 | ``404`` response instead of a ``401`` if the ``Authorization`` header is not |
| 1138 | sent. (Contributed by Matej Cepl in :issue:`19494` and Akshit Khurana in |
| 1139 | :issue:`7159`.) |
Nick Coghlan | c216c48 | 2014-11-12 23:33:50 +1000 | [diff] [blame] | 1140 | |
R David Murray | c17686f | 2015-05-17 20:44:50 -0400 | [diff] [blame] | 1141 | * A new :func:`~urllib.parse.urlencode` parameter *quote_via* provides a way to |
| 1142 | control the encoding of query parts if needed. (Contributed by Samwyse and |
| 1143 | Arnon Yaari in :issue:`13866`.) |
| 1144 | |
Yury Selivanov | 100fc3f | 2015-09-08 22:40:30 -0400 | [diff] [blame] | 1145 | * :func:`~urllib.request.urlopen` accepts an :class:`ssl.SSLContext` |
| 1146 | object as a *context* argument, which will be used for the HTTPS |
| 1147 | connection. (Contributed by Alex Gaynor in :issue:`22366`.) |
| 1148 | |
Benjamin Peterson | 4801383 | 2015-06-27 15:45:56 -0500 | [diff] [blame] | 1149 | unicodedata |
| 1150 | ----------- |
| 1151 | |
| 1152 | * The :mod:`unicodedata` module now uses data from `Unicode 8.0.0 |
Nick Coghlan | 2ab5b09 | 2015-07-03 19:49:15 +1000 | [diff] [blame] | 1153 | <http://unicode.org/versions/Unicode8.0.0/>`_. |
Benjamin Peterson | 4801383 | 2015-06-27 15:45:56 -0500 | [diff] [blame] | 1154 | |
| 1155 | |
Berker Peksag | 3e88722 | 2014-07-02 08:37:22 +0300 | [diff] [blame] | 1156 | wsgiref |
| 1157 | ------- |
| 1158 | |
| 1159 | * *headers* parameter of :class:`wsgiref.headers.Headers` is now optional. |
| 1160 | (Contributed by Pablo Torres Navarrete and SilentGhost in :issue:`5800`.) |
| 1161 | |
Antoine Pitrou | b9d9ce7 | 2014-05-15 22:47:33 +0200 | [diff] [blame] | 1162 | xmlrpc |
| 1163 | ------ |
| 1164 | |
Serhiy Storchaka | c1ded29 | 2014-11-02 19:22:02 +0200 | [diff] [blame] | 1165 | * :class:`xmlrpc.client.ServerProxy` is now a :term:`context manager`. |
| 1166 | (Contributed by Claudiu Popa in :issue:`20627`.) |
Brett Cannon | 6eaac13 | 2014-05-09 12:28:22 -0400 | [diff] [blame] | 1167 | |
Yury Selivanov | 100fc3f | 2015-09-08 22:40:30 -0400 | [diff] [blame] | 1168 | * :class:`~xmlrpc.client.ServerProxy` constructor now accepts an optional |
| 1169 | :class:`ssl.SSLContext` instance. |
| 1170 | (Contributed by Alex Gaynor in :issue:`22960`.) |
| 1171 | |
Serhiy Storchaka | 61de087 | 2015-04-02 21:00:13 +0300 | [diff] [blame] | 1172 | xml.sax |
| 1173 | ------- |
| 1174 | |
| 1175 | * SAX parsers now support a character stream of |
| 1176 | :class:`~xml.sax.xmlreader.InputSource` object. |
| 1177 | (Contributed by Serhiy Storchaka in :issue:`2175`.) |
| 1178 | |
Victor Stinner | 95bb714 | 2015-03-12 15:32:03 +0100 | [diff] [blame] | 1179 | faulthandler |
| 1180 | ------------ |
| 1181 | |
| 1182 | * :func:`~faulthandler.enable`, :func:`~faulthandler.register`, |
| 1183 | :func:`~faulthandler.dump_traceback` and |
| 1184 | :func:`~faulthandler.dump_traceback_later` functions now accept file |
| 1185 | descriptors. (Contributed by Wei Wu in :issue:`23566`.) |
| 1186 | |
Serhiy Storchaka | 77d8997 | 2015-03-23 01:09:35 +0200 | [diff] [blame] | 1187 | zipfile |
| 1188 | ------- |
| 1189 | |
| 1190 | * Added support for writing ZIP files to unseekable streams. |
| 1191 | (Contributed by Serhiy Storchaka in :issue:`23252`.) |
| 1192 | |
Serhiy Storchaka | 764fc9b | 2015-03-25 10:09:41 +0200 | [diff] [blame] | 1193 | * The :func:`zipfile.ZipFile.open` function now supports ``'x'`` (exclusive |
| 1194 | creation) mode. (Contributed by Serhiy Storchaka in :issue:`21717`.) |
| 1195 | |
Victor Stinner | 01adf06 | 2014-03-18 00:53:32 +0100 | [diff] [blame] | 1196 | |
| 1197 | Optimizations |
| 1198 | ============= |
| 1199 | |
Antoine Pitrou | b9d9ce7 | 2014-05-15 22:47:33 +0200 | [diff] [blame] | 1200 | The following performance enhancements have been added: |
Victor Stinner | 01adf06 | 2014-03-18 00:53:32 +0100 | [diff] [blame] | 1201 | |
Victor Stinner | 37f2034 | 2015-03-10 13:29:41 +0100 | [diff] [blame] | 1202 | * :func:`os.walk` has been sped up by 3-5x on POSIX systems and 7-20x |
| 1203 | on Windows. This was done using the new :func:`os.scandir` function, |
| 1204 | which exposes file information from the underlying ``readdir`` and |
| 1205 | ``FindFirstFile``/``FindNextFile`` system calls. (Contributed by |
| 1206 | Ben Hoyt with help from Victor Stinner in :issue:`23605`.) |
| 1207 | |
Brett Cannon | f299abd | 2015-04-13 14:21:02 -0400 | [diff] [blame] | 1208 | * Construction of ``bytes(int)`` (filled by zero bytes) is faster and uses less |
Victor Stinner | 2bc4d95 | 2014-06-02 22:22:42 +0200 | [diff] [blame] | 1209 | memory for large objects. ``calloc()`` is used instead of ``malloc()`` to |
Victor Stinner | db067af | 2014-05-02 22:31:14 +0200 | [diff] [blame] | 1210 | allocate memory for these objects. |
Victor Stinner | 01adf06 | 2014-03-18 00:53:32 +0100 | [diff] [blame] | 1211 | |
Antoine Pitrou | 0dfce56 | 2014-05-15 22:55:40 +0200 | [diff] [blame] | 1212 | * Some operations on :class:`~ipaddress.IPv4Network` and |
| 1213 | :class:`~ipaddress.IPv6Network` have been massively sped up, such as |
| 1214 | :meth:`~ipaddress.IPv4Network.subnets`, :meth:`~ipaddress.IPv4Network.supernet`, |
| 1215 | :func:`~ipaddress.summarize_address_range`, :func:`~ipaddress.collapse_addresses`. |
| 1216 | The speed up can range from 3x to 15x. |
Yury Selivanov | 100fc3f | 2015-09-08 22:40:30 -0400 | [diff] [blame] | 1217 | (See :issue:`21486`, :issue:`21487`, :issue:`20826`, :issue:`23266`.) |
| 1218 | |
| 1219 | * Pickling of :mod:`ipaddress` classes was optimized to produce significantly |
| 1220 | smaller output. (Contributed by Serhiy Storchaka in :issue:`23133`.) |
Antoine Pitrou | 0dfce56 | 2014-05-15 22:55:40 +0200 | [diff] [blame] | 1221 | |
Serhiy Storchaka | 87d0b45 | 2015-02-03 11:30:10 +0200 | [diff] [blame] | 1222 | * Many operations on :class:`io.BytesIO` are now 50% to 100% faster. |
Berker Peksag | 9121fe8 | 2015-02-15 00:45:57 +0200 | [diff] [blame] | 1223 | (Contributed by Serhiy Storchaka in :issue:`15381` and David Wilson in |
| 1224 | :issue:`22003`.) |
Serhiy Storchaka | 87d0b45 | 2015-02-03 11:30:10 +0200 | [diff] [blame] | 1225 | |
Serhiy Storchaka | c1efe5f | 2015-02-11 15:54:54 +0200 | [diff] [blame] | 1226 | * :func:`marshal.dumps` is now faster (65%-85% with versions 3--4, 20-25% with |
| 1227 | versions 0--2 on typical data, and up to 5x in best cases). |
| 1228 | (Contributed by Serhiy Storchaka in :issue:`20416` and :issue:`23344`.) |
Serhiy Storchaka | ce921c62 | 2015-02-11 15:53:31 +0200 | [diff] [blame] | 1229 | |
Serhiy Storchaka | 0d4df75 | 2015-05-12 23:12:45 +0300 | [diff] [blame] | 1230 | * The UTF-32 encoder is now 3x to 7x faster. (Contributed by Serhiy Storchaka |
| 1231 | in :issue:`15027`.) |
| 1232 | |
Yury Selivanov | 100fc3f | 2015-09-08 22:40:30 -0400 | [diff] [blame] | 1233 | * Regular expressions are now parsed up to 10% faster. |
| 1234 | (Contributed by Serhiy Storchaka in :issue:`19380`.) |
| 1235 | |
| 1236 | * :func:`json.dumps` was optimized to run with ``ensure_ascii=False`` |
| 1237 | as fast as with ``ensure_ascii=True``. |
| 1238 | (Contributed by Naoki Inada in :issue:`23206`.) |
| 1239 | |
Victor Stinner | 01adf06 | 2014-03-18 00:53:32 +0100 | [diff] [blame] | 1240 | |
| 1241 | Build and C API Changes |
| 1242 | ======================= |
| 1243 | |
| 1244 | Changes to Python's build process and to the C API include: |
| 1245 | |
Victor Stinner | db067af | 2014-05-02 22:31:14 +0200 | [diff] [blame] | 1246 | * New ``calloc`` functions: |
| 1247 | |
| 1248 | * :c:func:`PyMem_RawCalloc` |
| 1249 | * :c:func:`PyMem_Calloc` |
| 1250 | * :c:func:`PyObject_Calloc` |
| 1251 | * :c:func:`_PyObject_GC_Calloc` |
Victor Stinner | 01adf06 | 2014-03-18 00:53:32 +0100 | [diff] [blame] | 1252 | |
Steve Dower | 313fbf4 | 2015-07-17 16:48:48 -0700 | [diff] [blame] | 1253 | * Windows builds now require Microsoft Visual C++ 14.0, which |
| 1254 | is available as part of `Visual Studio 2015 <http://www.visualstudio.com>`_. |
Victor Stinner | 01adf06 | 2014-03-18 00:53:32 +0100 | [diff] [blame] | 1255 | |
| 1256 | Deprecated |
| 1257 | ========== |
| 1258 | |
Yury Selivanov | 8fa6d4f | 2015-05-28 17:09:14 -0400 | [diff] [blame] | 1259 | New Keywords |
| 1260 | ------------ |
| 1261 | |
Yury Selivanov | 13b74ae | 2015-08-03 14:55:58 -0400 | [diff] [blame] | 1262 | ``async`` and ``await`` are not recommended to be used as variable, class, |
| 1263 | function or module names. Introduced by :pep:`492` in Python 3.5, they will |
| 1264 | become proper keywords in Python 3.7. |
Yury Selivanov | 8fa6d4f | 2015-05-28 17:09:14 -0400 | [diff] [blame] | 1265 | |
| 1266 | |
Victor Stinner | 01adf06 | 2014-03-18 00:53:32 +0100 | [diff] [blame] | 1267 | Unsupported Operating Systems |
| 1268 | ----------------------------- |
| 1269 | |
Zachary Ware | 38019d1 | 2015-04-13 15:51:59 -0500 | [diff] [blame] | 1270 | * Windows XP - Per :PEP:`11`, Microsoft support of Windows XP has ended. |
Victor Stinner | 01adf06 | 2014-03-18 00:53:32 +0100 | [diff] [blame] | 1271 | |
| 1272 | |
| 1273 | Deprecated Python modules, functions and methods |
| 1274 | ------------------------------------------------ |
| 1275 | |
Brett Cannon | a77d0c3 | 2014-03-21 10:52:33 -0400 | [diff] [blame] | 1276 | * The :mod:`formatter` module has now graduated to full deprecation and is still |
| 1277 | slated for removal in Python 3.6. |
Victor Stinner | 01adf06 | 2014-03-18 00:53:32 +0100 | [diff] [blame] | 1278 | |
R David Murray | 554bcbf | 2014-06-11 11:18:08 -0400 | [diff] [blame] | 1279 | * :mod:`smtpd` has in the past always decoded the DATA portion of email |
| 1280 | messages using the ``utf-8`` codec. This can now be controlled by the new |
| 1281 | *decode_data* keyword to :class:`~smtpd.SMTPServer`. The default value is |
| 1282 | ``True``, but this default is deprecated. Specify the *decode_data* keyword |
| 1283 | with an appropriate value to avoid the deprecation warning. |
| 1284 | |
R David Murray | 1813c17 | 2015-03-29 17:09:21 -0400 | [diff] [blame] | 1285 | * Directly assigning values to the :attr:`~http.cookies.Morsel.key`, |
| 1286 | :attr:`~http.cookies.Morsel.value` and |
| 1287 | :attr:`~http.cookies.Morsel.coded_value` of :class:`~http.cookies.Morsel` |
| 1288 | objects is deprecated. Use the :func:`~http.cookies.Morsel.set` method |
| 1289 | instead. In addition, the undocumented *LegalChars* parameter of |
| 1290 | :func:`~http.cookies.Morsel.set` is deprecated, and is now ignored. |
Serhiy Storchaka | 9c1a9b2 | 2015-03-18 10:59:57 +0200 | [diff] [blame] | 1291 | |
Serhiy Storchaka | b876df4 | 2015-03-24 22:30:46 +0200 | [diff] [blame] | 1292 | * Passing a format string as keyword argument *format_string* to the |
| 1293 | :meth:`~string.Formatter.format` method of the :class:`string.Formatter` |
| 1294 | class has been deprecated. |
| 1295 | |
Berker Peksag | 2f3742b | 2015-05-13 12:32:20 +0300 | [diff] [blame] | 1296 | * :func:`platform.dist` and :func:`platform.linux_distribution` functions are |
| 1297 | now deprecated and will be removed in Python 3.7. Linux distributions use |
| 1298 | too many different ways of describing themselves, so the functionality is |
| 1299 | left to a package. |
| 1300 | (Contributed by Vajrasky Kok and Berker Peksag in :issue:`1322`.) |
Victor Stinner | 01adf06 | 2014-03-18 00:53:32 +0100 | [diff] [blame] | 1301 | |
Benjamin Peterson | b1cc37c | 2015-05-20 22:09:43 -0500 | [diff] [blame] | 1302 | * The previously undocumented ``from_function`` and ``from_builtin`` methods of |
| 1303 | :class:`inspect.Signature` are deprecated. Use new |
Yury Selivanov | 57c74fc | 2015-05-20 23:07:02 -0400 | [diff] [blame] | 1304 | :meth:`inspect.Signature.from_callable` instead. (Contributed by Yury |
| 1305 | Selivanov in :issue:`24248`.) |
| 1306 | |
Yury Selivanov | 945fff4 | 2015-05-22 16:28:05 -0400 | [diff] [blame] | 1307 | * :func:`inspect.getargspec` is deprecated and scheduled to be removed in |
| 1308 | Python 3.6. (See :issue:`20438` for details.) |
| 1309 | |
| 1310 | * :func:`~inspect.getfullargspec`, :func:`~inspect.getargvalues`, |
| 1311 | :func:`~inspect.getcallargs`, :func:`~inspect.getargvalues`, |
| 1312 | :func:`~inspect.formatargspec`, and :func:`~inspect.formatargvalues` are |
| 1313 | deprecated in favor of :func:`inspect.signature` API. (See :issue:`20438` |
| 1314 | for details.) |
| 1315 | |
Yury Selivanov | 100fc3f | 2015-09-08 22:40:30 -0400 | [diff] [blame] | 1316 | * Use of ``re.LOCALE`` flag with str patterns or ``re.ASCII`` is now |
| 1317 | deprecated. (Contributed by Serhiy Storchaka in :issue:`22407`.) |
| 1318 | |
Yury Selivanov | 945fff4 | 2015-05-22 16:28:05 -0400 | [diff] [blame] | 1319 | |
Victor Stinner | 01adf06 | 2014-03-18 00:53:32 +0100 | [diff] [blame] | 1320 | Deprecated functions and types of the C API |
| 1321 | ------------------------------------------- |
| 1322 | |
| 1323 | * None yet. |
| 1324 | |
| 1325 | |
| 1326 | Deprecated features |
| 1327 | ------------------- |
| 1328 | |
| 1329 | * None yet. |
| 1330 | |
| 1331 | |
R David Murray | df75fee | 2014-10-03 13:02:47 -0400 | [diff] [blame] | 1332 | Removed |
| 1333 | ======= |
| 1334 | |
Berker Peksag | 8f791d3 | 2014-11-01 10:45:57 +0200 | [diff] [blame] | 1335 | API and Feature Removals |
| 1336 | ------------------------ |
| 1337 | |
| 1338 | The following obsolete and previously deprecated APIs and features have been |
| 1339 | removed: |
| 1340 | |
R David Murray | df75fee | 2014-10-03 13:02:47 -0400 | [diff] [blame] | 1341 | * The ``__version__`` attribute has been dropped from the email package. The |
| 1342 | email code hasn't been shipped separately from the stdlib for a long time, |
| 1343 | and the ``__version__`` string was not updated in the last few releases. |
| 1344 | |
Berker Peksag | 8f791d3 | 2014-11-01 10:45:57 +0200 | [diff] [blame] | 1345 | * The internal ``Netrc`` class in the :mod:`ftplib` module was deprecated in |
Serhiy Storchaka | c1ded29 | 2014-11-02 19:22:02 +0200 | [diff] [blame] | 1346 | 3.4, and has now been removed. |
| 1347 | (Contributed by Matt Chaput in :issue:`6623`.) |
R David Murray | df75fee | 2014-10-03 13:02:47 -0400 | [diff] [blame] | 1348 | |
Brett Cannon | f299abd | 2015-04-13 14:21:02 -0400 | [diff] [blame] | 1349 | * The concept of ``.pyo`` files has been removed. |
| 1350 | |
R David Murray | e81a773 | 2015-04-12 18:47:56 -0400 | [diff] [blame] | 1351 | * The JoinableQueue class in the provisional asyncio module was deprecated |
| 1352 | in 3.4.4 and is now removed (:issue:`23464`). |
| 1353 | |
| 1354 | |
Victor Stinner | 01adf06 | 2014-03-18 00:53:32 +0100 | [diff] [blame] | 1355 | Porting to Python 3.5 |
| 1356 | ===================== |
| 1357 | |
| 1358 | This section lists previously described changes and other bugfixes |
| 1359 | that may require changes to your code. |
| 1360 | |
Victor Stinner | db067af | 2014-05-02 22:31:14 +0200 | [diff] [blame] | 1361 | Changes in the Python API |
| 1362 | ------------------------- |
| 1363 | |
Victor Stinner | 6752d65 | 2015-07-29 01:11:10 +0200 | [diff] [blame] | 1364 | * :pep:`475`: System calls are now retried when interrupted by a signal instead |
| 1365 | of raising :exc:`InterruptedError` if the Python signal handler does not |
| 1366 | raise an exception. |
Victor Stinner | a766ddf | 2015-03-26 23:50:57 +0100 | [diff] [blame] | 1367 | |
Benjamin Peterson | ee6bdc0 | 2014-03-20 18:00:35 -0500 | [diff] [blame] | 1368 | * Before Python 3.5, a :class:`datetime.time` object was considered to be false |
| 1369 | if it represented midnight in UTC. This behavior was considered obscure and |
| 1370 | error-prone and has been removed in Python 3.5. See :issue:`13936` for full |
| 1371 | details. |
Antoine Pitrou | 92c4d45 | 2014-04-29 10:05:59 +0200 | [diff] [blame] | 1372 | |
| 1373 | * :meth:`ssl.SSLSocket.send()` now raises either :exc:`ssl.SSLWantReadError` |
| 1374 | or :exc:`ssl.SSLWantWriteError` on a non-blocking socket if the operation |
| 1375 | would block. Previously, it would return 0. See :issue:`20951`. |
Victor Stinner | db067af | 2014-05-02 22:31:14 +0200 | [diff] [blame] | 1376 | |
Victor Stinner | 40ee301 | 2014-06-16 15:59:28 +0200 | [diff] [blame] | 1377 | * The ``__name__`` attribute of generator is now set from the function name, |
| 1378 | instead of being set from the code name. Use ``gen.gi_code.co_name`` to |
| 1379 | retrieve the code name. Generators also have a new ``__qualname__`` |
| 1380 | attribute, the qualified name, which is now used for the representation |
| 1381 | of a generator (``repr(gen)``). See :issue:`21205`. |
| 1382 | |
Ezio Melotti | 045160b | 2014-08-02 18:54:30 +0300 | [diff] [blame] | 1383 | * The deprecated "strict" mode and argument of :class:`~html.parser.HTMLParser`, |
| 1384 | :meth:`HTMLParser.error`, and the :exc:`HTMLParserError` exception have been |
Serhiy Storchaka | c1ded29 | 2014-11-02 19:22:02 +0200 | [diff] [blame] | 1385 | removed. (Contributed by Ezio Melotti in :issue:`15114`.) |
Ezio Melotti | 045160b | 2014-08-02 18:54:30 +0300 | [diff] [blame] | 1386 | The *convert_charrefs* argument of :class:`~html.parser.HTMLParser` is |
Serhiy Storchaka | c1ded29 | 2014-11-02 19:22:02 +0200 | [diff] [blame] | 1387 | now ``True`` by default. (Contributed by Berker Peksag in :issue:`21047`.) |
Ezio Melotti | 045160b | 2014-08-02 18:54:30 +0300 | [diff] [blame] | 1388 | |
R David Murray | 861470c | 2014-10-05 11:47:01 -0400 | [diff] [blame] | 1389 | * Although it is not formally part of the API, it is worth noting for porting |
| 1390 | purposes (ie: fixing tests) that error messages that were previously of the |
| 1391 | form "'sometype' does not support the buffer protocol" are now of the form "a |
Serhiy Storchaka | c1ded29 | 2014-11-02 19:22:02 +0200 | [diff] [blame] | 1392 | bytes-like object is required, not 'sometype'". (Contributed by Ezio Melotti |
| 1393 | in :issue:`16518`.) |
R David Murray | 861470c | 2014-10-05 11:47:01 -0400 | [diff] [blame] | 1394 | |
Brett Cannon | b6e2556 | 2014-11-21 12:19:28 -0500 | [diff] [blame] | 1395 | * If the current directory is set to a directory that no longer exists then |
| 1396 | :exc:`FileNotFoundError` will no longer be raised and instead |
| 1397 | :meth:`~importlib.machinery.FileFinder.find_spec` will return ``None`` |
| 1398 | **without** caching ``None`` in :data:`sys.path_importer_cache` which is |
| 1399 | different than the typical case (:issue:`22834`). |
| 1400 | |
Berker Peksag | 088ca8b | 2015-02-06 10:17:49 +0200 | [diff] [blame] | 1401 | * HTTP status code and messages from :mod:`http.client` and :mod:`http.server` |
| 1402 | were refactored into a common :class:`~http.HTTPStatus` enum. The values in |
| 1403 | :mod:`http.client` and :mod:`http.server` remain available for backwards |
| 1404 | compatibility. (Contributed by Demian Brecht in :issue:`21793`.) |
Serhiy Storchaka | e4db769 | 2014-12-23 16:28:28 +0200 | [diff] [blame] | 1405 | |
Brett Cannon | 02d8454 | 2015-01-09 11:39:21 -0500 | [diff] [blame] | 1406 | * When an import loader defines :meth:`~importlib.machinery.Loader.exec_module` |
| 1407 | it is now expected to also define |
| 1408 | :meth:`~importlib.machinery.Loader.create_module` (raises a |
| 1409 | :exc:`DeprecationWarning` now, will be an error in Python 3.6). If the loader |
| 1410 | inherits from :class:`importlib.abc.Loader` then there is nothing to do, else |
| 1411 | simply define :meth:`~importlib.machinery.Loader.create_module` to return |
| 1412 | ``None`` (:issue:`23014`). |
| 1413 | |
Serhiy Storchaka | 83e8027 | 2015-02-03 11:04:19 +0200 | [diff] [blame] | 1414 | * :func:`re.split` always ignored empty pattern matches, so the ``'x*'`` |
| 1415 | pattern worked the same as ``'x+'``, and the ``'\b'`` pattern never worked. |
| 1416 | Now :func:`re.split` raises a warning if the pattern could match |
| 1417 | an empty string. For compatibility use patterns that never match an empty |
| 1418 | string (e.g. ``'x+'`` instead of ``'x*'``). Patterns that could only match |
| 1419 | an empty string (such as ``'\b'``) now raise an error. |
| 1420 | |
R David Murray | 1813c17 | 2015-03-29 17:09:21 -0400 | [diff] [blame] | 1421 | * The :class:`~http.cookies.Morsel` dict-like interface has been made self |
| 1422 | consistent: morsel comparison now takes the :attr:`~http.cookies.Morsel.key` |
| 1423 | and :attr:`~http.cookies.Morsel.value` into account, |
| 1424 | :meth:`~http.cookies.Morsel.copy` now results in a |
R David Murray | ba6ea9b | 2015-03-30 11:48:50 -0400 | [diff] [blame] | 1425 | :class:`~http.cookies.Morsel` instance rather than a :class:`dict`, and |
| 1426 | :meth:`~http.cookies.Morsel.update` will now raise an exception if any of the |
R David Murray | 1813c17 | 2015-03-29 17:09:21 -0400 | [diff] [blame] | 1427 | keys in the update dictionary are invalid. In addition, the undocumented |
| 1428 | *LegalChars* parameter of :func:`~http.cookies.Morsel.set` is deprecated and |
| 1429 | is now ignored. (:issue:`2211`) |
| 1430 | |
Brett Cannon | f299abd | 2015-04-13 14:21:02 -0400 | [diff] [blame] | 1431 | * :pep:`488` has removed ``.pyo`` files from Python and introduced the optional |
| 1432 | ``opt-`` tag in ``.pyc`` file names. The |
| 1433 | :func:`importlib.util.cache_from_source` has gained an *optimization* |
| 1434 | parameter to help control the ``opt-`` tag. Because of this, the |
| 1435 | *debug_override* parameter of the function is now deprecated. `.pyo` files |
| 1436 | are also no longer supported as a file argument to the Python interpreter and |
| 1437 | thus serve no purpose when distributed on their own (i.e. sourcless code |
| 1438 | distribution). Due to the fact that the magic number for bytecode has changed |
| 1439 | in Python 3.5, all old `.pyo` files from previous versions of Python are |
| 1440 | invalid regardless of this PEP. |
| 1441 | |
Ned Deily | cec3f56 | 2015-06-10 15:43:05 -0700 | [diff] [blame] | 1442 | * The :mod:`socket` module now exports the CAN_RAW_FD_FRAMES constant on linux |
| 1443 | 3.6 and greater. |
Larry Hastings | a6cc551 | 2015-04-13 17:48:40 -0400 | [diff] [blame] | 1444 | |
Zachary Ware | 3d3aedc | 2015-07-07 00:07:25 -0500 | [diff] [blame] | 1445 | * The ``pygettext.py`` Tool now uses the standard +NNNN format for timezones in |
R David Murray | 2b78129 | 2015-04-16 12:15:09 -0400 | [diff] [blame] | 1446 | the POT-Creation-Date header. |
| 1447 | |
R David Murray | 0c49b89 | 2015-04-16 17:14:42 -0400 | [diff] [blame] | 1448 | * The :mod:`smtplib` module now uses :data:`sys.stderr` instead of previous |
| 1449 | module level :data:`stderr` variable for debug output. If your (test) |
| 1450 | program depends on patching the module level variable to capture the debug |
| 1451 | output, you will need to update it to capture sys.stderr instead. |
| 1452 | |
Serhiy Storchaka | d4ea03c | 2015-05-31 09:15:51 +0300 | [diff] [blame] | 1453 | * The :meth:`str.startswith` and :meth:`str.endswith` methods no longer return |
| 1454 | ``True`` when finding the empty string and the indexes are completely out of |
| 1455 | range. See :issue:`24284`. |
| 1456 | |
Berker Peksag | 4333d8b | 2015-07-30 18:06:09 +0300 | [diff] [blame] | 1457 | * The :func:`inspect.getdoc` function now returns documentation strings |
| 1458 | inherited from base classes. Documentation strings no longer need to be |
| 1459 | duplicated if the inherited documentation is appropriate. To suppress an |
| 1460 | inherited string, an empty string must be specified (or the documentation |
| 1461 | may be filled in). This change affects the output of the :mod:`pydoc` |
| 1462 | module and the :func:`help` function. See :issue:`15582`. |
| 1463 | |
Victor Stinner | db067af | 2014-05-02 22:31:14 +0200 | [diff] [blame] | 1464 | Changes in the C API |
| 1465 | -------------------- |
| 1466 | |
Stefan Krah | f5324d7 | 2015-01-29 14:29:51 +0100 | [diff] [blame] | 1467 | * The undocumented :c:member:`~PyMemoryViewObject.format` member of the |
| 1468 | (non-public) :c:type:`PyMemoryViewObject` structure has been removed. |
| 1469 | |
| 1470 | All extensions relying on the relevant parts in ``memoryobject.h`` |
| 1471 | must be rebuilt. |
| 1472 | |
Victor Stinner | d8f0d92 | 2014-06-02 21:57:10 +0200 | [diff] [blame] | 1473 | * The :c:type:`PyMemAllocator` structure was renamed to |
| 1474 | :c:type:`PyMemAllocatorEx` and a new ``calloc`` field was added. |
Serhiy Storchaka | df4518c | 2014-11-18 23:34:33 +0200 | [diff] [blame] | 1475 | |
| 1476 | * Removed non-documented macro :c:macro:`PyObject_REPR` which leaked references. |
| 1477 | Use format character ``%R`` in :c:func:`PyUnicode_FromFormat`-like functions |
| 1478 | to format the :func:`repr` of the object. |
Serhiy Storchaka | 490055a | 2015-03-01 10:03:02 +0200 | [diff] [blame] | 1479 | |
| 1480 | * Because the lack of the :attr:`__module__` attribute breaks pickling and |
| 1481 | introspection, a deprecation warning now is raised for builtin type without |
| 1482 | the :attr:`__module__` attribute. Would be an AttributeError in future. |
| 1483 | (:issue:`20204`) |
Yury Selivanov | 5096088 | 2015-05-12 00:15:05 -0400 | [diff] [blame] | 1484 | |
Yury Selivanov | 5376ba9 | 2015-06-22 12:19:30 -0400 | [diff] [blame] | 1485 | * As part of :pep:`492` implementation, ``tp_reserved`` slot of |
Yury Selivanov | f3e40fa | 2015-05-21 11:50:30 -0400 | [diff] [blame] | 1486 | :c:type:`PyTypeObject` was replaced with a |
Yury Selivanov | 27947d5 | 2015-06-23 15:09:58 -0400 | [diff] [blame] | 1487 | :c:member:`tp_as_async` slot. Refer to :ref:`coro-objects` for |
Yury Selivanov | 5376ba9 | 2015-06-22 12:19:30 -0400 | [diff] [blame] | 1488 | new types, structures and functions. |