blob: b9ea6278a6eda7f49508ec24a9bb47e800058e3c [file] [log] [blame]
Victor Stinner01adf062014-03-18 00:53:32 +01001****************************
2 What's New In Python 3.5
3****************************
4
5:Release: |release|
6:Date: |today|
7
8.. Rules for maintenance:
9
10 * Anyone can add text to this document. Do not spend very much time
11 on the wording of your changes, because your text will probably
12 get rewritten to some degree.
13
14 * The maintainer will go through Misc/NEWS periodically and add
15 changes; it's therefore more important to add your changes to
16 Misc/NEWS than to this file.
17
18 * This is not a complete list of every single change; completeness
19 is the purpose of Misc/NEWS. Some changes I consider too small
20 or esoteric to include. If such a change is added to the text,
21 I'll just remove it. (This is another reason you shouldn't spend
22 too much time on writing your addition.)
23
24 * If you want to draw your new text to the attention of the
25 maintainer, add 'XXX' to the beginning of the paragraph or
26 section.
27
28 * It's OK to just add a fragmentary note about a change. For
29 example: "XXX Describe the transmogrify() function added to the
30 socket module." The maintainer will research the change and
31 write the necessary text.
32
33 * You can comment out your additions if you like, but it's not
34 necessary (especially when a final release is some months away).
35
36 * Credit the author of a patch or bugfix. Just the name is
37 sufficient; the e-mail address isn't necessary.
38
39 * It's helpful to add the bug/patch number as a comment:
40
41 XXX Describe the transmogrify() function added to the socket
42 module.
43 (Contributed by P.Y. Developer in :issue:`12345`.)
44
45 This saves the maintainer the effort of going through the Mercurial log
46 when researching a change.
47
48This article explains the new features in Python 3.5, compared to 3.4.
49
50For full details, see the :source:`Misc/NEWS` file.
51
Benjamin Peterson52d14932015-03-27 16:07:35 -040052.. 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 Stinner01adf062014-03-18 00:53:32 +010057
58
59.. seealso::
60
Berker Peksagfa0423b2014-10-09 11:38:19 +030061 :pep:`478` - Python 3.5 Release Schedule
Victor Stinner01adf062014-03-18 00:53:32 +010062
63
64Summary -- Release highlights
65=============================
66
Victor Stinner93692bb2015-03-30 15:04:45 +020067.. This section singles out the most important changes in Python 3.5.
Victor Stinner01adf062014-03-18 00:53:32 +010068 Brevity is key.
69
70New syntax features:
71
Benjamin Peterson14ef1a12015-05-13 11:19:27 -040072* :pep:`465`, a new matrix multiplication operator: ``a @ b``.
73* :pep:`492`, coroutines with async and await syntax.
Victor Stinner01adf062014-03-18 00:53:32 +010074
75New library modules:
76
Brett Cannoncc4dfc12015-03-13 10:40:49 -040077* :mod:`zipapp`: :ref:`Improving Python ZIP Application Support
78 <whatsnew-zipapp>` (:pep:`441`).
Victor Stinner01adf062014-03-18 00:53:32 +010079
80New built-in features:
81
Victor Stinner93692bb2015-03-30 15:04:45 +020082* ``bytes % args``, ``bytearray % args``: :pep:`461` - Adding ``%`` formatting
83 to bytes and bytearray
Gregory P. Smith8cb65692015-04-25 23:22:26 +000084* ``b'\xf0\x9f\x90\x8d'.hex()``, ``bytearray(b'\xf0\x9f\x90\x8d').hex()``,
85 ``memoryview(b'\xf0\x9f\x90\x8d').hex()``: :issue:`9951` - A ``hex`` method
86 has been added to bytes, bytearray, and memoryview.
Victor Stinner01adf062014-03-18 00:53:32 +010087
88Implementation improvements:
89
Victor Stinner71430292014-03-18 01:18:21 +010090* When the ``LC_TYPE`` locale is the POSIX locale (``C`` locale),
91 :py:data:`sys.stdin` and :py:data:`sys.stdout` are now using the
92 ``surrogateescape`` error handler, instead of the ``strict`` error handler
93 (:issue:`19977`).
Victor Stinner01adf062014-03-18 00:53:32 +010094
Brett Cannonf299abd2015-04-13 14:21:02 -040095* :pep:`488`, the elimination of ``.pyo`` files.
96
Victor Stinner01adf062014-03-18 00:53:32 +010097Significantly Improved Library Modules:
98
99* None yet.
100
101Security improvements:
102
103* None yet.
104
105Please read on for a comprehensive list of user-facing changes.
106
107
108.. PEP-sized items next.
109
110.. _pep-4XX:
111
112.. PEP 4XX: Virtual Environments
113.. =============================
114
115
116.. (Implemented by Foo Bar.)
117
118.. .. seealso::
119
120 :pep:`4XX` - Python Virtual Environments
121 PEP written by Carl Meyer
122
123
Yury Selivanovf3e40fa2015-05-21 11:50:30 -0400124PEP 492 - Coroutines with async and await syntax
125------------------------------------------------
126
127The PEP added dedicated syntax for declaring :term:`coroutines <coroutine>`,
128:keyword:`await` expressions, new asynchronous :keyword:`async for`
129and :keyword:`async with` statements.
130
131Example::
132
133 async def read_data(db):
134 async with db.transaction():
135 data = await db.fetch('SELECT ...')
136
137PEP written and implemented by Yury Selivanov.
138
139.. seealso::
140
141 :pep:`492` -- Coroutines with async and await syntax
142
143
Benjamin Peterson5562c9032015-05-13 11:19:06 -0400144PEP 461 - Adding formatting to bytes and bytearray
145--------------------------------------------------
Victor Stinner93692bb2015-03-30 15:04:45 +0200146
147This PEP proposes adding % formatting operations similar to Python 2's ``str``
148type to :class:`bytes` and :class:`bytearray`.
149
150Examples::
151
152 >>> b'Hello %s!' % b'World'
153 b'Hello World!'
154 >>> b'x=%i y=%f' % (1, 2.5)
155 b'x=1 y=2.500000'
156
157Unicode is not allowed for ``%s``, but it is accepted by ``%a`` (equivalent of
158``repr(obj).encode('ascii', 'backslashreplace')``)::
159
160 >>> b'Hello %s!' % 'World'
161 Traceback (most recent call last):
162 File "<stdin>", line 1, in <module>
163 TypeError: %b requires bytes, or an object that implements __bytes__, not 'str'
164 >>> b'price: %a' % '10€'
165 b"price: '10\\u20ac'"
166
167.. seealso::
168
169 :pep:`461` -- Adding % formatting to bytes and bytearray
170
171
172PEP 465 - A dedicated infix operator for matrix multiplication
173--------------------------------------------------------------
174
175This PEP proposes a new binary operator to be used for matrix multiplication,
R David Murrayef2a3972015-04-01 09:15:02 -0400176called ``@``. (Mnemonic: ``@`` is ``*`` for mATrices.)
Victor Stinner93692bb2015-03-30 15:04:45 +0200177
178.. seealso::
179
180 :pep:`465` -- A dedicated infix operator for matrix multiplication
181
Victor Stinner6036e442015-03-08 01:58:04 +0100182
183PEP 471 - os.scandir() function -- a better and faster directory iterator
184-------------------------------------------------------------------------
185
Victor Stinner37f20342015-03-10 13:29:41 +0100186:pep:`471` adds a new directory iteration function, :func:`os.scandir`,
187to the standard library. Additionally, :func:`os.walk` is now
188implemented using :func:`os.scandir`, which speeds it up by 3-5 times
189on POSIX systems and by 7-20 times on Windows systems.
190
191PEP and implementation written by Ben Hoyt with the help of Victor Stinner.
Victor Stinner6036e442015-03-08 01:58:04 +0100192
193.. seealso::
194
195 :pep:`471` -- os.scandir() function -- a better and faster directory
Victor Stinner37f20342015-03-10 13:29:41 +0100196 iterator
Victor Stinner6036e442015-03-08 01:58:04 +0100197
198
Charles-François Natali6e6c59b2015-02-07 13:27:50 +0000199PEP 475: Retry system calls failing with EINTR
200----------------------------------------------
201
Victor Stinnerf70e1ca2015-03-30 21:16:11 +0200202:pep:`475` adds support for automatic retry of system calls failing with
203:py:data:`~errno.EINTR`: this means that user code doesn't have to deal with
204EINTR or :exc:`InterruptedError` manually, and should make it more robust
205against asynchronous signal reception.
Charles-François Natali6e6c59b2015-02-07 13:27:50 +0000206
207.. seealso::
208
209 :pep:`475` -- Retry system calls failing with EINTR
Victor Stinner01adf062014-03-18 00:53:32 +0100210
211
Steve Dower76998fe2015-02-26 14:25:33 -0800212PEP 486: Make the Python Launcher aware of virtual environments
213---------------------------------------------------------------
214
215:pep:`486` makes the Windows launcher (see :pep:`397`) aware of an active
216virtual environment. When the default interpreter would be used and the
217``VIRTUAL_ENV`` environment variable is set, the interpreter in the virtual
218environment will be used.
219
220.. seealso::
221
222 :pep:`486` -- Make the Python Launcher aware of virtual environments
223
Brett Cannonf299abd2015-04-13 14:21:02 -0400224
225PEP 488: Elimination of PYO files
226---------------------------------
227
228:pep:`488` does away with the concept of ``.pyo`` files. This means that
229``.pyc`` files represent both unoptimized and optimized bytecode. To prevent
230the need to constantly regenerate bytecode files, ``.pyc`` files now have an
231optional ``opt-`` tag in their name when the bytecode is optimized. This has
232the side-effect of no more bytecode file name clashes when running under either
233``-O`` or ``-OO``, thus allowing unoptimized, ``-O``, and ``-OO`` bytecode files
234to all exist simultaneously. :func:`importlib.util.cache_from_source` has an
235updated API to help with this change.
236
237.. seealso::
238
239 :pep:`488` -- Elimination of PYO files
240
241
Victor Stinner01adf062014-03-18 00:53:32 +0100242Other Language Changes
243======================
244
245Some smaller changes made to the core Python language are:
246
Serhiy Storchaka07985ef2015-01-25 22:56:57 +0200247* Added the ``'namereplace'`` error handlers. The ``'backslashreplace'``
248 error handlers now works with decoding and translating.
249 (Contributed by Serhiy Storchaka in :issue:`19676` and :issue:`22286`.)
Victor Stinner01adf062014-03-18 00:53:32 +0100250
Serhiy Storchaka1dd49822015-03-20 16:54:57 +0200251* The :option:`-b` option now affects comparisons of :class:`bytes` with
252 :class:`int`. (Contributed by Serhiy Storchaka in :issue:`23681`)
Victor Stinner01adf062014-03-18 00:53:32 +0100253
Serhiy Storchakaad8a1c32015-05-12 23:16:55 +0300254* New Kazakh :ref:`codec <standard-encodings>` ``kz1048``. (Contributed by
255 Serhiy Storchaka in :issue:`22682`.)
256
Raymond Hettingereac503a2015-05-13 01:09:59 -0700257* Property docstrings are now writable. This is especially useful for
258 :func:`collections.namedtuple` docstrings.
259 (Contributed by Berker Peksag in :issue:`24064`.)
260
Serhiy Storchakaf0eeedf2015-05-12 23:24:19 +0300261* New Tajik :ref:`codec <standard-encodings>` ``koi8_t``. (Contributed by
262 Serhiy Storchaka in :issue:`22681`.)
263
Victor Stinner01adf062014-03-18 00:53:32 +0100264
265New Modules
266===========
267
Brett Cannoncc4dfc12015-03-13 10:40:49 -0400268.. _whatsnew-zipapp:
Victor Stinner01adf062014-03-18 00:53:32 +0100269
Brett Cannoncc4dfc12015-03-13 10:40:49 -0400270zipapp
271------
272
273The new :mod:`zipapp` module (specified in :pep:`441`) provides an API and
274command line tool for creating executable Python Zip Applications, which
275were introduced in Python 2.6 in :issue:`1739468` but which were not well
276publicised, either at the time or since.
277
278With the new module, bundling your application is as simple as putting all
279the files, including a ``__main__.py`` file, into a directory ``myapp``
280and running::
281
282 $ python -m zipapp myapp
283 $ python myapp.pyz
Victor Stinner01adf062014-03-18 00:53:32 +0100284
285
286Improved Modules
287================
288
Berker Peksag8089cd62015-02-14 01:39:17 +0200289argparse
290--------
291
292* :class:`~argparse.ArgumentParser` now allows to disable
293 :ref:`abbreviated usage <prefix-matching>` of long options by setting
294 :ref:`allow_abbrev` to ``False``.
295 (Contributed by Jonathan Paugh, Steven Bethard, paul j3 and Daniel Eriksson.)
296
Berker Peksagbf5e9602015-02-06 10:21:37 +0200297cgi
298---
299
Berker Peksagbd09d7b2015-02-11 15:32:34 +0200300* :class:`~cgi.FieldStorage` now supports the context management protocol.
Berker Peksagbf5e9602015-02-06 10:21:37 +0200301 (Contributed by Berker Peksag in :issue:`20289`.)
302
R David Murrayc31e6222014-09-29 11:25:00 -0400303code
304----
305
306* The :func:`code.InteractiveInterpreter.showtraceback` method now prints
Serhiy Storchakac1ded292014-11-02 19:22:02 +0200307 the full chained traceback, just like the interactive interpreter.
Berker Peksag088ca8b2015-02-06 10:17:49 +0200308 (Contributed by Claudiu Popa in :issue:`17442`.)
R David Murrayc31e6222014-09-29 11:25:00 -0400309
Raymond Hettingereac503a2015-05-13 01:09:59 -0700310collections
311-----------
312
313* You can now update docstrings produced by :func:`collections.namedtuple`::
314
315 Point = namedtuple('Point', ['x', 'y'])
316 Point.__doc__ = 'ordered pair'
317 Point.x.__doc__ = 'abscissa'
318 Point.y.__doc__ = 'ordinate'
319
320 (Contributed by Berker Peksag in :issue:`24064`.)
321
Brett Cannonf1a8df02014-09-12 10:39:48 -0400322compileall
323----------
324
325* :func:`compileall.compile_dir` and :mod:`compileall`'s command-line interface
326 can now do parallel bytecode compilation.
Serhiy Storchakac1ded292014-11-02 19:22:02 +0200327 (Contributed by Claudiu Popa in :issue:`16104`.)
Brett Cannonf1a8df02014-09-12 10:39:48 -0400328
Berker Peksagbb44fe02014-11-28 23:28:06 +0200329contextlib
330----------
331
332* The new :func:`contextlib.redirect_stderr` context manager(similar to
333 :func:`contextlib.redirect_stdout`) makes it easier for utility scripts to
334 handle inflexible APIs that write their output to :data:`sys.stderr` and
335 don't provide any options to redirect it.
336 (Contributed by Berker Peksag in :issue:`22389`.)
337
Steve Dowerd2bc3892015-04-15 18:06:05 -0400338curses
339------
340* The new :func:`curses.update_lines_cols` function updates the variables
341 :envvar:`curses.LINES` and :envvar:`curses.COLS`.
342
Berker Peksag102029d2015-03-15 01:18:47 +0200343difflib
344-------
345
346* The charset of the HTML document generated by :meth:`difflib.HtmlDiff.make_file`
347 can now be customized by using *charset* keyword-only parameter. The default
348 charset of HTML document changed from ``'ISO-8859-1'`` to ``'utf-8'``.
349 (Contributed by Berker Peksag in :issue:`2052`.)
350
Greg Ward4d9d2562015-04-20 20:21:21 -0400351* It's now possible to compare lists of byte strings with
352 :func:`difflib.diff_bytes` (fixes a regression from Python 2).
353
Berker Peksag618e3152015-01-27 02:59:09 +0200354distutils
355---------
356
357* The ``build`` and ``build_ext`` commands now accept a ``-j``
358 option to enable parallel building of extension modules.
359 (Contributed by Antoine Pitrou in :issue:`5309`.)
360
Serhiy Storchakab9cec6a2015-05-16 22:13:27 +0300361* Added support for the LZMA compression.
362 (Contributed by Serhiy Storchaka in :issue:`16314`.)
363
Antoine Pitroub9d9ce72014-05-15 22:47:33 +0200364doctest
365-------
Giampaolo Rodola'e09fb712014-04-04 15:34:17 +0200366
Antoine Pitroub9d9ce72014-05-15 22:47:33 +0200367* :func:`doctest.DocTestSuite` returns an empty :class:`unittest.TestSuite` if
Serhiy Storchakac1ded292014-11-02 19:22:02 +0200368 *module* contains no docstrings instead of raising :exc:`ValueError`.
369 (Contributed by Glenn Jones in :issue:`15916`.)
Antoine Pitroub9d9ce72014-05-15 22:47:33 +0200370
R David Murrayb744f3a2015-05-16 15:41:07 -0400371email
372-----
373
R David Murrayfdb23c22015-05-17 14:24:33 -0400374* A new policy option :attr:`~email.policy.Policy.mangle_from_` controls
375 whether or not lines that start with "From " in email bodies are prefixed with
376 a '>' character by generators. The default is ``True`` for
377 :attr:`~email.policy.compat32` and ``False`` for all other policies.
378 (Contributed by Milan Oberkirch in :issue:`20098`.)
379
R David Murrayb744f3a2015-05-16 15:41:07 -0400380* A new method :meth:`~email.message.Message.get_content_disposition` provides
381 easy access to a canonical value for the :mailheader:`Content-Disposition`
382 header (``None`` if there is no such header). (Contributed by Abhilash Raj
383 in :issue:`21083`.)
384
R David Murray224ef3e2015-05-17 11:29:21 -0400385* A new policy option :attr:`~email.policy.EmailPolicy.utf8` can be set
386 ``True`` to encode email headers using the utf8 charset instead of using
387 encoded words. This allows ``Messages`` to be formatted according to
388 :rfc:`6532` and used with an SMTP server that supports the :rfc:`6531`
389 ``SMTPUTF8`` extension. (Contributed by R. David Murray in :issue:`24211`.)
390
Serhiy Storchakac2edcdd2014-09-11 12:17:37 +0300391glob
392----
393
394* :func:`~glob.iglob` and :func:`~glob.glob` now support recursive search in
395 subdirectories using the "``**``" pattern.
396 (Contributed by Serhiy Storchaka in :issue:`13968`.)
397
Serhiy Storchaka38684c32014-09-09 19:07:49 +0300398imaplib
399-------
400
401* :class:`IMAP4` now supports the context management protocol. When used in a
402 :keyword:`with` statement, the IMAP4 ``LOGOUT`` command will be called
403 automatically at the end of the block. (Contributed by Tarek Ziadé and
Serhiy Storchakac1ded292014-11-02 19:22:02 +0200404 Serhiy Storchaka in :issue:`4972`.)
Serhiy Storchaka38684c32014-09-09 19:07:49 +0300405
R David Murraya6429db2015-05-10 19:17:23 -0400406* :mod:`imaplib` now supports :rfc:`5161`: the :meth:`~imaplib.IMAP4.enable`
407 extension), and :rfc:`6855`: utf-8 support (internationalized email, via the
408 ``UTF8=ACCEPT`` argument to :meth:`~imaplib.IMAP4.enable`). A new attribute,
409 :attr:`~imaplib.IMAP4.utf8_enabled`, tracks whether or not :rfc:`6855`
410 support is enabled. Milan Oberkirch, R. David Murray, and Maciej Szulik in
411 :issue:`21800`.)
412
413* :mod:`imaplib` now automatically encodes non-ASCII string usernames and
414 passwords using ``UTF8``, as recommended by the RFCs. (Contributed by Milan
415 Oberkirch in :issue:`21800`.)
416
R David Murray2f608202014-06-26 12:27:57 -0400417imghdr
418------
419
420* :func:`~imghdr.what` now recognizes the `OpenEXR <http://www.openexr.com>`_
Berker Peksag088ca8b2015-02-06 10:17:49 +0200421 format. (Contributed by Martin Vignali and Claudiu Popa in :issue:`20295`.)
R David Murray2f608202014-06-26 12:27:57 -0400422
Antoine Pitroub9d9ce72014-05-15 22:47:33 +0200423importlib
424---------
425
426* :class:`importlib.util.LazyLoader` allows for the lazy loading of modules in
Serhiy Storchakac1ded292014-11-02 19:22:02 +0200427 applications where startup time is paramount.
428 (Contributed by Brett Cannon in :issue:`17621`.)
Antoine Pitroub9d9ce72014-05-15 22:47:33 +0200429
430* :func:`importlib.abc.InspectLoader.source_to_code` is now a
431 static method to make it easier to work with source code in a string.
432 With a module object that you want to initialize you can then use
433 ``exec(code, module.__dict__)`` to execute the code in the module.
434
Brett Cannon2a17bde2014-05-30 14:55:29 -0400435* :func:`importlib.util.module_from_spec` is now the preferred way to create a
436 new module. Compared to :class:`types.ModuleType`, this new function will set
437 the various import-controlled attributes based on the passed-in spec object.
438
Antoine Pitroub9d9ce72014-05-15 22:47:33 +0200439inspect
440-------
Victor Stinner01adf062014-03-18 00:53:32 +0100441
Yury Selivanova5d63dd2014-03-27 11:31:43 -0400442* :class:`inspect.Signature` and :class:`inspect.Parameter` are now
Serhiy Storchakac1ded292014-11-02 19:22:02 +0200443 picklable and hashable. (Contributed by Yury Selivanov in :issue:`20726`
444 and :issue:`20334`.)
Yury Selivanova5d63dd2014-03-27 11:31:43 -0400445
Yury Selivanovb907a512015-05-16 13:45:09 -0400446* New method :meth:`inspect.BoundArguments.apply_defaults`. (Contributed
447 by Yury Selivanov in :issue:`24190`.)
448
Yury Selivanovda396452014-03-27 12:09:24 -0400449* New class method :meth:`inspect.Signature.from_callable`, which makes
Serhiy Storchakac1ded292014-11-02 19:22:02 +0200450 subclassing of :class:`~inspect.Signature` easier. (Contributed
451 by Yury Selivanov and Eric Snow in :issue:`17373`.)
Yury Selivanovda396452014-03-27 12:09:24 -0400452
Yury Selivanovbcd4fc12015-05-20 14:30:08 -0400453* New argument ``follow_wrapped`` for :func:`inspect.signature`.
454 (Contributed by Yury Selivanov in :issue:`20691`.)
455
Yury Selivanovf3e40fa2015-05-21 11:50:30 -0400456* New :func:`~inspect.iscoroutine`, :func:`~inspect.iscoroutinefunction`,
457 and :func:`~inspect.isawaitable` functions. (Contributed by Yury Selivanov
458 in :issue:`24017`.)
459
Antoine Pitrou0dfce562014-05-15 22:55:40 +0200460ipaddress
461---------
462
463* :class:`ipaddress.IPv4Network` and :class:`ipaddress.IPv6Network` now
464 accept an ``(address, netmask)`` tuple argument, so as to easily construct
Serhiy Storchakac1ded292014-11-02 19:22:02 +0200465 network objects from existing addresses. (Contributed by Peter Moody
466 and Antoine Pitrou in :issue:`16531`.)
Antoine Pitrou0dfce562014-05-15 22:55:40 +0200467
Berker Peksag39e4c4d2014-11-10 09:56:54 +0200468json
469----
470
471* The output of :mod:`json.tool` command line interface is now in the same
472 order as the input. Use the :option:`--sort-keys` option to sort the output
473 of dictionaries alphabetically by key. (Contributed by Berker Peksag in
474 :issue:`21650`.)
475
Serhiy Storchaka47efb4a2015-01-26 13:16:30 +0200476* JSON decoder now raises :exc:`json.JSONDecodeError` instead of
477 :exc:`ValueError`. (Contributed by Serhiy Storchaka in :issue:`19361`.)
478
Zachary Ware63f277b2014-06-19 09:46:37 -0500479os
480--
481
Victor Stinner37f20342015-03-10 13:29:41 +0100482* New :func:`os.scandir` function that exposes file information from
483 the operating system when listing a directory. :func:`os.scandir`
484 returns an iterator of :class:`os.DirEntry` objects corresponding to
485 the entries in the directory given by *path*. (Contributed by Ben
486 Hoyt with the help of Victor Stinner in :issue:`22524`.)
Victor Stinner6036e442015-03-08 01:58:04 +0100487
Victor Stinnere1d24f72014-07-24 12:44:07 +0200488* :class:`os.stat_result` now has a :attr:`~os.stat_result.st_file_attributes`
Serhiy Storchakac1ded292014-11-02 19:22:02 +0200489 attribute on Windows. (Contributed by Ben Hoyt in :issue:`21719`.)
Zachary Ware63f277b2014-06-19 09:46:37 -0500490
Serhiy Storchaka38220932015-03-31 15:31:53 +0300491os.path
492-------
493
494* New :func:`~os.path.commonpath` function that extracts common path prefix.
495 Unlike the :func:`~os.path.commonprefix` function, it always returns a valid
496 patch. (Contributed by Rafik Draoui and Serhiy Storchaka in :issue:`10395`.)
497
Serhiy Storchaka58e41342015-03-31 14:07:24 +0300498pickle
499------
500
501* Serializing more "lookupable" objects (such as unbound methods or nested
502 classes) now are supported with pickle protocols < 4.
503 (Contributed by Serhiy Storchaka in :issue:`23611`.)
504
R David Murrayb8cd3e42015-05-16 15:05:53 -0400505poplib
506------
507
508* A new command :meth:`~poplib.POP3.utf8` enables :rfc:`6856`
509 (internationalized email) support if the POP server supports it. (Contributed
510 by Milan OberKirch in :issue:`21804`.)
511
Serhiy Storchaka9baa5b22014-09-29 22:49:23 +0300512re
513--
514
515* Number of capturing groups in regular expression is no longer limited by 100.
516 (Contributed by Serhiy Storchaka in :issue:`22437`.)
517
Serhiy Storchaka7438e4b2014-10-10 11:06:31 +0300518* Now unmatched groups are replaced with empty strings in :func:`re.sub`
519 and :func:`re.subn`. (Contributed by Serhiy Storchaka in :issue:`1519638`.)
520
Mark Dickinsona5d0c7c2015-01-11 11:55:29 +0000521math
522----
523
524* :data:`math.inf` and :data:`math.nan` constants added. (Contributed by Mark
525 Dickinson in :issue:`23185`.)
526
R David Murray6ffface2014-06-11 14:40:13 -0400527shutil
528------
529
530* :func:`~shutil.move` now accepts a *copy_function* argument, allowing,
531 for example, :func:`~shutil.copy` to be used instead of the default
532 :func:`~shutil.copy2` if there is a need to ignore metadata. (Contributed by
533 Claudiu Popa in :issue:`19840`.)
534
Antoine Pitroub9d9ce72014-05-15 22:47:33 +0200535signal
536------
Brett Cannona04dbe42014-04-04 13:53:38 -0400537
Victor Stinnerbbe38032015-04-01 16:32:32 +0200538* On Windows, :func:`signal.set_wakeup_fd` now also supports socket handles.
539 (Contributed by Victor Stinner in :issue:`22018`.)
540
Antoine Pitroub9d9ce72014-05-15 22:47:33 +0200541* Different constants of :mod:`signal` module are now enumeration values using
542 the :mod:`enum` module. This allows meaningful names to be printed during
Serhiy Storchakac1ded292014-11-02 19:22:02 +0200543 debugging, instead of integer “magic numbers”. (Contributed by Giampaolo
544 Rodola' in :issue:`21076`.)
R David Murray1976d9b2014-04-14 20:28:36 -0400545
R David Murray554bcbf2014-06-11 11:18:08 -0400546smtpd
547-----
548
549* Both :class:`~smtpd.SMTPServer` and :class:`smtpd.SMTPChannel` now accept a
550 *decode_data* keyword to determine if the DATA portion of the SMTP
551 transaction is decoded using the ``utf-8`` codec or is instead provided to
552 :meth:`~smtpd.SMTPServer.process_message` as a byte string. The default
553 is ``True`` for backward compatibility reasons, but will change to ``False``
R David Murraya33df312015-05-11 12:11:40 -0400554 in Python 3.6. If *decode_data* is set to ``False``, the
555 :meth:`~smtpd.SMTPServer.process_message` method must be prepared to accept
556 keyword arguments. (Contributed by Maciej Szulik in :issue:`19662`.)
557
558* :class:`~smtpd.SMTPServer` now advertises the ``8BITMIME`` extension
559 (:rfc:`6152`) if if *decode_data* has been set ``True``. If the client
560 specifies ``BODY=8BITMIME`` on the ``MAIL`` command, it is passed to
561 :meth:`~smtpd.SMTPServer.process_message` via the ``mail_options`` keyword.
562 (Contributed by Milan Oberkirch and R. David Murray in :issue:`21795`.)
563
564* :class:`~smtpd.SMTPServer` now supports the ``SMTPUTF8`` extension
565 (:rfc:`6531`: Internationalized Email). If the client specified ``SMTPUTF8
566 BODY=8BITMIME`` on the ``MAIL`` command, they are passed to
567 :meth:`~smtpd.SMTPServer.process_message` via the ``mail_options`` keyword.
568 It is the responsibility of the :meth:`~smtpd.SMTPServer.process_message`
569 method to correctly handle the ``SMTPUTF8`` data. (Contributed by Milan
570 Oberkirch in :issue:`21725`.)
R David Murray554bcbf2014-06-11 11:18:08 -0400571
R David Murray6fe56a32014-06-11 13:48:58 -0400572* It is now possible to provide, directly or via name resolution, IPv6
573 addresses in the :class:`~smtpd.SMTPServer` constructor, and have it
574 successfully connect. (Contributed by Milan Oberkirch in :issue:`14758`.)
575
R David Murray76e13c12014-07-03 14:47:46 -0400576smtplib
577-------
578
579* A new :meth:`~smtplib.SMTP.auth` method provides a convenient way to
Serhiy Storchakac1ded292014-11-02 19:22:02 +0200580 implement custom authentication mechanisms.
581 (Contributed by Milan Oberkirch in :issue:`15014`.)
R David Murray76e13c12014-07-03 14:47:46 -0400582
R David Murray0c49b892015-04-16 17:14:42 -0400583* Additional debuglevel (2) shows timestamps for debug messages in
584 :class:`smtplib.SMTP`. (Contributed by Gavin Chappell and Maciej Szulik in
585 :issue:`16914`.)
586
R David Murray83084442015-05-17 19:27:22 -0400587* :mod:`smtplib` now supports :rfc:`6531` (SMTPUTF8) in both the
588 :meth:`~smtplib.SMTP.sendmail` and :meth:`~smtplib.SMTP.send_message`
589 commands. (Contributed by Milan Oberkirch and R. David Murray in
590 :issue:`22027`.)
R David Murraycee7cf62015-05-16 13:58:14 -0400591
R David Murray4487dd02014-10-09 16:59:30 -0400592sndhdr
593------
594
595* :func:`~sndhdr.what` and :func:`~sndhdr.whathdr` now return
Serhiy Storchakac1ded292014-11-02 19:22:02 +0200596 :func:`~collections.namedtuple`.
597 (Contributed by Claudiu Popa in :issue:`18615`.)
R David Murray4487dd02014-10-09 16:59:30 -0400598
Giampaolo Rodola'915d1412014-06-11 03:54:30 +0200599socket
600------
601
602* New :meth:`socket.socket.sendfile` method allows to send a file over a socket
603 by using high-performance :func:`os.sendfile` function on UNIX resulting in
604 uploads being from 2x to 3x faster than when using plain
605 :meth:`socket.socket.send`.
Serhiy Storchakac1ded292014-11-02 19:22:02 +0200606 (Contributed by Giampaolo Rodola' in :issue:`17552`.)
Giampaolo Rodola'915d1412014-06-11 03:54:30 +0200607
Gregory P. Smith6e730002015-04-14 16:14:25 -0700608subprocess
609----------
610
611* The new :func:`subprocess.run` function runs subprocesses and returns a
612 :class:`subprocess.CompletedProcess` object. It Provides a more consistent
613 API than :func:`~subprocess.call`, :func:`~subprocess.check_call` and
614 :func:`~subprocess.check_output`.
615
Eric V. Smith7a803892015-04-15 10:27:58 -0400616sysconfig
617---------
618
619* The user scripts directory on Windows is now versioned.
620 (Contributed by Paul Moore in :issue:`23437`.)
621
622tarfile
623-------
624
625* The :func:`tarfile.open` function now supports ``'x'`` (exclusive creation)
626 mode. (Contributed by Berker Peksag in :issue:`21717`.)
627
628* The :meth:`~tarfile.TarFile.extractall` and :meth:`~tarfile.TarFile.extract`
629 methods now take a keyword parameter *numeric_only*. If set to ``True``,
630 the extracted files and directories will be owned by the numeric uid and gid
631 from the tarfile. If set to ``False`` (the default, and the behavior in
632 versions prior to 3.5), they will be owned bythe named user and group in the
633 tarfile. (Contributed by Michael Vogt and Eric Smith in :issue:`23193`.)
634
Victor Stinnerae586492014-09-02 23:18:25 +0200635time
636----
637
Berker Peksag882c95c2014-10-09 11:46:56 +0300638* The :func:`time.monotonic` function is now always available. (Contributed by
639 Victor Stinner in :issue:`22043`.)
Victor Stinnerae586492014-09-02 23:18:25 +0200640
Yury Selivanovf3e40fa2015-05-21 11:50:30 -0400641types
642-----
643
644* New :func:`~types.coroutine` function. (Contributed by Yury Selivanov
645 in :issue:`24017`.)
646
Berker Peksagbd09d7b2015-02-11 15:32:34 +0200647urllib
648------
Nick Coghlanc216c482014-11-12 23:33:50 +1000649
R David Murray4c7f9952015-04-16 16:36:18 -0400650* A new :class:`~urllib.request.HTTPPasswordMgrWithPriorAuth` allows HTTP Basic
651 Authentication credentials to be managed so as to eliminate unnecessary
652 ``401`` response handling, or to unconditionally send credentials
653 on the first request in order to communicate with servers that return a
654 ``404`` response instead of a ``401`` if the ``Authorization`` header is not
655 sent. (Contributed by Matej Cepl in :issue:`19494` and Akshit Khurana in
656 :issue:`7159`.)
Nick Coghlanc216c482014-11-12 23:33:50 +1000657
R David Murrayc17686f2015-05-17 20:44:50 -0400658* A new :func:`~urllib.parse.urlencode` parameter *quote_via* provides a way to
659 control the encoding of query parts if needed. (Contributed by Samwyse and
660 Arnon Yaari in :issue:`13866`.)
661
Berker Peksag3e887222014-07-02 08:37:22 +0300662wsgiref
663-------
664
665* *headers* parameter of :class:`wsgiref.headers.Headers` is now optional.
666 (Contributed by Pablo Torres Navarrete and SilentGhost in :issue:`5800`.)
667
Antoine Pitroub9d9ce72014-05-15 22:47:33 +0200668xmlrpc
669------
670
Serhiy Storchakac1ded292014-11-02 19:22:02 +0200671* :class:`xmlrpc.client.ServerProxy` is now a :term:`context manager`.
672 (Contributed by Claudiu Popa in :issue:`20627`.)
Brett Cannon6eaac132014-05-09 12:28:22 -0400673
Serhiy Storchaka61de0872015-04-02 21:00:13 +0300674xml.sax
675-------
676
677* SAX parsers now support a character stream of
678 :class:`~xml.sax.xmlreader.InputSource` object.
679 (Contributed by Serhiy Storchaka in :issue:`2175`.)
680
Victor Stinner95bb7142015-03-12 15:32:03 +0100681faulthandler
682------------
683
684* :func:`~faulthandler.enable`, :func:`~faulthandler.register`,
685 :func:`~faulthandler.dump_traceback` and
686 :func:`~faulthandler.dump_traceback_later` functions now accept file
687 descriptors. (Contributed by Wei Wu in :issue:`23566`.)
688
Serhiy Storchaka77d89972015-03-23 01:09:35 +0200689zipfile
690-------
691
692* Added support for writing ZIP files to unseekable streams.
693 (Contributed by Serhiy Storchaka in :issue:`23252`.)
694
Serhiy Storchaka764fc9b2015-03-25 10:09:41 +0200695* The :func:`zipfile.ZipFile.open` function now supports ``'x'`` (exclusive
696 creation) mode. (Contributed by Serhiy Storchaka in :issue:`21717`.)
697
Victor Stinner01adf062014-03-18 00:53:32 +0100698
699Optimizations
700=============
701
Antoine Pitroub9d9ce72014-05-15 22:47:33 +0200702The following performance enhancements have been added:
Victor Stinner01adf062014-03-18 00:53:32 +0100703
Victor Stinner37f20342015-03-10 13:29:41 +0100704* :func:`os.walk` has been sped up by 3-5x on POSIX systems and 7-20x
705 on Windows. This was done using the new :func:`os.scandir` function,
706 which exposes file information from the underlying ``readdir`` and
707 ``FindFirstFile``/``FindNextFile`` system calls. (Contributed by
708 Ben Hoyt with help from Victor Stinner in :issue:`23605`.)
709
Brett Cannonf299abd2015-04-13 14:21:02 -0400710* Construction of ``bytes(int)`` (filled by zero bytes) is faster and uses less
Victor Stinner2bc4d952014-06-02 22:22:42 +0200711 memory for large objects. ``calloc()`` is used instead of ``malloc()`` to
Victor Stinnerdb067af2014-05-02 22:31:14 +0200712 allocate memory for these objects.
Victor Stinner01adf062014-03-18 00:53:32 +0100713
Antoine Pitrou0dfce562014-05-15 22:55:40 +0200714* Some operations on :class:`~ipaddress.IPv4Network` and
715 :class:`~ipaddress.IPv6Network` have been massively sped up, such as
716 :meth:`~ipaddress.IPv4Network.subnets`, :meth:`~ipaddress.IPv4Network.supernet`,
717 :func:`~ipaddress.summarize_address_range`, :func:`~ipaddress.collapse_addresses`.
718 The speed up can range from 3x to 15x.
719 (:issue:`21486`, :issue:`21487`, :issue:`20826`)
720
Serhiy Storchaka87d0b452015-02-03 11:30:10 +0200721* Many operations on :class:`io.BytesIO` are now 50% to 100% faster.
Berker Peksag9121fe82015-02-15 00:45:57 +0200722 (Contributed by Serhiy Storchaka in :issue:`15381` and David Wilson in
723 :issue:`22003`.)
Serhiy Storchaka87d0b452015-02-03 11:30:10 +0200724
Serhiy Storchakac1efe5f2015-02-11 15:54:54 +0200725* :func:`marshal.dumps` is now faster (65%-85% with versions 3--4, 20-25% with
726 versions 0--2 on typical data, and up to 5x in best cases).
727 (Contributed by Serhiy Storchaka in :issue:`20416` and :issue:`23344`.)
Serhiy Storchakace921c622015-02-11 15:53:31 +0200728
Serhiy Storchaka0d4df752015-05-12 23:12:45 +0300729* The UTF-32 encoder is now 3x to 7x faster. (Contributed by Serhiy Storchaka
730 in :issue:`15027`.)
731
Victor Stinner01adf062014-03-18 00:53:32 +0100732
733Build and C API Changes
734=======================
735
736Changes to Python's build process and to the C API include:
737
Victor Stinnerdb067af2014-05-02 22:31:14 +0200738* New ``calloc`` functions:
739
740 * :c:func:`PyMem_RawCalloc`
741 * :c:func:`PyMem_Calloc`
742 * :c:func:`PyObject_Calloc`
743 * :c:func:`_PyObject_GC_Calloc`
Victor Stinner01adf062014-03-18 00:53:32 +0100744
745
746Deprecated
747==========
748
749Unsupported Operating Systems
750-----------------------------
751
Zachary Ware38019d12015-04-13 15:51:59 -0500752* Windows XP - Per :PEP:`11`, Microsoft support of Windows XP has ended.
Victor Stinner01adf062014-03-18 00:53:32 +0100753
754
755Deprecated Python modules, functions and methods
756------------------------------------------------
757
Brett Cannona77d0c32014-03-21 10:52:33 -0400758* The :mod:`formatter` module has now graduated to full deprecation and is still
759 slated for removal in Python 3.6.
Victor Stinner01adf062014-03-18 00:53:32 +0100760
R David Murray554bcbf2014-06-11 11:18:08 -0400761* :mod:`smtpd` has in the past always decoded the DATA portion of email
762 messages using the ``utf-8`` codec. This can now be controlled by the new
763 *decode_data* keyword to :class:`~smtpd.SMTPServer`. The default value is
764 ``True``, but this default is deprecated. Specify the *decode_data* keyword
765 with an appropriate value to avoid the deprecation warning.
766
R David Murray1813c172015-03-29 17:09:21 -0400767* Directly assigning values to the :attr:`~http.cookies.Morsel.key`,
768 :attr:`~http.cookies.Morsel.value` and
769 :attr:`~http.cookies.Morsel.coded_value` of :class:`~http.cookies.Morsel`
770 objects is deprecated. Use the :func:`~http.cookies.Morsel.set` method
771 instead. In addition, the undocumented *LegalChars* parameter of
772 :func:`~http.cookies.Morsel.set` is deprecated, and is now ignored.
Serhiy Storchaka9c1a9b22015-03-18 10:59:57 +0200773
Serhiy Storchakab876df42015-03-24 22:30:46 +0200774* Passing a format string as keyword argument *format_string* to the
775 :meth:`~string.Formatter.format` method of the :class:`string.Formatter`
776 class has been deprecated.
777
Berker Peksag2f3742b2015-05-13 12:32:20 +0300778* :func:`platform.dist` and :func:`platform.linux_distribution` functions are
779 now deprecated and will be removed in Python 3.7. Linux distributions use
780 too many different ways of describing themselves, so the functionality is
781 left to a package.
782 (Contributed by Vajrasky Kok and Berker Peksag in :issue:`1322`.)
Victor Stinner01adf062014-03-18 00:53:32 +0100783
Benjamin Petersonb1cc37c2015-05-20 22:09:43 -0500784* The previously undocumented ``from_function`` and ``from_builtin`` methods of
785 :class:`inspect.Signature` are deprecated. Use new
Yury Selivanov57c74fc2015-05-20 23:07:02 -0400786 :meth:`inspect.Signature.from_callable` instead. (Contributed by Yury
787 Selivanov in :issue:`24248`.)
788
Victor Stinner01adf062014-03-18 00:53:32 +0100789Deprecated functions and types of the C API
790-------------------------------------------
791
792* None yet.
793
794
795Deprecated features
796-------------------
797
798* None yet.
799
800
R David Murraydf75fee2014-10-03 13:02:47 -0400801Removed
802=======
803
Berker Peksag8f791d32014-11-01 10:45:57 +0200804API and Feature Removals
805------------------------
806
807The following obsolete and previously deprecated APIs and features have been
808removed:
809
R David Murraydf75fee2014-10-03 13:02:47 -0400810* The ``__version__`` attribute has been dropped from the email package. The
811 email code hasn't been shipped separately from the stdlib for a long time,
812 and the ``__version__`` string was not updated in the last few releases.
813
Berker Peksag8f791d32014-11-01 10:45:57 +0200814* The internal ``Netrc`` class in the :mod:`ftplib` module was deprecated in
Serhiy Storchakac1ded292014-11-02 19:22:02 +0200815 3.4, and has now been removed.
816 (Contributed by Matt Chaput in :issue:`6623`.)
R David Murraydf75fee2014-10-03 13:02:47 -0400817
Brett Cannonf299abd2015-04-13 14:21:02 -0400818* The concept of ``.pyo`` files has been removed.
819
R David Murraye81a7732015-04-12 18:47:56 -0400820* The JoinableQueue class in the provisional asyncio module was deprecated
821 in 3.4.4 and is now removed (:issue:`23464`).
822
823
Victor Stinner01adf062014-03-18 00:53:32 +0100824Porting to Python 3.5
825=====================
826
827This section lists previously described changes and other bugfixes
828that may require changes to your code.
829
Victor Stinnerdb067af2014-05-02 22:31:14 +0200830Changes in the Python API
831-------------------------
832
Victor Stinnerf70e1ca2015-03-30 21:16:11 +0200833* :pep:`475`: Examples of functions which are now retried when interrupted
834 instead of raising :exc:`InterruptedError` if the signal handler does not
835 raise an exception:
Victor Stinnera766ddf2015-03-26 23:50:57 +0100836
Victor Stinner45ca48b2015-03-31 12:10:33 +0200837 - :func:`open`, :func:`os.open`, :func:`io.open`
Victor Stinneracd8e7c2015-04-02 13:56:29 +0200838 - functions of the :mod:`faulthandler` module
839 - :mod:`os` functions:
840
841 * :func:`os.fchdir`
842 * :func:`os.fchmod`
843 * :func:`os.fchown`
844 * :func:`os.fdatasync`
845 * :func:`os.fstat`
846 * :func:`os.fstatvfs`
847 * :func:`os.fsync`
848 * :func:`os.ftruncate`
849 * :func:`os.mkfifo`
850 * :func:`os.mknod`
851 * :func:`os.posix_fadvise`
852 * :func:`os.posix_fallocate`
853 * :func:`os.pread`
854 * :func:`os.pwrite`
855 * :func:`os.read`
856 * :func:`os.readv`
857 * :func:`os.sendfile`
858 * :func:`os.wait3`
859 * :func:`os.wait4`
860 * :func:`os.wait`
861 * :func:`os.waitid`
862 * :func:`os.waitpid`
863 * :func:`os.write`
864 * :func:`os.writev`
865 * special cases: :func:`os.close` and :func:`os.dup2` now ignore
866 :py:data:`~errno.EINTR` error, the syscall is not retried (see the PEP
867 for the rationale)
868
Victor Stinner4448c082015-03-31 11:48:34 +0200869 - :func:`select.select`, :func:`select.poll.poll`, :func:`select.epoll.poll`,
Victor Stinner45ca48b2015-03-31 12:10:33 +0200870 :func:`select.kqueue.control`, :func:`select.devpoll.poll`
Victor Stinner708d9ba2015-04-02 11:49:42 +0200871 - :func:`socket.socket` methods:
872
873 * :meth:`~socket.socket.accept`
Victor Stinner81c41db2015-04-02 11:50:57 +0200874 * :meth:`~socket.socket.connect` (except for non-blocking sockets)
Victor Stinner708d9ba2015-04-02 11:49:42 +0200875 * :meth:`~socket.socket.recv`
876 * :meth:`~socket.socket.recvfrom`
877 * :meth:`~socket.socket.recvmsg`
878 * :meth:`~socket.socket.send`
879 * :meth:`~socket.socket.sendall`
880 * :meth:`~socket.socket.sendmsg`
881 * :meth:`~socket.socket.sendto`
882
Victor Stinnereb011cb2015-03-31 12:19:15 +0200883 - :func:`signal.sigtimedwait`, :func:`signal.sigwaitinfo`
Victor Stinnera766ddf2015-03-26 23:50:57 +0100884 - :func:`time.sleep`
885
Benjamin Petersonee6bdc02014-03-20 18:00:35 -0500886* Before Python 3.5, a :class:`datetime.time` object was considered to be false
887 if it represented midnight in UTC. This behavior was considered obscure and
888 error-prone and has been removed in Python 3.5. See :issue:`13936` for full
889 details.
Antoine Pitrou92c4d452014-04-29 10:05:59 +0200890
891* :meth:`ssl.SSLSocket.send()` now raises either :exc:`ssl.SSLWantReadError`
892 or :exc:`ssl.SSLWantWriteError` on a non-blocking socket if the operation
893 would block. Previously, it would return 0. See :issue:`20951`.
Victor Stinnerdb067af2014-05-02 22:31:14 +0200894
Victor Stinner40ee3012014-06-16 15:59:28 +0200895* The ``__name__`` attribute of generator is now set from the function name,
896 instead of being set from the code name. Use ``gen.gi_code.co_name`` to
897 retrieve the code name. Generators also have a new ``__qualname__``
898 attribute, the qualified name, which is now used for the representation
899 of a generator (``repr(gen)``). See :issue:`21205`.
900
Ezio Melotti045160b2014-08-02 18:54:30 +0300901* The deprecated "strict" mode and argument of :class:`~html.parser.HTMLParser`,
902 :meth:`HTMLParser.error`, and the :exc:`HTMLParserError` exception have been
Serhiy Storchakac1ded292014-11-02 19:22:02 +0200903 removed. (Contributed by Ezio Melotti in :issue:`15114`.)
Ezio Melotti045160b2014-08-02 18:54:30 +0300904 The *convert_charrefs* argument of :class:`~html.parser.HTMLParser` is
Serhiy Storchakac1ded292014-11-02 19:22:02 +0200905 now ``True`` by default. (Contributed by Berker Peksag in :issue:`21047`.)
Ezio Melotti045160b2014-08-02 18:54:30 +0300906
R David Murray861470c2014-10-05 11:47:01 -0400907* Although it is not formally part of the API, it is worth noting for porting
908 purposes (ie: fixing tests) that error messages that were previously of the
909 form "'sometype' does not support the buffer protocol" are now of the form "a
Serhiy Storchakac1ded292014-11-02 19:22:02 +0200910 bytes-like object is required, not 'sometype'". (Contributed by Ezio Melotti
911 in :issue:`16518`.)
R David Murray861470c2014-10-05 11:47:01 -0400912
Brett Cannonb6e25562014-11-21 12:19:28 -0500913* If the current directory is set to a directory that no longer exists then
914 :exc:`FileNotFoundError` will no longer be raised and instead
915 :meth:`~importlib.machinery.FileFinder.find_spec` will return ``None``
916 **without** caching ``None`` in :data:`sys.path_importer_cache` which is
917 different than the typical case (:issue:`22834`).
918
Berker Peksag088ca8b2015-02-06 10:17:49 +0200919* HTTP status code and messages from :mod:`http.client` and :mod:`http.server`
920 were refactored into a common :class:`~http.HTTPStatus` enum. The values in
921 :mod:`http.client` and :mod:`http.server` remain available for backwards
922 compatibility. (Contributed by Demian Brecht in :issue:`21793`.)
Serhiy Storchakae4db7692014-12-23 16:28:28 +0200923
Brett Cannon02d84542015-01-09 11:39:21 -0500924* When an import loader defines :meth:`~importlib.machinery.Loader.exec_module`
925 it is now expected to also define
926 :meth:`~importlib.machinery.Loader.create_module` (raises a
927 :exc:`DeprecationWarning` now, will be an error in Python 3.6). If the loader
928 inherits from :class:`importlib.abc.Loader` then there is nothing to do, else
929 simply define :meth:`~importlib.machinery.Loader.create_module` to return
930 ``None`` (:issue:`23014`).
931
Serhiy Storchaka83e80272015-02-03 11:04:19 +0200932* :func:`re.split` always ignored empty pattern matches, so the ``'x*'``
933 pattern worked the same as ``'x+'``, and the ``'\b'`` pattern never worked.
934 Now :func:`re.split` raises a warning if the pattern could match
935 an empty string. For compatibility use patterns that never match an empty
936 string (e.g. ``'x+'`` instead of ``'x*'``). Patterns that could only match
937 an empty string (such as ``'\b'``) now raise an error.
938
R David Murray1813c172015-03-29 17:09:21 -0400939* The :class:`~http.cookies.Morsel` dict-like interface has been made self
940 consistent: morsel comparison now takes the :attr:`~http.cookies.Morsel.key`
941 and :attr:`~http.cookies.Morsel.value` into account,
942 :meth:`~http.cookies.Morsel.copy` now results in a
R David Murrayba6ea9b2015-03-30 11:48:50 -0400943 :class:`~http.cookies.Morsel` instance rather than a :class:`dict`, and
944 :meth:`~http.cookies.Morsel.update` will now raise an exception if any of the
R David Murray1813c172015-03-29 17:09:21 -0400945 keys in the update dictionary are invalid. In addition, the undocumented
946 *LegalChars* parameter of :func:`~http.cookies.Morsel.set` is deprecated and
947 is now ignored. (:issue:`2211`)
948
Brett Cannonf299abd2015-04-13 14:21:02 -0400949* :pep:`488` has removed ``.pyo`` files from Python and introduced the optional
950 ``opt-`` tag in ``.pyc`` file names. The
951 :func:`importlib.util.cache_from_source` has gained an *optimization*
952 parameter to help control the ``opt-`` tag. Because of this, the
953 *debug_override* parameter of the function is now deprecated. `.pyo` files
954 are also no longer supported as a file argument to the Python interpreter and
955 thus serve no purpose when distributed on their own (i.e. sourcless code
956 distribution). Due to the fact that the magic number for bytecode has changed
957 in Python 3.5, all old `.pyo` files from previous versions of Python are
958 invalid regardless of this PEP.
959
Larry Hastingsa6cc5512015-04-13 17:48:40 -0400960 * The :mod:`socket` module now exports the CAN_RAW_FD_FRAMES constant on linux
961 3.6 and greater.
962
R David Murray2b781292015-04-16 12:15:09 -0400963* The `pygettext.py` Tool now uses the standard +NNNN format for timezones in
964 the POT-Creation-Date header.
965
R David Murray0c49b892015-04-16 17:14:42 -0400966* The :mod:`smtplib` module now uses :data:`sys.stderr` instead of previous
967 module level :data:`stderr` variable for debug output. If your (test)
968 program depends on patching the module level variable to capture the debug
969 output, you will need to update it to capture sys.stderr instead.
970
R David Murray2b781292015-04-16 12:15:09 -0400971
Victor Stinnerdb067af2014-05-02 22:31:14 +0200972Changes in the C API
973--------------------
974
Stefan Krahf5324d72015-01-29 14:29:51 +0100975* The undocumented :c:member:`~PyMemoryViewObject.format` member of the
976 (non-public) :c:type:`PyMemoryViewObject` structure has been removed.
977
978 All extensions relying on the relevant parts in ``memoryobject.h``
979 must be rebuilt.
980
Victor Stinnerd8f0d922014-06-02 21:57:10 +0200981* The :c:type:`PyMemAllocator` structure was renamed to
982 :c:type:`PyMemAllocatorEx` and a new ``calloc`` field was added.
Serhiy Storchakadf4518c2014-11-18 23:34:33 +0200983
984* Removed non-documented macro :c:macro:`PyObject_REPR` which leaked references.
985 Use format character ``%R`` in :c:func:`PyUnicode_FromFormat`-like functions
986 to format the :func:`repr` of the object.
Serhiy Storchaka490055a2015-03-01 10:03:02 +0200987
988* Because the lack of the :attr:`__module__` attribute breaks pickling and
989 introspection, a deprecation warning now is raised for builtin type without
990 the :attr:`__module__` attribute. Would be an AttributeError in future.
991 (:issue:`20204`)
Yury Selivanov50960882015-05-12 00:15:05 -0400992
993* As part of PEP 492 implementation, ``tp_reserved`` slot of
Yury Selivanovf3e40fa2015-05-21 11:50:30 -0400994 :c:type:`PyTypeObject` was replaced with a
995 :c:member:`PyTypeObject.tp_as_async` slot.