Ned Deily | 4829bc6 | 2016-09-12 17:29:04 -0400 | [diff] [blame] | 1 | **************************** |
| 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 | |
| 48 | This article explains the new features in Python 3.7, compared to 3.6. |
| 49 | |
Steve Dower | 3e7d93d | 2016-09-22 17:11:53 -0700 | [diff] [blame] | 50 | For full details, see the :ref:`changelog <changelog>`. |
Ned Deily | 4829bc6 | 2016-09-12 17:29:04 -0400 | [diff] [blame] | 51 | |
| 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 | |
| 59 | Summary -- 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 | |
| 70 | New Features |
| 71 | ============ |
| 72 | |
Nick Coghlan | 6ea4186 | 2017-06-11 13:16:15 +1000 | [diff] [blame] | 73 | .. _whatsnew37-pep538: |
| 74 | |
| 75 | PEP 538: Legacy C Locale Coercion |
| 76 | --------------------------------- |
| 77 | |
| 78 | An ongoing challenge within the Python 3 series has been determining a sensible |
| 79 | default strategy for handling the "7-bit ASCII" text encoding assumption |
| 80 | currently 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 |
| 83 | automatically coerce that locale to an available UTF-8 based locale as |
| 84 | described in the documentation of the new :envvar:`PYTHONCOERCECLOCALE` |
| 85 | environment variable. Automatically setting ``LC_CTYPE`` this way means that |
| 86 | both 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, |
| 88 | rather than ASCII. |
| 89 | |
| 90 | The platform support definition in :pep:`11` has also been updated to limit |
| 91 | full text handling support to suitably configured non-ASCII based locales. |
| 92 | |
| 93 | As part of this change, the default error handler for ``stdin`` and ``stdout`` |
| 94 | is now ``surrogateescape`` (rather than ``strict``) when using any of the |
| 95 | defined 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 Coghlan | eb81795 | 2017-06-18 12:29:42 +1000 | [diff] [blame] | 99 | Locale coercion is silent by default, but to assist in debugging potentially |
| 100 | locale related integration problems, explicit warnings (emitted directly on |
| 101 | ``stderr`` can be requested by setting ``PYTHONCOERCECLOCALE=warn``. This |
| 102 | setting will also cause the Python runtime to emit a warning if the legacy C |
| 103 | locale remains active when the core interpreter is initialized. |
Nick Coghlan | 6ea4186 | 2017-06-11 13:16:15 +1000 | [diff] [blame] | 104 | |
| 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 Deily | 4829bc6 | 2016-09-12 17:29:04 -0400 | [diff] [blame] | 109 | |
| 110 | |
| 111 | Other Language Changes |
| 112 | ====================== |
| 113 | |
Serhiy Storchaka | 5bb8b91 | 2016-12-16 19:19:02 +0200 | [diff] [blame] | 114 | * More than 255 arguments can now be passed to a function, and a function can |
Garvit Khatri | 1cf93a7 | 2017-03-28 23:43:38 +0800 | [diff] [blame] | 115 | now have more than 255 parameters. (Contributed by Serhiy Storchaka in |
| 116 | :issue:`12844` and :issue:`18896`.) |
Ned Deily | 4829bc6 | 2016-09-12 17:29:04 -0400 | [diff] [blame] | 117 | |
Serhiy Storchaka | dd1da7f | 2016-12-19 18:51:37 +0200 | [diff] [blame] | 118 | * :meth:`bytes.fromhex` and :meth:`bytearray.fromhex` now ignore all ASCII |
Garvit Khatri | 1cf93a7 | 2017-03-28 23:43:38 +0800 | [diff] [blame] | 119 | whitespace, not only spaces. (Contributed by Robert Xiao in :issue:`28927`.) |
Serhiy Storchaka | dd1da7f | 2016-12-19 18:51:37 +0200 | [diff] [blame] | 120 | |
Matthias Bussonnier | 1bc1564 | 2017-02-22 07:06:50 -0800 | [diff] [blame] | 121 | * :exc:`ImportError` now displays module name and module ``__file__`` path when |
Garvit Khatri | 1cf93a7 | 2017-03-28 23:43:38 +0800 | [diff] [blame] | 122 | ``from ... import ...`` fails. (Contributed by Matthias Bussonnier in :issue:`29546`.) |
Matthias Bussonnier | 1bc1564 | 2017-02-22 07:06:50 -0800 | [diff] [blame] | 123 | |
Serhiy Storchaka | f93234b | 2017-05-09 22:31:05 +0300 | [diff] [blame] | 124 | * 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 Storchaka | 7e19dbc | 2017-05-13 12:40:52 +0300 | [diff] [blame] | 128 | * ``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 Deily | 4829bc6 | 2016-09-12 17:29:04 -0400 | [diff] [blame] | 132 | |
| 133 | New Modules |
| 134 | =========== |
| 135 | |
| 136 | * None yet. |
| 137 | |
| 138 | |
| 139 | Improved Modules |
| 140 | ================ |
| 141 | |
Pierre Quentel | cc3fa20 | 2017-05-08 14:08:34 +0200 | [diff] [blame] | 142 | |
R. David Murray | 0f6b9d2 | 2017-09-06 20:25:40 -0400 | [diff] [blame] | 143 | argparse |
| 144 | -------- |
| 145 | |
| 146 | The :meth:`~argparse.ArgumentParser.parse_intermixed_args` supports letting |
| 147 | the user intermix options and positional arguments on the command line, |
| 148 | as is possible in many unix commands. It supports most but not all |
| 149 | argparse features. (Contributed by paul.j3 in :issue:`14191`.) |
| 150 | |
| 151 | |
Xiang Zhang | 13f1f42 | 2017-05-03 11:16:21 +0800 | [diff] [blame] | 152 | binascii |
| 153 | -------- |
| 154 | |
| 155 | The :func:`~binascii.b2a_uu` function now accepts an optional *backtick* |
| 156 | keyword argument. When it's true, zeros are represented by ``'`'`` |
| 157 | instead of spaces. (Contributed by Xiang Zhang in :issue:`30103`.) |
| 158 | |
Oz N Tiram | 8b7a4cc | 2017-06-06 11:35:59 +0200 | [diff] [blame] | 159 | |
| 160 | calendar |
| 161 | -------- |
| 162 | |
Walter Dörwald | f5c58c7 | 2017-06-26 18:31:52 +0200 | [diff] [blame] | 163 | The class :class:`~calendar.HTMLCalendar` has new class attributes which ease |
| 164 | the customisation of the CSS classes in the produced HTML calendar. |
Oz N Tiram | 8b7a4cc | 2017-06-06 11:35:59 +0200 | [diff] [blame] | 165 | (Contributed by Oz Tiram in :issue:`30095`.) |
| 166 | |
| 167 | cgi |
| 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 |
| 172 | is a list of strings, not bytes. |
| 173 | (Contributed by Pierre Quentel in :issue:`29979`.) |
| 174 | |
Jelle Zijlstra | 2e62469 | 2017-04-30 18:25:58 -0700 | [diff] [blame] | 175 | contextlib |
| 176 | ---------- |
| 177 | |
| 178 | :func:`contextlib.asynccontextmanager` has been added. (Contributed by |
| 179 | Jelle Zijlstra in :issue:`29679`.) |
| 180 | |
Serhiy Storchaka | 1efbf92 | 2017-06-11 14:09:39 +0300 | [diff] [blame] | 181 | dis |
| 182 | --- |
| 183 | |
| 184 | The :func:`~dis.dis` function now is able to |
| 185 | disassemble nested code objects (the code of comprehensions, generator |
| 186 | expressions and nested functions, and the code used for building nested |
| 187 | classes). (Contributed by Serhiy Storchaka in :issue:`11822`.) |
| 188 | |
Ryan Gonzalez | f9f87f0 | 2017-04-14 04:00:25 -0500 | [diff] [blame] | 189 | distutils |
| 190 | --------- |
| 191 | |
| 192 | README.rst is now included in the list of distutils standard READMEs and |
| 193 | therefore included in source distributions. |
| 194 | (Contributed by Ryan Gonzalez in :issue:`11913`.) |
| 195 | |
Pierre Quentel | 351adda | 2017-04-02 12:26:12 +0200 | [diff] [blame] | 196 | http.server |
| 197 | ----------- |
| 198 | |
| 199 | :class:`~http.server.SimpleHTTPRequestHandler` supports the HTTP |
| 200 | If-Modified-Since header. The server returns the 304 response status if the |
| 201 | target file was not modified after the time specified in the header. |
| 202 | (Contributed by Pierre Quentel in :issue:`29654`.) |
| 203 | |
Stéphane Wirtel | a17a2f5 | 2017-05-24 09:29:06 +0200 | [diff] [blame] | 204 | Add the parameter ``directory`` to the :class:`~http.server.SimpleHTTPRequestHandler` |
| 205 | and the ``--directory`` to the command line of the module :mod:`~http.server`. |
| 206 | With 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 Khatri | 1cf93a7 | 2017-03-28 23:43:38 +0800 | [diff] [blame] | 209 | locale |
| 210 | ------ |
| 211 | |
| 212 | Added another argument *monetary* in :meth:`format_string` of :mod:`locale`. |
| 213 | If *monetary* is true, the conversion uses monetary thousands separator and |
| 214 | grouping strings. (Contributed by Garvit in :issue:`10379`.) |
| 215 | |
Mark Dickinson | a0ce375 | 2017-04-05 18:34:27 +0100 | [diff] [blame] | 216 | math |
| 217 | ---- |
| 218 | |
| 219 | New :func:`~math.remainder` function, implementing the IEEE 754-style remainder |
| 220 | operation. (Contributed by Mark Dickinson in :issue:`29962`.) |
| 221 | |
Serhiy Storchaka | 8f6b344 | 2017-03-07 14:33:21 +0200 | [diff] [blame] | 222 | os |
| 223 | -- |
| 224 | |
Garvit Khatri | 1cf93a7 | 2017-03-28 23:43:38 +0800 | [diff] [blame] | 225 | Added support for :class:`bytes` paths in :func:`~os.fwalk`. (Contributed by |
| 226 | Serhiy Storchaka in :issue:`28682`.) |
Serhiy Storchaka | 8f6b344 | 2017-03-07 14:33:21 +0200 | [diff] [blame] | 227 | |
Serhiy Storchaka | ea720fe | 2017-03-30 09:12:31 +0300 | [diff] [blame] | 228 | Added support for :ref:`file descriptors <path_fd>` in :func:`~os.scandir` |
| 229 | on Unix. (Contributed by Serhiy Storchaka in :issue:`25996`.) |
| 230 | |
Antoine Pitrou | f7ecfac | 2017-05-28 11:35:14 +0200 | [diff] [blame] | 231 | New function :func:`os.register_at_fork` allows registering Python callbacks |
| 232 | to be executed on a process fork. (Contributed by Antoine Pitrou in |
| 233 | :issue:`16500`.) |
| 234 | |
Barry Warsaw | 35425d6 | 2017-09-22 12:29:42 -0400 | [diff] [blame^] | 235 | pdb |
| 236 | --- |
| 237 | |
| 238 | :func:`~pdb.set_trace` now takes an optional ``header`` keyword-only |
| 239 | argument. If given, this is printed to the console just before debugging |
| 240 | begins. |
| 241 | |
Barry Warsaw | 973b901 | 2017-09-04 17:29:27 -0400 | [diff] [blame] | 242 | string |
| 243 | ------ |
| 244 | |
| 245 | :class:`string.Template` now lets you to optionally modify the regular |
| 246 | expression pattern for braced placeholders and non-braced placeholders |
| 247 | separately. (Contributed by Barry Warsaw in :issue:`1198569`.) |
| 248 | |
Serhiy Storchaka | d9c956f | 2017-01-11 20:13:03 +0200 | [diff] [blame] | 249 | unittest.mock |
| 250 | ------------- |
| 251 | |
| 252 | The :const:`~unittest.mock.sentinel` attributes now preserve their identity |
Garvit Khatri | 1cf93a7 | 2017-03-28 23:43:38 +0800 | [diff] [blame] | 253 | when they are :mod:`copied <copy>` or :mod:`pickled <pickle>`. (Contributed by |
| 254 | Serhiy Storchaka in :issue:`20804`.) |
Serhiy Storchaka | d9c956f | 2017-01-11 20:13:03 +0200 | [diff] [blame] | 255 | |
Xiang Zhang | 267b9d2 | 2017-02-28 17:12:52 +0800 | [diff] [blame] | 256 | xmlrpc.server |
| 257 | ------------- |
| 258 | |
| 259 | :meth:`register_function` of :class:`xmlrpc.server.SimpleXMLRPCDispatcher` and |
Garvit Khatri | 1cf93a7 | 2017-03-28 23:43:38 +0800 | [diff] [blame] | 260 | its subclasses can be used as a decorator. (Contributed by Xiang Zhang in |
| 261 | :issue:`7769`.) |
Xiang Zhang | 267b9d2 | 2017-02-28 17:12:52 +0800 | [diff] [blame] | 262 | |
Benjamin Peterson | 279a962 | 2017-06-22 22:31:08 -0700 | [diff] [blame] | 263 | unicodedata |
| 264 | ----------- |
| 265 | |
| 266 | The internal :mod:`unicodedata` database has been upgraded to use `Unicode 10 |
| 267 | <http://www.unicode.org/versions/Unicode10.0.0/>`_. (Contributed by Benjamin |
| 268 | Peterson.) |
| 269 | |
Ratnadeep Debnath | 21024f0 | 2017-02-25 14:30:28 +0530 | [diff] [blame] | 270 | urllib.parse |
| 271 | ------------ |
| 272 | |
Daniel Himmelstein | dadca48 | 2017-08-10 21:45:12 -0400 | [diff] [blame] | 273 | :func:`urllib.parse.quote` has been updated from RFC 2396 to RFC 3986, |
Ratnadeep Debnath | 21024f0 | 2017-02-25 14:30:28 +0530 | [diff] [blame] | 274 | adding `~` to the set of characters that is never quoted by default. |
| 275 | (Contributed by Christian Theune and Ratnadeep Debnath in :issue:`16285`.) |
| 276 | |
Xiang Zhang | 13f1f42 | 2017-05-03 11:16:21 +0800 | [diff] [blame] | 277 | uu |
| 278 | -- |
| 279 | |
| 280 | Function :func:`~uu.encode` now accepts an optional *backtick* |
| 281 | keyword argument. When it's true, zeros are represented by ``'`'`` |
| 282 | instead of spaces. (Contributed by Xiang Zhang in :issue:`30103`.) |
| 283 | |
Paul Moore | 0780bf7 | 2017-08-26 18:04:12 +0100 | [diff] [blame] | 284 | zipapp |
| 285 | ------ |
| 286 | |
| 287 | Function :func:`zipapp.create_archive` now accepts an optional *filter* |
| 288 | argument, to allow the user to select which files should be included in the |
| 289 | archive. |
| 290 | |
Ned Deily | 4829bc6 | 2016-09-12 17:29:04 -0400 | [diff] [blame] | 291 | |
| 292 | Optimizations |
| 293 | ============= |
| 294 | |
Yury Selivanov | f239213 | 2016-12-13 19:03:51 -0500 | [diff] [blame] | 295 | * Added two new opcodes: ``LOAD_METHOD`` and ``CALL_METHOD`` to avoid |
| 296 | instantiation of bound method objects for method calls, which results |
Garvit Khatri | 1cf93a7 | 2017-03-28 23:43:38 +0800 | [diff] [blame] | 297 | in method calls being faster up to 20%. (Contributed by Yury Selivanov and |
| 298 | INADA Naoki in :issue:`26110`.) |
Yury Selivanov | f239213 | 2016-12-13 19:03:51 -0500 | [diff] [blame] | 299 | |
Serhiy Storchaka | 0a58f72 | 2017-03-30 09:11:10 +0300 | [diff] [blame] | 300 | * Searching some unlucky Unicode characters (like Ukrainian capital "Є") |
| 301 | in a string was to 25 times slower than searching other characters. |
| 302 | Now it is slower only by 3 times in worst case. |
| 303 | (Contributed by Serhiy Storchaka in :issue:`24821`.) |
| 304 | |
Serhiy Storchaka | 97553fd | 2017-03-11 23:37:16 +0200 | [diff] [blame] | 305 | * Fast implementation from standard C library is now used for functions |
Paul Romano | 992f613 | 2017-09-15 12:00:57 -0500 | [diff] [blame] | 306 | :func:`~math.erf` and :func:`~math.erfc` in the :mod:`math` module. |
| 307 | (Contributed by Serhiy Storchaka in :issue:`26121`.) |
Serhiy Storchaka | 97553fd | 2017-03-11 23:37:16 +0200 | [diff] [blame] | 308 | |
Serhiy Storchaka | ea720fe | 2017-03-30 09:12:31 +0300 | [diff] [blame] | 309 | * The :func:`os.fwalk` function has been sped up by 2 times. This was done |
| 310 | using the :func:`os.scandir` function. |
| 311 | (Contributed by Serhiy Storchaka in :issue:`25996`.) |
| 312 | |
Serhiy Storchaka | 6d336a0 | 2017-05-09 23:37:14 +0300 | [diff] [blame] | 313 | * Optimized case-insensitive matching and searching of :mod:`regular |
| 314 | expressions <re>`. Searching some patterns can now be up to 20 times faster. |
| 315 | (Contributed by Serhiy Storchaka in :issue:`30285`.) |
| 316 | |
Giampaolo Rodola | fbfaa6f | 2017-06-09 22:20:41 +0200 | [diff] [blame] | 317 | * :meth:`selectors.EpollSelector.modify`, :meth:`selectors.PollSelector.modify` |
| 318 | and :meth:`selectors.DevpollSelector.modify` may be around 10% faster under |
| 319 | heavy loads. (Contributed by Giampaolo Rodola' in :issue:`30014`) |
Ned Deily | 4829bc6 | 2016-09-12 17:29:04 -0400 | [diff] [blame] | 320 | |
| 321 | Build and C API Changes |
| 322 | ======================= |
| 323 | |
Zachary Ware | f40d4dd | 2016-09-17 01:25:24 -0500 | [diff] [blame] | 324 | * A full copy of libffi is no longer bundled for use when building the |
| 325 | :mod:`_ctypes <ctypes>` module on non-OSX UNIX platforms. An installed copy |
| 326 | of libffi is now required when building ``_ctypes`` on such platforms. |
| 327 | Contributed by Zachary Ware in :issue:`27979`. |
Ned Deily | 4829bc6 | 2016-09-12 17:29:04 -0400 | [diff] [blame] | 328 | |
Serhiy Storchaka | 007d7ff | 2016-11-22 07:58:08 +0200 | [diff] [blame] | 329 | * The fields :c:member:`name` and :c:member:`doc` of structures |
| 330 | :c:type:`PyMemberDef`, :c:type:`PyGetSetDef`, |
| 331 | :c:type:`PyStructSequence_Field`, :c:type:`PyStructSequence_Desc`, |
| 332 | and :c:type:`wrapperbase` are now of type ``const char *`` rather of |
| 333 | ``char *``. (Contributed by Serhiy Storchaka in :issue:`28761`.) |
| 334 | |
Serhiy Storchaka | 2a404b6 | 2017-01-22 23:07:07 +0200 | [diff] [blame] | 335 | * The result of :c:func:`PyUnicode_AsUTF8AndSize` and :c:func:`PyUnicode_AsUTF8` |
Garvit Khatri | 1cf93a7 | 2017-03-28 23:43:38 +0800 | [diff] [blame] | 336 | is now of type ``const char *`` rather of ``char *``. (Contributed by Serhiy |
| 337 | Storchaka in :issue:`28769`.) |
Serhiy Storchaka | 2a404b6 | 2017-01-22 23:07:07 +0200 | [diff] [blame] | 338 | |
Serhiy Storchaka | 6e08baf | 2017-01-25 13:27:44 +0200 | [diff] [blame] | 339 | * Added functions :c:func:`PySlice_Unpack` and :c:func:`PySlice_AdjustIndices`. |
| 340 | (Contributed by Serhiy Storchaka in :issue:`27867`.) |
| 341 | |
Antoine Pitrou | f7ecfac | 2017-05-28 11:35:14 +0200 | [diff] [blame] | 342 | * :c:func:`PyOS_AfterFork` is deprecated in favour of the new functions |
| 343 | :c:func:`PyOS_BeforeFork`, :c:func:`PyOS_AfterFork_Parent` and |
| 344 | :c:func:`PyOS_AfterFork_Child`. (Contributed by Antoine Pitrou in |
| 345 | :issue:`16500`.) |
| 346 | |
Zachary Ware | cb8c048 | 2017-06-15 22:34:59 -0500 | [diff] [blame] | 347 | * The Windows build process no longer depends on Subversion to pull in external |
| 348 | sources, a Python script is used to download zipfiles from GitHub instead. |
| 349 | If Python 3.6 is not found on the system (via ``py -3.6``), NuGet is used to |
| 350 | download a copy of 32-bit Python for this purpose. (Contributed by Zachary |
| 351 | Ware in :issue:`30450`.) |
| 352 | |
Antoine Pitrou | a6a4dc8 | 2017-09-07 18:56:24 +0200 | [diff] [blame] | 353 | * Support for building ``--without-threads`` is removed. |
| 354 | (Contributed by Antoine Pitrou in :issue:`31370`.). |
| 355 | |
Ned Deily | 4829bc6 | 2016-09-12 17:29:04 -0400 | [diff] [blame] | 356 | |
Nick Coghlan | 5a85167 | 2017-09-08 10:14:16 +1000 | [diff] [blame] | 357 | Other CPython Implementation Changes |
| 358 | ==================================== |
| 359 | |
| 360 | * Trace hooks may now opt out of receiving ``line`` events from the interpreter |
| 361 | by setting the new ``f_trace_lines`` attribute to :const:`False` on the frame |
| 362 | being traced. (Contributed by Nick Coghlan in :issue:`31344`.) |
| 363 | |
| 364 | * Trace hooks may now opt in to receiving ``opcode`` events from the interpreter |
| 365 | by setting the new ``f_trace_opcodes`` attribute to :const:`True` on the frame |
| 366 | being traced. (Contributed by Nick Coghlan in :issue:`31344`.) |
| 367 | |
| 368 | |
Ned Deily | 4829bc6 | 2016-09-12 17:29:04 -0400 | [diff] [blame] | 369 | Deprecated |
| 370 | ========== |
| 371 | |
Serhiy Storchaka | 6e08baf | 2017-01-25 13:27:44 +0200 | [diff] [blame] | 372 | - Function :c:func:`PySlice_GetIndicesEx` is deprecated and replaced with |
| 373 | a macro if ``Py_LIMITED_API`` is not set or set to the value between |
| 374 | ``0x03050400`` and ``0x03060000`` (not including) or ``0x03060100`` or |
| 375 | higher. (Contributed by Serhiy Storchaka in :issue:`27867`.) |
Ned Deily | 4829bc6 | 2016-09-12 17:29:04 -0400 | [diff] [blame] | 376 | |
Garvit Khatri | 1cf93a7 | 2017-03-28 23:43:38 +0800 | [diff] [blame] | 377 | - Deprecated :meth:`format` from :mod:`locale`, use the :meth:`format_string` |
| 378 | instead. (Contributed by Garvit in :issue:`10379`.) |
| 379 | |
Matthias Bussonnier | 1d4601c | 2017-02-15 18:00:32 -0800 | [diff] [blame] | 380 | - Methods |
| 381 | :meth:`MetaPathFinder.find_module() <importlib.abc.MetaPathFinder.find_module>` |
| 382 | (replaced by |
| 383 | :meth:`MetaPathFinder.find_spec() <importlib.abc.MetaPathFinder.find_spec>` |
| 384 | ) and |
| 385 | :meth:`PathEntryFinder.find_loader() <importlib.abc.PathEntryFinder.find_loader>` |
| 386 | (replaced by |
| 387 | :meth:`PathEntryFinder.find_spec() <importlib.abc.PathEntryFinder.find_spec>`) |
| 388 | both deprecated in Python 3.4 now emit :exc:`DeprecationWarning`. (Contributed |
| 389 | by Matthias Bussonnier in :issue:`29576`) |
| 390 | |
Serhiy Storchaka | f659598 | 2017-03-12 13:15:01 +0200 | [diff] [blame] | 391 | - Using non-integer value for selecting a plural form in :mod:`gettext` is |
Garvit Khatri | 1cf93a7 | 2017-03-28 23:43:38 +0800 | [diff] [blame] | 392 | now deprecated. It never correctly worked. (Contributed by Serhiy Storchaka |
| 393 | in :issue:`28692`.) |
Serhiy Storchaka | f659598 | 2017-03-12 13:15:01 +0200 | [diff] [blame] | 394 | |
Victor Stinner | 89a1c93 | 2017-05-15 11:01:21 +0200 | [diff] [blame] | 395 | - The :mod:`macpath` is now deprecated and will be removed in Python 3.8. |
| 396 | |
Ned Deily | 4829bc6 | 2016-09-12 17:29:04 -0400 | [diff] [blame] | 397 | |
Serhiy Storchaka | aefa7eb | 2017-03-23 15:48:39 +0200 | [diff] [blame] | 398 | Changes in the C API |
| 399 | -------------------- |
| 400 | |
| 401 | - The type of results of :c:func:`PyThread_start_new_thread` and |
| 402 | :c:func:`PyThread_get_thread_ident`, and the *id* parameter of |
| 403 | :c:func:`PyThreadState_SetAsyncExc` changed from :c:type:`long` to |
| 404 | :c:type:`unsigned long`. |
| 405 | (Contributed by Serhiy Storchaka in :issue:`6532`.) |
| 406 | |
Serhiy Storchaka | e613e6a | 2017-06-27 16:03:14 +0300 | [diff] [blame] | 407 | - :c:func:`PyUnicode_AsWideCharString` now raises a :exc:`ValueError` if the |
| 408 | second argument is *NULL* and the :c:type:`wchar_t*` string contains null |
| 409 | characters. (Contributed by Serhiy Storchaka in :issue:`30708`.) |
| 410 | |
Serhiy Storchaka | aefa7eb | 2017-03-23 15:48:39 +0200 | [diff] [blame] | 411 | |
Steve (Gadget) Barnes | 5b8f972 | 2017-06-28 20:14:52 +0100 | [diff] [blame] | 412 | Windows Only |
| 413 | ------------ |
| 414 | - The python launcher, (py.exe), can accept 32 & 64 bit specifiers **without** |
| 415 | having to specify a minor version as well. So ``py -3-32`` and ``py -3-64`` |
| 416 | become valid as well as ``py -3.7-32``, also the -*m*-64 and -*m.n*-64 forms |
| 417 | are now accepted to force 64 bit python even if 32 bit would have otherwise |
| 418 | been used. If the specified version is not available py.exe will error exit. |
| 419 | (Contributed by Steve Barnes in :issue:`30291`.) |
| 420 | |
| 421 | - The launcher can be run as "py -0" to produce a list of the installed pythons, |
| 422 | *with default marked with an asterix*. Running "py -0p" will include the paths. |
| 423 | If py is run with a version specifier that cannot be matched it will also print |
| 424 | the *short form* list of available specifiers. |
| 425 | (Contributed by Steve Barnes in :issue:`30362`.) |
| 426 | |
Ned Deily | 4829bc6 | 2016-09-12 17:29:04 -0400 | [diff] [blame] | 427 | Removed |
| 428 | ======= |
| 429 | |
Serhiy Storchaka | ff3dbe9 | 2016-12-06 19:25:19 +0200 | [diff] [blame] | 430 | API and Feature Removals |
| 431 | ------------------------ |
| 432 | |
| 433 | * Unknown escapes consisting of ``'\'`` and an ASCII letter in replacement |
Serhiy Storchaka | b2d6179 | 2017-01-13 21:14:40 +0200 | [diff] [blame] | 434 | templates for :func:`re.sub` were deprecated in Python 3.5, and will now |
| 435 | cause an error. |
Ned Deily | 4829bc6 | 2016-09-12 17:29:04 -0400 | [diff] [blame] | 436 | |
Serhiy Storchaka | 4f76fb1 | 2017-01-13 13:25:24 +0200 | [diff] [blame] | 437 | * Removed support of the *exclude* argument in :meth:`tarfile.TarFile.add`. |
Serhiy Storchaka | b2d6179 | 2017-01-13 21:14:40 +0200 | [diff] [blame] | 438 | It was deprecated in Python 2.7 and 3.2. Use the *filter* argument instead. |
Serhiy Storchaka | 4f76fb1 | 2017-01-13 13:25:24 +0200 | [diff] [blame] | 439 | |
Serhiy Storchaka | 9ed707e | 2017-01-13 20:55:05 +0200 | [diff] [blame] | 440 | * The ``splitunc()`` function in the :mod:`ntpath` module was deprecated in |
| 441 | Python 3.1, and has now been removed. Use the :func:`~os.path.splitdrive` |
| 442 | function instead. |
| 443 | |
Raymond Hettinger | 8b57d73 | 2017-09-10 10:23:36 -0700 | [diff] [blame] | 444 | * :func:`collections.namedtuple` no longer supports the *verbose* parameter |
| 445 | or ``_source`` attribute which showed the generated source code for the |
| 446 | named tuple class. This was part of an optimization designed to speed-up |
| 447 | class creation. (Contributed by Jelle Zijlstra with further improvements |
| 448 | by INADA Naoki, Serhiy Storchaka, and Raymond Hettinger in :issue:`28638`.) |
| 449 | |
Serhiy Storchaka | 2e56424 | 2017-03-06 17:01:06 +0200 | [diff] [blame] | 450 | * Functions :func:`bool`, :func:`float`, :func:`list` and :func:`tuple` no |
| 451 | longer take keyword arguments. The first argument of :func:`int` can now |
Daniel Porteous | 77f68e3 | 2017-06-21 10:21:48 +1000 | [diff] [blame] | 452 | be passed only as positional argument. |
Serhiy Storchaka | 2e56424 | 2017-03-06 17:01:06 +0200 | [diff] [blame] | 453 | |
Serhiy Storchaka | edef358 | 2017-05-15 13:21:31 +0300 | [diff] [blame] | 454 | * Removed previously deprecated in Python 2.4 classes ``Plist``, ``Dict`` and |
| 455 | ``_InternalDict`` in the :mod:`plistlib` module. Dict values in the result |
| 456 | of functions :func:`~plistlib.readPlist` and |
| 457 | :func:`~plistlib.readPlistFromBytes` are now normal dicts. You no longer |
| 458 | can use attribute access to access items of these dictionaries. |
| 459 | |
Ned Deily | 4829bc6 | 2016-09-12 17:29:04 -0400 | [diff] [blame] | 460 | |
| 461 | Porting to Python 3.7 |
| 462 | ===================== |
| 463 | |
| 464 | This section lists previously described changes and other bugfixes |
| 465 | that may require changes to your code. |
| 466 | |
| 467 | |
Serhiy Storchaka | 009b0a1 | 2017-01-13 09:10:51 +0200 | [diff] [blame] | 468 | Changes in the Python API |
| 469 | ------------------------- |
| 470 | |
Sanyam Khurana | b9c3da5 | 2017-06-13 22:41:14 +0530 | [diff] [blame] | 471 | * :meth:`pkgutil.walk_packages` now raises ValueError if *path* is a string. |
| 472 | Previously an empty list was returned. (Contributed by Sanyam Khurana in |
| 473 | :issue:`24744`.) |
| 474 | |
Serhiy Storchaka | 009b0a1 | 2017-01-13 09:10:51 +0200 | [diff] [blame] | 475 | * A format string argument for :meth:`string.Formatter.format` |
| 476 | is now :ref:`positional-only <positional-only_parameter>`. |
Garvit Khatri | 1cf93a7 | 2017-03-28 23:43:38 +0800 | [diff] [blame] | 477 | Passing it as a keyword argument was deprecated in Python 3.5. (Contributed |
| 478 | by Serhiy Storchaka in :issue:`29193`.) |
Serhiy Storchaka | cc28337 | 2017-01-13 09:23:15 +0200 | [diff] [blame] | 479 | |
| 480 | * Attributes :attr:`~http.cookies.Morsel.key`, |
| 481 | :attr:`~http.cookies.Morsel.value` and |
| 482 | :attr:`~http.cookies.Morsel.coded_value` of class |
| 483 | :class:`http.cookies.Morsel` are now read-only. |
Serhiy Storchaka | b2d6179 | 2017-01-13 21:14:40 +0200 | [diff] [blame] | 484 | Assigning to them was deprecated in Python 3.5. |
Serhiy Storchaka | cc28337 | 2017-01-13 09:23:15 +0200 | [diff] [blame] | 485 | Use the :meth:`~http.cookies.Morsel.set` method for setting them. |
| 486 | (Contributed by Serhiy Storchaka in :issue:`29192`.) |
INADA Naoki | 015bce6 | 2017-01-16 17:23:30 +0900 | [diff] [blame] | 487 | |
INADA Naoki | cb41b27 | 2017-02-23 00:31:59 +0900 | [diff] [blame] | 488 | * ``Module``, ``FunctionDef``, ``AsyncFunctionDef``, and |
| 489 | ``ClassDef`` AST nodes now have a new ``docstring`` field. |
| 490 | The first statement in their body is not considered as a docstring |
| 491 | anymore. ``co_firstlineno`` and ``co_lnotab`` of code object for class |
Garvit Khatri | 1cf93a7 | 2017-03-28 23:43:38 +0800 | [diff] [blame] | 492 | and module are affected by this change. (Contributed by INADA Naoki and |
| 493 | Eugene Toder in :issue:`29463`.) |
INADA Naoki | 015bce6 | 2017-01-16 17:23:30 +0900 | [diff] [blame] | 494 | |
Serhiy Storchaka | e304e33 | 2017-03-24 13:27:42 +0200 | [diff] [blame] | 495 | * The *mode* argument of :func:`os.makedirs` no longer affects the file |
| 496 | permission bits of newly-created intermediate-level directories. |
| 497 | To set their file permission bits you can set the umask before invoking |
| 498 | ``makedirs()``. |
| 499 | (Contributed by Serhiy Storchaka in :issue:`19930`.) |
| 500 | |
Victor Stinner | f87b85f | 2017-06-23 15:11:12 +0200 | [diff] [blame] | 501 | * The :attr:`struct.Struct.format` type is now :class:`str` instead of |
| 502 | :class:`bytes`. (Contributed by Victor Stinner in :issue:`21071`.) |
| 503 | |
Segev Finer | 9f3bdcb | 2017-06-28 23:51:00 +0300 | [diff] [blame] | 504 | * Due to internal changes in :mod:`socket` you won't be able to |
| 505 | :func:`socket.fromshare` a socket :func:`~socket.socket.share`-ed in older |
| 506 | Python versions. |
| 507 | |
Utkarsh Upadhyay | 8e45318 | 2017-07-28 14:42:56 +0200 | [diff] [blame] | 508 | * ``repr`` for :class:`datetime.timedelta` has changed to include keyword arguments |
| 509 | in the output. (Contributed by Utkarsh Upadhyay in :issue:`30302`.) |
| 510 | |
Serhiy Storchaka | e304e33 | 2017-03-24 13:27:42 +0200 | [diff] [blame] | 511 | |
INADA Naoki | 015bce6 | 2017-01-16 17:23:30 +0900 | [diff] [blame] | 512 | CPython bytecode changes |
| 513 | ------------------------ |
| 514 | |
Martin Panter | 91a8866 | 2017-01-24 00:30:06 +0000 | [diff] [blame] | 515 | * Added two new opcodes: :opcode:`LOAD_METHOD` and :opcode:`CALL_METHOD`. |
INADA Naoki | 015bce6 | 2017-01-16 17:23:30 +0900 | [diff] [blame] | 516 | (Contributed by Yury Selivanov and INADA Naoki in :issue:`26110`.) |