blob: 870ca066923521b8bc9cc99a40bf5680a834124f [file] [log] [blame]
Ned Deily4829bc62016-09-12 17:29:04 -04001****************************
2 What's New In Python 3.7
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.7, compared to 3.6.
49
Steve Dower3e7d93d2016-09-22 17:11:53 -070050For full details, see the :ref:`changelog <changelog>`.
Ned Deily4829bc62016-09-12 17:29:04 -040051
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.7 moves towards release,
56 so it's worth checking back even after reading earlier versions.
57
58
59Summary -- Release highlights
60=============================
61
62.. This section singles out the most important changes in Python 3.7.
63 Brevity is key.
64
65
66.. PEP-sized items next.
67
68
69
70New Features
71============
72
Nick Coghlan6ea41862017-06-11 13:16:15 +100073.. _whatsnew37-pep538:
74
75PEP 538: Legacy C Locale Coercion
76---------------------------------
77
78An ongoing challenge within the Python 3 series has been determining a sensible
79default strategy for handling the "7-bit ASCII" text encoding assumption
80currently implied by the use of the default C locale on non-Windows platforms.
81
82:pep:`538` updates the default interpreter command line interface to
83automatically coerce that locale to an available UTF-8 based locale as
84described in the documentation of the new :envvar:`PYTHONCOERCECLOCALE`
85environment variable. Automatically setting ``LC_CTYPE`` this way means that
86both the core interpreter and locale-aware C extensions (such as
87:mod:`readline`) will assume the use of UTF-8 as the default text encoding,
88rather than ASCII.
89
90The platform support definition in :pep:`11` has also been updated to limit
91full text handling support to suitably configured non-ASCII based locales.
92
93As part of this change, the default error handler for ``stdin`` and ``stdout``
94is now ``surrogateescape`` (rather than ``strict``) when using any of the
95defined coercion target locales (currently ``C.UTF-8``, ``C.utf8``, and
96``UTF-8``). The default error handler for ``stderr`` continues to be
97``backslashreplace``, regardless of locale.
98
Nick Coghlaneb817952017-06-18 12:29:42 +100099Locale coercion is silent by default, but to assist in debugging potentially
100locale related integration problems, explicit warnings (emitted directly on
101``stderr`` can be requested by setting ``PYTHONCOERCECLOCALE=warn``. This
102setting will also cause the Python runtime to emit a warning if the legacy C
103locale remains active when the core interpreter is initialized.
Nick Coghlan6ea41862017-06-11 13:16:15 +1000104
105.. seealso::
106
107 :pep:`538` -- Coercing the legacy C locale to a UTF-8 based locale
108 PEP written and implemented by Nick Coghlan.
Ned Deily4829bc62016-09-12 17:29:04 -0400109
110
111Other Language Changes
112======================
113
Serhiy Storchaka5bb8b912016-12-16 19:19:02 +0200114* More than 255 arguments can now be passed to a function, and a function can
Garvit Khatri1cf93a72017-03-28 23:43:38 +0800115 now have more than 255 parameters. (Contributed by Serhiy Storchaka in
116 :issue:`12844` and :issue:`18896`.)
Ned Deily4829bc62016-09-12 17:29:04 -0400117
Serhiy Storchakadd1da7f2016-12-19 18:51:37 +0200118* :meth:`bytes.fromhex` and :meth:`bytearray.fromhex` now ignore all ASCII
Garvit Khatri1cf93a72017-03-28 23:43:38 +0800119 whitespace, not only spaces. (Contributed by Robert Xiao in :issue:`28927`.)
Serhiy Storchakadd1da7f2016-12-19 18:51:37 +0200120
Matthias Bussonnier1bc15642017-02-22 07:06:50 -0800121* :exc:`ImportError` now displays module name and module ``__file__`` path when
Garvit Khatri1cf93a72017-03-28 23:43:38 +0800122 ``from ... import ...`` fails. (Contributed by Matthias Bussonnier in :issue:`29546`.)
Matthias Bussonnier1bc15642017-02-22 07:06:50 -0800123
Serhiy Storchakaf93234b2017-05-09 22:31:05 +0300124* Circular imports involving absolute imports with binding a submodule to
125 a name are now supported.
126 (Contributed by Serhiy Storchaka in :issue:`30024`.)
127
Serhiy Storchaka7e19dbc2017-05-13 12:40:52 +0300128* ``object.__format__(x, '')`` is now equivalent to ``str(x)`` rather than
129 ``format(str(self), '')``.
130 (Contributed by Serhiy Storchaka in :issue:`28974`.)
131
Ned Deily4829bc62016-09-12 17:29:04 -0400132
133New Modules
134===========
135
136* None yet.
137
138
139Improved Modules
140================
141
Pierre Quentelcc3fa202017-05-08 14:08:34 +0200142
R. David Murray0f6b9d22017-09-06 20:25:40 -0400143argparse
144--------
145
146The :meth:`~argparse.ArgumentParser.parse_intermixed_args` supports letting
147the user intermix options and positional arguments on the command line,
148as is possible in many unix commands. It supports most but not all
149argparse features. (Contributed by paul.j3 in :issue:`14191`.)
150
151
Xiang Zhang13f1f422017-05-03 11:16:21 +0800152binascii
153--------
154
155The :func:`~binascii.b2a_uu` function now accepts an optional *backtick*
156keyword argument. When it's true, zeros are represented by ``'`'``
157instead of spaces. (Contributed by Xiang Zhang in :issue:`30103`.)
158
Oz N Tiram8b7a4cc2017-06-06 11:35:59 +0200159
160calendar
161--------
162
Walter Dörwaldf5c58c72017-06-26 18:31:52 +0200163The class :class:`~calendar.HTMLCalendar` has new class attributes which ease
164the customisation of the CSS classes in the produced HTML calendar.
Oz N Tiram8b7a4cc2017-06-06 11:35:59 +0200165(Contributed by Oz Tiram in :issue:`30095`.)
166
167cgi
168---
169
170:func:`~cgi.parse_multipart` returns the same results as
171:class:`~FieldStorage` : for non-file fields, the value associated to a key
172is a list of strings, not bytes.
173(Contributed by Pierre Quentel in :issue:`29979`.)
174
Jelle Zijlstra2e624692017-04-30 18:25:58 -0700175contextlib
176----------
177
178:func:`contextlib.asynccontextmanager` has been added. (Contributed by
179Jelle Zijlstra in :issue:`29679`.)
180
Serhiy Storchaka1efbf922017-06-11 14:09:39 +0300181dis
182---
183
184The :func:`~dis.dis` function now is able to
185disassemble nested code objects (the code of comprehensions, generator
186expressions and nested functions, and the code used for building nested
187classes). (Contributed by Serhiy Storchaka in :issue:`11822`.)
188
Ryan Gonzalezf9f87f02017-04-14 04:00:25 -0500189distutils
190---------
191
192README.rst is now included in the list of distutils standard READMEs and
193therefore included in source distributions.
194(Contributed by Ryan Gonzalez in :issue:`11913`.)
195
Pierre Quentel351adda2017-04-02 12:26:12 +0200196http.server
197-----------
198
199:class:`~http.server.SimpleHTTPRequestHandler` supports the HTTP
200If-Modified-Since header. The server returns the 304 response status if the
201target file was not modified after the time specified in the header.
202(Contributed by Pierre Quentel in :issue:`29654`.)
203
Stéphane Wirtela17a2f52017-05-24 09:29:06 +0200204Add the parameter ``directory`` to the :class:`~http.server.SimpleHTTPRequestHandler`
205and the ``--directory`` to the command line of the module :mod:`~http.server`.
206With this parameter, the server serves the specified directory, by default it uses the current working directory.
207(Contributed by Stéphane Wirtel and Julien Palard in :issue:`28707`.)
208
Garvit Khatri1cf93a72017-03-28 23:43:38 +0800209locale
210------
211
212Added another argument *monetary* in :meth:`format_string` of :mod:`locale`.
213If *monetary* is true, the conversion uses monetary thousands separator and
214grouping strings. (Contributed by Garvit in :issue:`10379`.)
215
Mark Dickinsona0ce3752017-04-05 18:34:27 +0100216math
217----
218
219New :func:`~math.remainder` function, implementing the IEEE 754-style remainder
220operation. (Contributed by Mark Dickinson in :issue:`29962`.)
221
Serhiy Storchaka8f6b3442017-03-07 14:33:21 +0200222os
223--
224
Garvit Khatri1cf93a72017-03-28 23:43:38 +0800225Added support for :class:`bytes` paths in :func:`~os.fwalk`. (Contributed by
226Serhiy Storchaka in :issue:`28682`.)
Serhiy Storchaka8f6b3442017-03-07 14:33:21 +0200227
Serhiy Storchakaea720fe2017-03-30 09:12:31 +0300228Added support for :ref:`file descriptors <path_fd>` in :func:`~os.scandir`
229on Unix. (Contributed by Serhiy Storchaka in :issue:`25996`.)
230
Antoine Pitrouf7ecfac2017-05-28 11:35:14 +0200231New function :func:`os.register_at_fork` allows registering Python callbacks
232to be executed on a process fork. (Contributed by Antoine Pitrou in
233:issue:`16500`.)
234
Barry Warsaw973b9012017-09-04 17:29:27 -0400235string
236------
237
238:class:`string.Template` now lets you to optionally modify the regular
239expression pattern for braced placeholders and non-braced placeholders
240separately. (Contributed by Barry Warsaw in :issue:`1198569`.)
241
Serhiy Storchakad9c956f2017-01-11 20:13:03 +0200242unittest.mock
243-------------
244
245The :const:`~unittest.mock.sentinel` attributes now preserve their identity
Garvit Khatri1cf93a72017-03-28 23:43:38 +0800246when they are :mod:`copied <copy>` or :mod:`pickled <pickle>`. (Contributed by
247Serhiy Storchaka in :issue:`20804`.)
Serhiy Storchakad9c956f2017-01-11 20:13:03 +0200248
Xiang Zhang267b9d22017-02-28 17:12:52 +0800249xmlrpc.server
250-------------
251
252:meth:`register_function` of :class:`xmlrpc.server.SimpleXMLRPCDispatcher` and
Garvit Khatri1cf93a72017-03-28 23:43:38 +0800253its subclasses can be used as a decorator. (Contributed by Xiang Zhang in
254:issue:`7769`.)
Xiang Zhang267b9d22017-02-28 17:12:52 +0800255
Benjamin Peterson279a9622017-06-22 22:31:08 -0700256unicodedata
257-----------
258
259The internal :mod:`unicodedata` database has been upgraded to use `Unicode 10
260<http://www.unicode.org/versions/Unicode10.0.0/>`_. (Contributed by Benjamin
261Peterson.)
262
Ratnadeep Debnath21024f02017-02-25 14:30:28 +0530263urllib.parse
264------------
265
Daniel Himmelsteindadca482017-08-10 21:45:12 -0400266:func:`urllib.parse.quote` has been updated from RFC 2396 to RFC 3986,
Ratnadeep Debnath21024f02017-02-25 14:30:28 +0530267adding `~` to the set of characters that is never quoted by default.
268(Contributed by Christian Theune and Ratnadeep Debnath in :issue:`16285`.)
269
Xiang Zhang13f1f422017-05-03 11:16:21 +0800270uu
271--
272
273Function :func:`~uu.encode` now accepts an optional *backtick*
274keyword argument. When it's true, zeros are represented by ``'`'``
275instead of spaces. (Contributed by Xiang Zhang in :issue:`30103`.)
276
Paul Moore0780bf72017-08-26 18:04:12 +0100277zipapp
278------
279
280Function :func:`zipapp.create_archive` now accepts an optional *filter*
281argument, to allow the user to select which files should be included in the
282archive.
283
Ned Deily4829bc62016-09-12 17:29:04 -0400284
285Optimizations
286=============
287
Yury Selivanovf2392132016-12-13 19:03:51 -0500288* Added two new opcodes: ``LOAD_METHOD`` and ``CALL_METHOD`` to avoid
289 instantiation of bound method objects for method calls, which results
Garvit Khatri1cf93a72017-03-28 23:43:38 +0800290 in method calls being faster up to 20%. (Contributed by Yury Selivanov and
291 INADA Naoki in :issue:`26110`.)
Yury Selivanovf2392132016-12-13 19:03:51 -0500292
Serhiy Storchaka0a58f722017-03-30 09:11:10 +0300293* Searching some unlucky Unicode characters (like Ukrainian capital "Є")
294 in a string was to 25 times slower than searching other characters.
295 Now it is slower only by 3 times in worst case.
296 (Contributed by Serhiy Storchaka in :issue:`24821`.)
297
Serhiy Storchaka97553fd2017-03-11 23:37:16 +0200298* Fast implementation from standard C library is now used for functions
Paul Romano992f6132017-09-15 12:00:57 -0500299 :func:`~math.erf` and :func:`~math.erfc` in the :mod:`math` module.
300 (Contributed by Serhiy Storchaka in :issue:`26121`.)
Serhiy Storchaka97553fd2017-03-11 23:37:16 +0200301
Serhiy Storchakaea720fe2017-03-30 09:12:31 +0300302* The :func:`os.fwalk` function has been sped up by 2 times. This was done
303 using the :func:`os.scandir` function.
304 (Contributed by Serhiy Storchaka in :issue:`25996`.)
305
Serhiy Storchaka6d336a02017-05-09 23:37:14 +0300306* Optimized case-insensitive matching and searching of :mod:`regular
307 expressions <re>`. Searching some patterns can now be up to 20 times faster.
308 (Contributed by Serhiy Storchaka in :issue:`30285`.)
309
Giampaolo Rodolafbfaa6f2017-06-09 22:20:41 +0200310* :meth:`selectors.EpollSelector.modify`, :meth:`selectors.PollSelector.modify`
311 and :meth:`selectors.DevpollSelector.modify` may be around 10% faster under
312 heavy loads. (Contributed by Giampaolo Rodola' in :issue:`30014`)
Ned Deily4829bc62016-09-12 17:29:04 -0400313
314Build and C API Changes
315=======================
316
Zachary Waref40d4dd2016-09-17 01:25:24 -0500317* A full copy of libffi is no longer bundled for use when building the
318 :mod:`_ctypes <ctypes>` module on non-OSX UNIX platforms. An installed copy
319 of libffi is now required when building ``_ctypes`` on such platforms.
320 Contributed by Zachary Ware in :issue:`27979`.
Ned Deily4829bc62016-09-12 17:29:04 -0400321
Serhiy Storchaka007d7ff2016-11-22 07:58:08 +0200322* The fields :c:member:`name` and :c:member:`doc` of structures
323 :c:type:`PyMemberDef`, :c:type:`PyGetSetDef`,
324 :c:type:`PyStructSequence_Field`, :c:type:`PyStructSequence_Desc`,
325 and :c:type:`wrapperbase` are now of type ``const char *`` rather of
326 ``char *``. (Contributed by Serhiy Storchaka in :issue:`28761`.)
327
Serhiy Storchaka2a404b62017-01-22 23:07:07 +0200328* The result of :c:func:`PyUnicode_AsUTF8AndSize` and :c:func:`PyUnicode_AsUTF8`
Garvit Khatri1cf93a72017-03-28 23:43:38 +0800329 is now of type ``const char *`` rather of ``char *``. (Contributed by Serhiy
330 Storchaka in :issue:`28769`.)
Serhiy Storchaka2a404b62017-01-22 23:07:07 +0200331
Serhiy Storchaka6e08baf2017-01-25 13:27:44 +0200332* Added functions :c:func:`PySlice_Unpack` and :c:func:`PySlice_AdjustIndices`.
333 (Contributed by Serhiy Storchaka in :issue:`27867`.)
334
Antoine Pitrouf7ecfac2017-05-28 11:35:14 +0200335* :c:func:`PyOS_AfterFork` is deprecated in favour of the new functions
336 :c:func:`PyOS_BeforeFork`, :c:func:`PyOS_AfterFork_Parent` and
337 :c:func:`PyOS_AfterFork_Child`. (Contributed by Antoine Pitrou in
338 :issue:`16500`.)
339
Zachary Warecb8c0482017-06-15 22:34:59 -0500340* The Windows build process no longer depends on Subversion to pull in external
341 sources, a Python script is used to download zipfiles from GitHub instead.
342 If Python 3.6 is not found on the system (via ``py -3.6``), NuGet is used to
343 download a copy of 32-bit Python for this purpose. (Contributed by Zachary
344 Ware in :issue:`30450`.)
345
Antoine Pitroua6a4dc82017-09-07 18:56:24 +0200346* Support for building ``--without-threads`` is removed.
347 (Contributed by Antoine Pitrou in :issue:`31370`.).
348
Ned Deily4829bc62016-09-12 17:29:04 -0400349
Nick Coghlan5a851672017-09-08 10:14:16 +1000350Other CPython Implementation Changes
351====================================
352
353* Trace hooks may now opt out of receiving ``line`` events from the interpreter
354 by setting the new ``f_trace_lines`` attribute to :const:`False` on the frame
355 being traced. (Contributed by Nick Coghlan in :issue:`31344`.)
356
357* Trace hooks may now opt in to receiving ``opcode`` events from the interpreter
358 by setting the new ``f_trace_opcodes`` attribute to :const:`True` on the frame
359 being traced. (Contributed by Nick Coghlan in :issue:`31344`.)
360
361
Ned Deily4829bc62016-09-12 17:29:04 -0400362Deprecated
363==========
364
Serhiy Storchaka6e08baf2017-01-25 13:27:44 +0200365- Function :c:func:`PySlice_GetIndicesEx` is deprecated and replaced with
366 a macro if ``Py_LIMITED_API`` is not set or set to the value between
367 ``0x03050400`` and ``0x03060000`` (not including) or ``0x03060100`` or
368 higher. (Contributed by Serhiy Storchaka in :issue:`27867`.)
Ned Deily4829bc62016-09-12 17:29:04 -0400369
Garvit Khatri1cf93a72017-03-28 23:43:38 +0800370- Deprecated :meth:`format` from :mod:`locale`, use the :meth:`format_string`
371 instead. (Contributed by Garvit in :issue:`10379`.)
372
Matthias Bussonnier1d4601c2017-02-15 18:00:32 -0800373- Methods
374 :meth:`MetaPathFinder.find_module() <importlib.abc.MetaPathFinder.find_module>`
375 (replaced by
376 :meth:`MetaPathFinder.find_spec() <importlib.abc.MetaPathFinder.find_spec>`
377 ) and
378 :meth:`PathEntryFinder.find_loader() <importlib.abc.PathEntryFinder.find_loader>`
379 (replaced by
380 :meth:`PathEntryFinder.find_spec() <importlib.abc.PathEntryFinder.find_spec>`)
381 both deprecated in Python 3.4 now emit :exc:`DeprecationWarning`. (Contributed
382 by Matthias Bussonnier in :issue:`29576`)
383
Serhiy Storchakaf6595982017-03-12 13:15:01 +0200384- Using non-integer value for selecting a plural form in :mod:`gettext` is
Garvit Khatri1cf93a72017-03-28 23:43:38 +0800385 now deprecated. It never correctly worked. (Contributed by Serhiy Storchaka
386 in :issue:`28692`.)
Serhiy Storchakaf6595982017-03-12 13:15:01 +0200387
Victor Stinner89a1c932017-05-15 11:01:21 +0200388- The :mod:`macpath` is now deprecated and will be removed in Python 3.8.
389
Ned Deily4829bc62016-09-12 17:29:04 -0400390
Serhiy Storchakaaefa7eb2017-03-23 15:48:39 +0200391Changes in the C API
392--------------------
393
394- The type of results of :c:func:`PyThread_start_new_thread` and
395 :c:func:`PyThread_get_thread_ident`, and the *id* parameter of
396 :c:func:`PyThreadState_SetAsyncExc` changed from :c:type:`long` to
397 :c:type:`unsigned long`.
398 (Contributed by Serhiy Storchaka in :issue:`6532`.)
399
Serhiy Storchakae613e6a2017-06-27 16:03:14 +0300400- :c:func:`PyUnicode_AsWideCharString` now raises a :exc:`ValueError` if the
401 second argument is *NULL* and the :c:type:`wchar_t*` string contains null
402 characters. (Contributed by Serhiy Storchaka in :issue:`30708`.)
403
Serhiy Storchakaaefa7eb2017-03-23 15:48:39 +0200404
Steve (Gadget) Barnes5b8f9722017-06-28 20:14:52 +0100405Windows Only
406------------
407- The python launcher, (py.exe), can accept 32 & 64 bit specifiers **without**
408 having to specify a minor version as well. So ``py -3-32`` and ``py -3-64``
409 become valid as well as ``py -3.7-32``, also the -*m*-64 and -*m.n*-64 forms
410 are now accepted to force 64 bit python even if 32 bit would have otherwise
411 been used. If the specified version is not available py.exe will error exit.
412 (Contributed by Steve Barnes in :issue:`30291`.)
413
414- The launcher can be run as "py -0" to produce a list of the installed pythons,
415 *with default marked with an asterix*. Running "py -0p" will include the paths.
416 If py is run with a version specifier that cannot be matched it will also print
417 the *short form* list of available specifiers.
418 (Contributed by Steve Barnes in :issue:`30362`.)
419
Ned Deily4829bc62016-09-12 17:29:04 -0400420Removed
421=======
422
Serhiy Storchakaff3dbe92016-12-06 19:25:19 +0200423API and Feature Removals
424------------------------
425
426* Unknown escapes consisting of ``'\'`` and an ASCII letter in replacement
Serhiy Storchakab2d61792017-01-13 21:14:40 +0200427 templates for :func:`re.sub` were deprecated in Python 3.5, and will now
428 cause an error.
Ned Deily4829bc62016-09-12 17:29:04 -0400429
Serhiy Storchaka4f76fb12017-01-13 13:25:24 +0200430* Removed support of the *exclude* argument in :meth:`tarfile.TarFile.add`.
Serhiy Storchakab2d61792017-01-13 21:14:40 +0200431 It was deprecated in Python 2.7 and 3.2. Use the *filter* argument instead.
Serhiy Storchaka4f76fb12017-01-13 13:25:24 +0200432
Serhiy Storchaka9ed707e2017-01-13 20:55:05 +0200433* The ``splitunc()`` function in the :mod:`ntpath` module was deprecated in
434 Python 3.1, and has now been removed. Use the :func:`~os.path.splitdrive`
435 function instead.
436
Raymond Hettinger8b57d732017-09-10 10:23:36 -0700437* :func:`collections.namedtuple` no longer supports the *verbose* parameter
438 or ``_source`` attribute which showed the generated source code for the
439 named tuple class. This was part of an optimization designed to speed-up
440 class creation. (Contributed by Jelle Zijlstra with further improvements
441 by INADA Naoki, Serhiy Storchaka, and Raymond Hettinger in :issue:`28638`.)
442
Serhiy Storchaka2e564242017-03-06 17:01:06 +0200443* Functions :func:`bool`, :func:`float`, :func:`list` and :func:`tuple` no
444 longer take keyword arguments. The first argument of :func:`int` can now
Daniel Porteous77f68e32017-06-21 10:21:48 +1000445 be passed only as positional argument.
Serhiy Storchaka2e564242017-03-06 17:01:06 +0200446
Serhiy Storchakaedef3582017-05-15 13:21:31 +0300447* Removed previously deprecated in Python 2.4 classes ``Plist``, ``Dict`` and
448 ``_InternalDict`` in the :mod:`plistlib` module. Dict values in the result
449 of functions :func:`~plistlib.readPlist` and
450 :func:`~plistlib.readPlistFromBytes` are now normal dicts. You no longer
451 can use attribute access to access items of these dictionaries.
452
Ned Deily4829bc62016-09-12 17:29:04 -0400453
454Porting to Python 3.7
455=====================
456
457This section lists previously described changes and other bugfixes
458that may require changes to your code.
459
460
Serhiy Storchaka009b0a12017-01-13 09:10:51 +0200461Changes in the Python API
462-------------------------
463
Sanyam Khuranab9c3da52017-06-13 22:41:14 +0530464* :meth:`pkgutil.walk_packages` now raises ValueError if *path* is a string.
465 Previously an empty list was returned. (Contributed by Sanyam Khurana in
466 :issue:`24744`.)
467
Serhiy Storchaka009b0a12017-01-13 09:10:51 +0200468* A format string argument for :meth:`string.Formatter.format`
469 is now :ref:`positional-only <positional-only_parameter>`.
Garvit Khatri1cf93a72017-03-28 23:43:38 +0800470 Passing it as a keyword argument was deprecated in Python 3.5. (Contributed
471 by Serhiy Storchaka in :issue:`29193`.)
Serhiy Storchakacc283372017-01-13 09:23:15 +0200472
473* Attributes :attr:`~http.cookies.Morsel.key`,
474 :attr:`~http.cookies.Morsel.value` and
475 :attr:`~http.cookies.Morsel.coded_value` of class
476 :class:`http.cookies.Morsel` are now read-only.
Serhiy Storchakab2d61792017-01-13 21:14:40 +0200477 Assigning to them was deprecated in Python 3.5.
Serhiy Storchakacc283372017-01-13 09:23:15 +0200478 Use the :meth:`~http.cookies.Morsel.set` method for setting them.
479 (Contributed by Serhiy Storchaka in :issue:`29192`.)
INADA Naoki015bce62017-01-16 17:23:30 +0900480
INADA Naokicb41b272017-02-23 00:31:59 +0900481* ``Module``, ``FunctionDef``, ``AsyncFunctionDef``, and
482 ``ClassDef`` AST nodes now have a new ``docstring`` field.
483 The first statement in their body is not considered as a docstring
484 anymore. ``co_firstlineno`` and ``co_lnotab`` of code object for class
Garvit Khatri1cf93a72017-03-28 23:43:38 +0800485 and module are affected by this change. (Contributed by INADA Naoki and
486 Eugene Toder in :issue:`29463`.)
INADA Naoki015bce62017-01-16 17:23:30 +0900487
Serhiy Storchakae304e332017-03-24 13:27:42 +0200488* The *mode* argument of :func:`os.makedirs` no longer affects the file
489 permission bits of newly-created intermediate-level directories.
490 To set their file permission bits you can set the umask before invoking
491 ``makedirs()``.
492 (Contributed by Serhiy Storchaka in :issue:`19930`.)
493
Victor Stinnerf87b85f2017-06-23 15:11:12 +0200494* The :attr:`struct.Struct.format` type is now :class:`str` instead of
495 :class:`bytes`. (Contributed by Victor Stinner in :issue:`21071`.)
496
Segev Finer9f3bdcb2017-06-28 23:51:00 +0300497* Due to internal changes in :mod:`socket` you won't be able to
498 :func:`socket.fromshare` a socket :func:`~socket.socket.share`-ed in older
499 Python versions.
500
Utkarsh Upadhyay8e453182017-07-28 14:42:56 +0200501* ``repr`` for :class:`datetime.timedelta` has changed to include keyword arguments
502 in the output. (Contributed by Utkarsh Upadhyay in :issue:`30302`.)
503
Serhiy Storchakae304e332017-03-24 13:27:42 +0200504
INADA Naoki015bce62017-01-16 17:23:30 +0900505CPython bytecode changes
506------------------------
507
Martin Panter91a88662017-01-24 00:30:06 +0000508* Added two new opcodes: :opcode:`LOAD_METHOD` and :opcode:`CALL_METHOD`.
INADA Naoki015bce62017-01-16 17:23:30 +0900509 (Contributed by Yury Selivanov and INADA Naoki in :issue:`26110`.)