blob: feca241cf0ac28d78afd65f5f739e556916ec541 [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
52.. note:: Prerelease users should be aware that this document is currently in
53 draft form. It will be updated substantially as Python 3.5 moves towards
54 release, so it's worth checking back even after reading earlier versions.
55
56
57.. seealso::
58
Berker Peksagfa0423b2014-10-09 11:38:19 +030059 :pep:`478` - Python 3.5 Release Schedule
Victor Stinner01adf062014-03-18 00:53:32 +010060
61
62Summary -- Release highlights
63=============================
64
65.. This section singles out the most important changes in Python 3.3.
66 Brevity is key.
67
68New syntax features:
69
70* None yet.
71
72New library modules:
73
74* None yet.
75
76New built-in features:
77
78* None yet.
79
80Implementation improvements:
81
Victor Stinner71430292014-03-18 01:18:21 +010082* When the ``LC_TYPE`` locale is the POSIX locale (``C`` locale),
83 :py:data:`sys.stdin` and :py:data:`sys.stdout` are now using the
84 ``surrogateescape`` error handler, instead of the ``strict`` error handler
85 (:issue:`19977`).
Victor Stinner01adf062014-03-18 00:53:32 +010086
87Significantly Improved Library Modules:
88
89* None yet.
90
91Security improvements:
92
93* None yet.
94
95Please read on for a comprehensive list of user-facing changes.
96
97
98.. PEP-sized items next.
99
100.. _pep-4XX:
101
102.. PEP 4XX: Virtual Environments
103.. =============================
104
105
106.. (Implemented by Foo Bar.)
107
108.. .. seealso::
109
110 :pep:`4XX` - Python Virtual Environments
111 PEP written by Carl Meyer
112
113
114
115
116Other Language Changes
117======================
118
119Some smaller changes made to the core Python language are:
120
121* None yet.
122
123
124
125New Modules
126===========
127
128.. module name
129.. -----------
130
131* None yet.
132
133
134Improved Modules
135================
136
R David Murrayc31e6222014-09-29 11:25:00 -0400137code
138----
139
140* The :func:`code.InteractiveInterpreter.showtraceback` method now prints
141 the full chained traceback, just like the interactive interpreter
142 (contributed by Claudiu.Popa in :issue:`17442`).
143
Brett Cannonf1a8df02014-09-12 10:39:48 -0400144compileall
145----------
146
147* :func:`compileall.compile_dir` and :mod:`compileall`'s command-line interface
148 can now do parallel bytecode compilation.
149 (Contributed by Claudiu Popa in :issue:`16104`).
150
Antoine Pitroub9d9ce72014-05-15 22:47:33 +0200151doctest
152-------
Giampaolo Rodola'e09fb712014-04-04 15:34:17 +0200153
Antoine Pitroub9d9ce72014-05-15 22:47:33 +0200154* :func:`doctest.DocTestSuite` returns an empty :class:`unittest.TestSuite` if
155 *module* contains no docstrings instead of raising :exc:`ValueError`
156 (contributed by Glenn Jones in :issue:`15916`).
157
Serhiy Storchakac2edcdd2014-09-11 12:17:37 +0300158glob
159----
160
161* :func:`~glob.iglob` and :func:`~glob.glob` now support recursive search in
162 subdirectories using the "``**``" pattern.
163 (Contributed by Serhiy Storchaka in :issue:`13968`.)
164
Serhiy Storchaka38684c32014-09-09 19:07:49 +0300165imaplib
166-------
167
168* :class:`IMAP4` now supports the context management protocol. When used in a
169 :keyword:`with` statement, the IMAP4 ``LOGOUT`` command will be called
170 automatically at the end of the block. (Contributed by Tarek Ziadé and
171 Serhiy Storchaka in :issue:`4972`).
172
R David Murray2f608202014-06-26 12:27:57 -0400173imghdr
174------
175
176* :func:`~imghdr.what` now recognizes the `OpenEXR <http://www.openexr.com>`_
177 format (contributed by Martin vignali and Cladui Popa in :issue:`20295`).
178
Antoine Pitroub9d9ce72014-05-15 22:47:33 +0200179importlib
180---------
181
182* :class:`importlib.util.LazyLoader` allows for the lazy loading of modules in
183 applications where startup time is paramount (contributed by Brett Cannon in
184 :issue:`17621`).
185
186* :func:`importlib.abc.InspectLoader.source_to_code` is now a
187 static method to make it easier to work with source code in a string.
188 With a module object that you want to initialize you can then use
189 ``exec(code, module.__dict__)`` to execute the code in the module.
190
Brett Cannon2a17bde2014-05-30 14:55:29 -0400191* :func:`importlib.util.module_from_spec` is now the preferred way to create a
192 new module. Compared to :class:`types.ModuleType`, this new function will set
193 the various import-controlled attributes based on the passed-in spec object.
194
Antoine Pitroub9d9ce72014-05-15 22:47:33 +0200195inspect
196-------
Victor Stinner01adf062014-03-18 00:53:32 +0100197
Yury Selivanova5d63dd2014-03-27 11:31:43 -0400198* :class:`inspect.Signature` and :class:`inspect.Parameter` are now
Yury Selivanov67ae50e2014-04-08 11:46:50 -0400199 picklable and hashable (contributed by Yury Selivanov in :issue:`20726`
200 and :issue:`20334`).
Yury Selivanova5d63dd2014-03-27 11:31:43 -0400201
Yury Selivanovda396452014-03-27 12:09:24 -0400202* New class method :meth:`inspect.Signature.from_callable`, which makes
203 subclassing of :class:`~inspect.Signature` easier (contributed
204 by Yury Selivanov and Eric Snow in :issue:`17373`).
205
Antoine Pitrou0dfce562014-05-15 22:55:40 +0200206ipaddress
207---------
208
209* :class:`ipaddress.IPv4Network` and :class:`ipaddress.IPv6Network` now
210 accept an ``(address, netmask)`` tuple argument, so as to easily construct
211 network objects from existing addresses (contributed by Peter Moody
212 and Antoine Pitrou in :issue:`16531`).
213
Zachary Ware63f277b2014-06-19 09:46:37 -0500214os
215--
216
Victor Stinnere1d24f72014-07-24 12:44:07 +0200217* :class:`os.stat_result` now has a :attr:`~os.stat_result.st_file_attributes`
218 attribute on Windows (contributed by Ben Hoyt in :issue:`21719`).
Zachary Ware63f277b2014-06-19 09:46:37 -0500219
Serhiy Storchaka9baa5b22014-09-29 22:49:23 +0300220re
221--
222
223* Number of capturing groups in regular expression is no longer limited by 100.
224 (Contributed by Serhiy Storchaka in :issue:`22437`.)
225
R David Murray6ffface2014-06-11 14:40:13 -0400226shutil
227------
228
229* :func:`~shutil.move` now accepts a *copy_function* argument, allowing,
230 for example, :func:`~shutil.copy` to be used instead of the default
231 :func:`~shutil.copy2` if there is a need to ignore metadata. (Contributed by
232 Claudiu Popa in :issue:`19840`.)
233
Antoine Pitroub9d9ce72014-05-15 22:47:33 +0200234signal
235------
Brett Cannona04dbe42014-04-04 13:53:38 -0400236
Antoine Pitroub9d9ce72014-05-15 22:47:33 +0200237* Different constants of :mod:`signal` module are now enumeration values using
238 the :mod:`enum` module. This allows meaningful names to be printed during
Giampaolo Rodola'915d1412014-06-11 03:54:30 +0200239 debugging, instead of integer magic numbers”. (contributed by Giampaolo
Antoine Pitroub9d9ce72014-05-15 22:47:33 +0200240 Rodola' in :issue:`21076`)
R David Murray1976d9b2014-04-14 20:28:36 -0400241
R David Murray554bcbf2014-06-11 11:18:08 -0400242smtpd
243-----
244
245* Both :class:`~smtpd.SMTPServer` and :class:`smtpd.SMTPChannel` now accept a
246 *decode_data* keyword to determine if the DATA portion of the SMTP
247 transaction is decoded using the ``utf-8`` codec or is instead provided to
248 :meth:`~smtpd.SMTPServer.process_message` as a byte string. The default
249 is ``True`` for backward compatibility reasons, but will change to ``False``
250 in Python 3.6. (Contributed by Maciej Szulik in :issue:`19662`.)
251
R David Murray6fe56a32014-06-11 13:48:58 -0400252* It is now possible to provide, directly or via name resolution, IPv6
253 addresses in the :class:`~smtpd.SMTPServer` constructor, and have it
254 successfully connect. (Contributed by Milan Oberkirch in :issue:`14758`.)
255
R David Murray2539e672014-08-09 16:40:49 -0400256* :mod:`~smtpd.SMTPServer` now supports :rfc:`6531` via the *enable_SMTPUTF8*
257 constructor argument and a user-provided
258 :meth:`~smtpd.SMTPServer.process_smtputf8_message` method.
259
R David Murray76e13c12014-07-03 14:47:46 -0400260smtplib
261-------
262
263* A new :meth:`~smtplib.SMTP.auth` method provides a convenient way to
264 implement custom authentication mechanisms (contributed by Milan Oberkirch in
265 :issue:`15014`).
266
R David Murray4487dd02014-10-09 16:59:30 -0400267sndhdr
268------
269
270* :func:`~sndhdr.what` and :func:`~sndhdr.whathdr` now return
271 :func:`~collections.namedtuple` \s (contributed by Claudiu Popa in
272 :issue:`18615`).
273
Giampaolo Rodola'915d1412014-06-11 03:54:30 +0200274socket
275------
276
277* New :meth:`socket.socket.sendfile` method allows to send a file over a socket
278 by using high-performance :func:`os.sendfile` function on UNIX resulting in
279 uploads being from 2x to 3x faster than when using plain
280 :meth:`socket.socket.send`.
281 (contributed by Giampaolo Rodola' in :issue:`17552`)
282
Victor Stinnerae586492014-09-02 23:18:25 +0200283time
284----
285
Berker Peksag882c95c2014-10-09 11:46:56 +0300286* The :func:`time.monotonic` function is now always available. (Contributed by
287 Victor Stinner in :issue:`22043`.)
Victor Stinnerae586492014-09-02 23:18:25 +0200288
Berker Peksag3e887222014-07-02 08:37:22 +0300289wsgiref
290-------
291
292* *headers* parameter of :class:`wsgiref.headers.Headers` is now optional.
293 (Contributed by Pablo Torres Navarrete and SilentGhost in :issue:`5800`.)
294
Antoine Pitroub9d9ce72014-05-15 22:47:33 +0200295xmlrpc
296------
297
298* :class:`xmlrpc.client.ServerProxy` is now a :term:`context manager`
299 (contributed by Claudiu Popa in :issue:`20627`).
Brett Cannon6eaac132014-05-09 12:28:22 -0400300
Victor Stinner01adf062014-03-18 00:53:32 +0100301
302Optimizations
303=============
304
Antoine Pitroub9d9ce72014-05-15 22:47:33 +0200305The following performance enhancements have been added:
Victor Stinner01adf062014-03-18 00:53:32 +0100306
Victor Stinner2bc4d952014-06-02 22:22:42 +0200307* Construction of ``bytes(int)`` (filled by zero bytes) is faster and use less
308 memory for large objects. ``calloc()`` is used instead of ``malloc()`` to
Victor Stinnerdb067af2014-05-02 22:31:14 +0200309 allocate memory for these objects.
Victor Stinner01adf062014-03-18 00:53:32 +0100310
Antoine Pitrou0dfce562014-05-15 22:55:40 +0200311* Some operations on :class:`~ipaddress.IPv4Network` and
312 :class:`~ipaddress.IPv6Network` have been massively sped up, such as
313 :meth:`~ipaddress.IPv4Network.subnets`, :meth:`~ipaddress.IPv4Network.supernet`,
314 :func:`~ipaddress.summarize_address_range`, :func:`~ipaddress.collapse_addresses`.
315 The speed up can range from 3x to 15x.
316 (:issue:`21486`, :issue:`21487`, :issue:`20826`)
317
Victor Stinner01adf062014-03-18 00:53:32 +0100318
319Build and C API Changes
320=======================
321
322Changes to Python's build process and to the C API include:
323
Victor Stinnerdb067af2014-05-02 22:31:14 +0200324* New ``calloc`` functions:
325
326 * :c:func:`PyMem_RawCalloc`
327 * :c:func:`PyMem_Calloc`
328 * :c:func:`PyObject_Calloc`
329 * :c:func:`_PyObject_GC_Calloc`
Victor Stinner01adf062014-03-18 00:53:32 +0100330
331
332Deprecated
333==========
334
335Unsupported Operating Systems
336-----------------------------
337
338* None yet.
339
340
341Deprecated Python modules, functions and methods
342------------------------------------------------
343
Brett Cannona77d0c32014-03-21 10:52:33 -0400344* The :mod:`formatter` module has now graduated to full deprecation and is still
345 slated for removal in Python 3.6.
Victor Stinner01adf062014-03-18 00:53:32 +0100346
R David Murray554bcbf2014-06-11 11:18:08 -0400347* :mod:`smtpd` has in the past always decoded the DATA portion of email
348 messages using the ``utf-8`` codec. This can now be controlled by the new
349 *decode_data* keyword to :class:`~smtpd.SMTPServer`. The default value is
350 ``True``, but this default is deprecated. Specify the *decode_data* keyword
351 with an appropriate value to avoid the deprecation warning.
352
Victor Stinner01adf062014-03-18 00:53:32 +0100353
354Deprecated functions and types of the C API
355-------------------------------------------
356
357* None yet.
358
359
360Deprecated features
361-------------------
362
363* None yet.
364
365
R David Murraydf75fee2014-10-03 13:02:47 -0400366Removed
367=======
368
369* The ``__version__`` attribute has been dropped from the email package. The
370 email code hasn't been shipped separately from the stdlib for a long time,
371 and the ``__version__`` string was not updated in the last few releases.
372
373
Victor Stinner01adf062014-03-18 00:53:32 +0100374Porting to Python 3.5
375=====================
376
377This section lists previously described changes and other bugfixes
378that may require changes to your code.
379
Victor Stinnerdb067af2014-05-02 22:31:14 +0200380Changes in the Python API
381-------------------------
382
Benjamin Petersonee6bdc02014-03-20 18:00:35 -0500383* Before Python 3.5, a :class:`datetime.time` object was considered to be false
384 if it represented midnight in UTC. This behavior was considered obscure and
385 error-prone and has been removed in Python 3.5. See :issue:`13936` for full
386 details.
Antoine Pitrou92c4d452014-04-29 10:05:59 +0200387
388* :meth:`ssl.SSLSocket.send()` now raises either :exc:`ssl.SSLWantReadError`
389 or :exc:`ssl.SSLWantWriteError` on a non-blocking socket if the operation
390 would block. Previously, it would return 0. See :issue:`20951`.
Victor Stinnerdb067af2014-05-02 22:31:14 +0200391
Victor Stinner40ee3012014-06-16 15:59:28 +0200392* The ``__name__`` attribute of generator is now set from the function name,
393 instead of being set from the code name. Use ``gen.gi_code.co_name`` to
394 retrieve the code name. Generators also have a new ``__qualname__``
395 attribute, the qualified name, which is now used for the representation
396 of a generator (``repr(gen)``). See :issue:`21205`.
397
Ezio Melotti045160b2014-08-02 18:54:30 +0300398* The deprecated "strict" mode and argument of :class:`~html.parser.HTMLParser`,
399 :meth:`HTMLParser.error`, and the :exc:`HTMLParserError` exception have been
400 removed (contributed by Ezio Melotti in :issue:`15114`).
401 The *convert_charrefs* argument of :class:`~html.parser.HTMLParser` is
402 now ``True`` by default (contributed by Berker Peksag in :issue:`21047`).
403
R David Murray861470c2014-10-05 11:47:01 -0400404* Although it is not formally part of the API, it is worth noting for porting
405 purposes (ie: fixing tests) that error messages that were previously of the
406 form "'sometype' does not support the buffer protocol" are now of the form "a
407 bytes-like object is required, not 'sometype'" (contributed by Ezio Melotti
408 in :issue:`16518`).
409
Victor Stinnerdb067af2014-05-02 22:31:14 +0200410Changes in the C API
411--------------------
412
Victor Stinnerd8f0d922014-06-02 21:57:10 +0200413* The :c:type:`PyMemAllocator` structure was renamed to
414 :c:type:`PyMemAllocatorEx` and a new ``calloc`` field was added.