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 | |
Barry Warsaw | 36c1d1f | 2017-10-05 12:11:18 -0400 | [diff] [blame] | 110 | .. _whatsnew37-pep553: |
| 111 | |
| 112 | PEP 553: Built-in breakpoint() |
| 113 | ------------------------------ |
| 114 | |
| 115 | :pep:`553` describes a new built-in called ``breakpoint()`` which makes it |
| 116 | easy and consistent to enter the Python debugger. Built-in ``breakpoint()`` |
| 117 | calls ``sys.breakpointhook()``. By default, this latter imports ``pdb`` and |
| 118 | then calls ``pdb.set_trace()``, but by binding ``sys.breakpointhook()`` to the |
| 119 | function of your choosing, ``breakpoint()`` can enter any debugger. Or, the |
| 120 | environment variable :envvar:`PYTHONBREAKPOINT` can be set to the callable of |
| 121 | your debugger of choice. Set ``PYTHONBREAKPOINT=0`` to completely disable |
| 122 | built-in ``breakpoint()``. |
| 123 | |
| 124 | .. seealso:: |
| 125 | |
| 126 | :pep:`553` -- Built-in breakpoint() |
| 127 | PEP written and implemented by Barry Warsaw |
| 128 | |
Ned Deily | 4829bc6 | 2016-09-12 17:29:04 -0400 | [diff] [blame] | 129 | |
Masayuki Yamamoto | 731e189 | 2017-10-06 19:41:34 +0900 | [diff] [blame] | 130 | .. _whatsnew37-pep539: |
| 131 | |
| 132 | PEP 539: A New C-API for Thread-Local Storage in CPython |
| 133 | -------------------------------------------------------- |
| 134 | |
| 135 | While Python provides a C API for thread-local storage support; the existing |
| 136 | :ref:`Thread Local Storage (TLS) API <thread-local-storage-api>` has used |
| 137 | :c:type:`int` to represent TLS keys across all platforms. This has not |
| 138 | generally been a problem for officially-support platforms, but that is neither |
| 139 | POSIX-compliant, nor portable in any practical sense. |
| 140 | |
| 141 | :pep:`539` changes this by providing a new :ref:`Thread Specific Storage (TSS) |
| 142 | API <thread-specific-storage-api>` to CPython which supersedes use of the |
| 143 | existing TLS API within the CPython interpreter, while deprecating the existing |
| 144 | API. The TSS API uses a new type :c:type:`Py_tss_t` instead of :c:type:`int` |
| 145 | to represent TSS keys--an opaque type the definition of which may depend on |
| 146 | the underlying TLS implementation. Therefore, this will allow to build CPython |
| 147 | on platforms where the native TLS key is defined in a way that cannot be safely |
| 148 | cast to :c:type:`int`. |
| 149 | |
| 150 | Note that on platforms where the native TLS key is defined in a way that cannot |
| 151 | be safely cast to :c:type:`int`, all functions of the existing TLS API will be |
| 152 | no-op and immediately return failure. This indicates clearly that the old API |
| 153 | is not supported on platforms where it cannot be used reliably, and that no |
| 154 | effort will be made to add such support. |
| 155 | |
| 156 | .. seealso:: |
| 157 | |
| 158 | :pep:`539` -- A New C-API for Thread-Local Storage in CPython |
| 159 | PEP written by Erik M. Bray; implementation by Masayuki Yamamoto. |
| 160 | |
| 161 | |
Victor Stinner | c29b585 | 2017-11-02 07:28:27 -0700 | [diff] [blame] | 162 | PEP 564: Add new time functions with nanosecond resolution |
| 163 | ---------------------------------------------------------- |
| 164 | |
| 165 | Add six new "nanosecond" variants of existing functions to the :mod:`time` |
| 166 | module: |
| 167 | |
| 168 | * :func:`time.clock_gettime_ns` |
| 169 | * :func:`time.clock_settime_ns` |
| 170 | * :func:`time.monotonic_ns` |
| 171 | * :func:`time.perf_counter_ns` |
| 172 | * :func:`time.process_time_ns` |
| 173 | * :func:`time.time_ns` |
| 174 | |
| 175 | While similar to the existing functions without the ``_ns`` suffix, they |
| 176 | provide nanosecond resolution: they return a number of nanoseconds as a Python |
| 177 | ``int``. |
| 178 | |
| 179 | The ``time.time_ns()`` resolution is 3 times better than the ``time.time()`` |
| 180 | resolution on Linux and Windows. |
| 181 | |
| 182 | .. seealso:: |
| 183 | |
| 184 | :pep:`564` -- Add new time functions with nanosecond resolution |
| 185 | PEP written and implemented by Victor Stinner |
| 186 | |
| 187 | |
Victor Stinner | 5e3806f | 2017-11-30 11:40:24 +0100 | [diff] [blame] | 188 | New Development Mode: -X dev |
| 189 | ---------------------------- |
Victor Stinner | ccb0442 | 2017-11-16 03:20:31 -0800 | [diff] [blame] | 190 | |
Victor Stinner | 5e3806f | 2017-11-30 11:40:24 +0100 | [diff] [blame] | 191 | Add a new "development mode": ``-X dev`` command line option to enable debug |
Victor Stinner | ccb0442 | 2017-11-16 03:20:31 -0800 | [diff] [blame] | 192 | checks at runtime. |
| 193 | |
| 194 | In short, ``python3 -X dev ...`` behaves as ``PYTHONMALLOC=debug python3 -W |
| 195 | default -X faulthandler ...``, except that the PYTHONMALLOC environment |
| 196 | variable is not set in practice. |
| 197 | |
| 198 | See :option:`-X` ``dev`` for the details. |
| 199 | |
| 200 | |
Ned Deily | 4829bc6 | 2016-09-12 17:29:04 -0400 | [diff] [blame] | 201 | Other Language Changes |
| 202 | ====================== |
| 203 | |
Serhiy Storchaka | 5bb8b91 | 2016-12-16 19:19:02 +0200 | [diff] [blame] | 204 | * 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] | 205 | now have more than 255 parameters. (Contributed by Serhiy Storchaka in |
| 206 | :issue:`12844` and :issue:`18896`.) |
Ned Deily | 4829bc6 | 2016-09-12 17:29:04 -0400 | [diff] [blame] | 207 | |
Serhiy Storchaka | dd1da7f | 2016-12-19 18:51:37 +0200 | [diff] [blame] | 208 | * :meth:`bytes.fromhex` and :meth:`bytearray.fromhex` now ignore all ASCII |
Garvit Khatri | 1cf93a7 | 2017-03-28 23:43:38 +0800 | [diff] [blame] | 209 | whitespace, not only spaces. (Contributed by Robert Xiao in :issue:`28927`.) |
Serhiy Storchaka | dd1da7f | 2016-12-19 18:51:37 +0200 | [diff] [blame] | 210 | |
Matthias Bussonnier | 1bc1564 | 2017-02-22 07:06:50 -0800 | [diff] [blame] | 211 | * :exc:`ImportError` now displays module name and module ``__file__`` path when |
Garvit Khatri | 1cf93a7 | 2017-03-28 23:43:38 +0800 | [diff] [blame] | 212 | ``from ... import ...`` fails. (Contributed by Matthias Bussonnier in :issue:`29546`.) |
Matthias Bussonnier | 1bc1564 | 2017-02-22 07:06:50 -0800 | [diff] [blame] | 213 | |
Serhiy Storchaka | f93234b | 2017-05-09 22:31:05 +0300 | [diff] [blame] | 214 | * Circular imports involving absolute imports with binding a submodule to |
| 215 | a name are now supported. |
| 216 | (Contributed by Serhiy Storchaka in :issue:`30024`.) |
| 217 | |
Serhiy Storchaka | 7e19dbc | 2017-05-13 12:40:52 +0300 | [diff] [blame] | 218 | * ``object.__format__(x, '')`` is now equivalent to ``str(x)`` rather than |
| 219 | ``format(str(self), '')``. |
| 220 | (Contributed by Serhiy Storchaka in :issue:`28974`.) |
| 221 | |
Ned Deily | 4829bc6 | 2016-09-12 17:29:04 -0400 | [diff] [blame] | 222 | |
| 223 | New Modules |
| 224 | =========== |
| 225 | |
| 226 | * None yet. |
| 227 | |
| 228 | |
| 229 | Improved Modules |
| 230 | ================ |
| 231 | |
Pierre Quentel | cc3fa20 | 2017-05-08 14:08:34 +0200 | [diff] [blame] | 232 | |
R. David Murray | 0f6b9d2 | 2017-09-06 20:25:40 -0400 | [diff] [blame] | 233 | argparse |
| 234 | -------- |
| 235 | |
| 236 | The :meth:`~argparse.ArgumentParser.parse_intermixed_args` supports letting |
| 237 | the user intermix options and positional arguments on the command line, |
| 238 | as is possible in many unix commands. It supports most but not all |
| 239 | argparse features. (Contributed by paul.j3 in :issue:`14191`.) |
| 240 | |
| 241 | |
Xiang Zhang | 13f1f42 | 2017-05-03 11:16:21 +0800 | [diff] [blame] | 242 | binascii |
| 243 | -------- |
| 244 | |
| 245 | The :func:`~binascii.b2a_uu` function now accepts an optional *backtick* |
| 246 | keyword argument. When it's true, zeros are represented by ``'`'`` |
| 247 | instead of spaces. (Contributed by Xiang Zhang in :issue:`30103`.) |
| 248 | |
Oz N Tiram | 8b7a4cc | 2017-06-06 11:35:59 +0200 | [diff] [blame] | 249 | |
| 250 | calendar |
| 251 | -------- |
| 252 | |
Walter Dörwald | f5c58c7 | 2017-06-26 18:31:52 +0200 | [diff] [blame] | 253 | The class :class:`~calendar.HTMLCalendar` has new class attributes which ease |
| 254 | the customisation of the CSS classes in the produced HTML calendar. |
Oz N Tiram | 8b7a4cc | 2017-06-06 11:35:59 +0200 | [diff] [blame] | 255 | (Contributed by Oz Tiram in :issue:`30095`.) |
| 256 | |
| 257 | cgi |
| 258 | --- |
| 259 | |
| 260 | :func:`~cgi.parse_multipart` returns the same results as |
| 261 | :class:`~FieldStorage` : for non-file fields, the value associated to a key |
| 262 | is a list of strings, not bytes. |
| 263 | (Contributed by Pierre Quentel in :issue:`29979`.) |
| 264 | |
Jelle Zijlstra | 2e62469 | 2017-04-30 18:25:58 -0700 | [diff] [blame] | 265 | contextlib |
| 266 | ---------- |
| 267 | |
| 268 | :func:`contextlib.asynccontextmanager` has been added. (Contributed by |
| 269 | Jelle Zijlstra in :issue:`29679`.) |
| 270 | |
Sanyam Khurana | 7973e27 | 2017-11-08 16:20:56 +0530 | [diff] [blame] | 271 | cProfile |
| 272 | -------- |
| 273 | |
| 274 | cProfile command line now accepts `-m module_name` as an alternative to |
| 275 | script path. (Contributed by Sanyam Khurana in :issue:`21862`.) |
| 276 | |
Serhiy Storchaka | eab3ff7 | 2017-10-24 19:36:17 +0300 | [diff] [blame] | 277 | crypt |
| 278 | ----- |
| 279 | |
| 280 | Added support for the Blowfish method. |
| 281 | (Contributed by Serhiy Storchaka in :issue:`31664`.) |
| 282 | |
Serhiy Storchaka | cede8c9 | 2017-11-16 13:22:51 +0200 | [diff] [blame] | 283 | The :func:`~crypt.mksalt` function now allows to specify the number of rounds |
| 284 | for hashing. (Contributed by Serhiy Storchaka in :issue:`31702`.) |
| 285 | |
Serhiy Storchaka | 1efbf92 | 2017-06-11 14:09:39 +0300 | [diff] [blame] | 286 | dis |
| 287 | --- |
| 288 | |
| 289 | The :func:`~dis.dis` function now is able to |
| 290 | disassemble nested code objects (the code of comprehensions, generator |
| 291 | expressions and nested functions, and the code used for building nested |
| 292 | classes). (Contributed by Serhiy Storchaka in :issue:`11822`.) |
| 293 | |
Ryan Gonzalez | f9f87f0 | 2017-04-14 04:00:25 -0500 | [diff] [blame] | 294 | distutils |
| 295 | --------- |
| 296 | |
| 297 | README.rst is now included in the list of distutils standard READMEs and |
| 298 | therefore included in source distributions. |
| 299 | (Contributed by Ryan Gonzalez in :issue:`11913`.) |
| 300 | |
Berker Peksag | dcaed6b | 2017-11-23 21:34:20 +0300 | [diff] [blame] | 301 | :class:`distutils.core.setup` now raises a :exc:`TypeError` if |
| 302 | ``classifiers``, ``keywords`` and ``platforms`` fields are not specified |
| 303 | as a list. However, to minimize backwards incompatibility concerns, |
| 304 | ``keywords`` and ``platforms`` fields still accept a comma separated string. |
| 305 | (Contributed by Berker Peksag in :issue:`19610`.) |
| 306 | |
Nir Soffer | ad455cd | 2017-11-06 23:16:37 +0200 | [diff] [blame] | 307 | http.client |
| 308 | ----------- |
| 309 | |
| 310 | Add Configurable *blocksize* to ``HTTPConnection`` and |
| 311 | ``HTTPSConnection`` for improved upload throughput. |
| 312 | (Contributed by Nir Soffer in :issue:`31945`.) |
| 313 | |
Pierre Quentel | 351adda | 2017-04-02 12:26:12 +0200 | [diff] [blame] | 314 | http.server |
| 315 | ----------- |
| 316 | |
| 317 | :class:`~http.server.SimpleHTTPRequestHandler` supports the HTTP |
| 318 | If-Modified-Since header. The server returns the 304 response status if the |
| 319 | target file was not modified after the time specified in the header. |
| 320 | (Contributed by Pierre Quentel in :issue:`29654`.) |
| 321 | |
Stéphane Wirtel | a17a2f5 | 2017-05-24 09:29:06 +0200 | [diff] [blame] | 322 | Add the parameter ``directory`` to the :class:`~http.server.SimpleHTTPRequestHandler` |
| 323 | and the ``--directory`` to the command line of the module :mod:`~http.server`. |
| 324 | With this parameter, the server serves the specified directory, by default it uses the current working directory. |
| 325 | (Contributed by Stéphane Wirtel and Julien Palard in :issue:`28707`.) |
| 326 | |
Garvit Khatri | 1cf93a7 | 2017-03-28 23:43:38 +0800 | [diff] [blame] | 327 | locale |
| 328 | ------ |
| 329 | |
| 330 | Added another argument *monetary* in :meth:`format_string` of :mod:`locale`. |
| 331 | If *monetary* is true, the conversion uses monetary thousands separator and |
| 332 | grouping strings. (Contributed by Garvit in :issue:`10379`.) |
| 333 | |
Mark Dickinson | a0ce375 | 2017-04-05 18:34:27 +0100 | [diff] [blame] | 334 | math |
| 335 | ---- |
| 336 | |
| 337 | New :func:`~math.remainder` function, implementing the IEEE 754-style remainder |
| 338 | operation. (Contributed by Mark Dickinson in :issue:`29962`.) |
| 339 | |
Serhiy Storchaka | 8f6b344 | 2017-03-07 14:33:21 +0200 | [diff] [blame] | 340 | os |
| 341 | -- |
| 342 | |
Garvit Khatri | 1cf93a7 | 2017-03-28 23:43:38 +0800 | [diff] [blame] | 343 | Added support for :class:`bytes` paths in :func:`~os.fwalk`. (Contributed by |
| 344 | Serhiy Storchaka in :issue:`28682`.) |
Serhiy Storchaka | 8f6b344 | 2017-03-07 14:33:21 +0200 | [diff] [blame] | 345 | |
Serhiy Storchaka | ea720fe | 2017-03-30 09:12:31 +0300 | [diff] [blame] | 346 | Added support for :ref:`file descriptors <path_fd>` in :func:`~os.scandir` |
| 347 | on Unix. (Contributed by Serhiy Storchaka in :issue:`25996`.) |
| 348 | |
Antoine Pitrou | f7ecfac | 2017-05-28 11:35:14 +0200 | [diff] [blame] | 349 | New function :func:`os.register_at_fork` allows registering Python callbacks |
| 350 | to be executed on a process fork. (Contributed by Antoine Pitrou in |
| 351 | :issue:`16500`.) |
| 352 | |
Barry Warsaw | 35425d6 | 2017-09-22 12:29:42 -0400 | [diff] [blame] | 353 | pdb |
| 354 | --- |
| 355 | |
Berker Peksag | 12d6056 | 2017-11-04 15:17:56 +0300 | [diff] [blame] | 356 | :func:`~pdb.set_trace` now takes an optional *header* keyword-only |
Barry Warsaw | 35425d6 | 2017-09-22 12:29:42 -0400 | [diff] [blame] | 357 | argument. If given, this is printed to the console just before debugging |
Berker Peksag | 12d6056 | 2017-11-04 15:17:56 +0300 | [diff] [blame] | 358 | begins. (Contributed by Barry Warsaw in :issue:`31389`.) |
Barry Warsaw | 35425d6 | 2017-09-22 12:29:42 -0400 | [diff] [blame] | 359 | |
Serhiy Storchaka | 3557b05 | 2017-10-24 23:31:42 +0300 | [diff] [blame] | 360 | re |
| 361 | -- |
| 362 | |
| 363 | The flags :const:`re.ASCII`, :const:`re.LOCALE` and :const:`re.UNICODE` |
| 364 | can be set within the scope of a group. |
| 365 | (Contributed by Serhiy Storchaka in :issue:`31690`.) |
| 366 | |
Barry Warsaw | 973b901 | 2017-09-04 17:29:27 -0400 | [diff] [blame] | 367 | string |
| 368 | ------ |
| 369 | |
| 370 | :class:`string.Template` now lets you to optionally modify the regular |
| 371 | expression pattern for braced placeholders and non-braced placeholders |
| 372 | separately. (Contributed by Barry Warsaw in :issue:`1198569`.) |
| 373 | |
Victor Stinner | 5e3806f | 2017-11-30 11:40:24 +0100 | [diff] [blame] | 374 | sys |
| 375 | --- |
| 376 | |
| 377 | Added :attr:`sys.flags.dev_mode` flag for the new development mode. |
| 378 | |
Victor Stinner | a64ce97 | 2017-11-02 04:19:19 -0700 | [diff] [blame] | 379 | time |
| 380 | ---- |
| 381 | |
Victor Stinner | c29b585 | 2017-11-02 07:28:27 -0700 | [diff] [blame] | 382 | The :pep:`564` added six new functions with nanosecond resolution: |
| 383 | |
| 384 | * :func:`time.clock_gettime_ns` |
| 385 | * :func:`time.clock_settime_ns` |
| 386 | * :func:`time.monotonic_ns` |
| 387 | * :func:`time.perf_counter_ns` |
| 388 | * :func:`time.process_time_ns` |
| 389 | * :func:`time.time_ns` |
| 390 | |
Victor Stinner | a64ce97 | 2017-11-02 04:19:19 -0700 | [diff] [blame] | 391 | Add new clock identifiers: |
| 392 | |
| 393 | * :data:`time.CLOCK_BOOTTIME` (Linux): Identical to |
| 394 | :data:`time.CLOCK_MONOTONIC`, except it also includes any time that the |
| 395 | system is suspended. |
| 396 | * :data:`time.CLOCK_PROF` (FreeBSD, NetBSD and OpenBSD): High-resolution |
| 397 | per-process timer from the CPU. |
| 398 | * :data:`time.CLOCK_UPTIME` (FreeBSD, OpenBSD): Time whose absolute value is |
| 399 | the time the system has been running and not suspended, providing accurate |
| 400 | uptime measurement, both absolute and interval. |
| 401 | |
Antoine Pitrou | 4bd41c9 | 2017-11-15 22:52:21 +0100 | [diff] [blame] | 402 | Added functions :func:`time.thread_time` and :func:`time.thread_time_ns` |
| 403 | to get per-thread CPU time measurements. |
| 404 | (Contributed by Antoine Pitrou in :issue:`32025`.) |
| 405 | |
Jonas Haag | 4d193bc | 2017-11-28 20:40:44 +0100 | [diff] [blame] | 406 | |
| 407 | unittest |
| 408 | -------- |
| 409 | Added new command-line option ``-k`` to filter tests to run with a substring or |
| 410 | Unix shell-like pattern. For example, ``python -m unittest -k foo`` runs the |
| 411 | tests ``foo_tests.SomeTest.test_something``, ``bar_tests.SomeTest.test_foo``, |
| 412 | but not ``bar_tests.FooTest.test_something``. |
| 413 | |
| 414 | |
Serhiy Storchaka | d9c956f | 2017-01-11 20:13:03 +0200 | [diff] [blame] | 415 | unittest.mock |
| 416 | ------------- |
| 417 | |
| 418 | The :const:`~unittest.mock.sentinel` attributes now preserve their identity |
Garvit Khatri | 1cf93a7 | 2017-03-28 23:43:38 +0800 | [diff] [blame] | 419 | when they are :mod:`copied <copy>` or :mod:`pickled <pickle>`. (Contributed by |
| 420 | Serhiy Storchaka in :issue:`20804`.) |
Serhiy Storchaka | d9c956f | 2017-01-11 20:13:03 +0200 | [diff] [blame] | 421 | |
Mario Corchero | 552be9d | 2017-10-17 12:35:11 +0100 | [diff] [blame] | 422 | New function :const:`~unittest.mock.seal` will disable the creation of mock |
| 423 | children by preventing to get or set any new attribute on the sealed mock. |
| 424 | The sealing process is performed recursively. (Contributed by Mario Corchero |
| 425 | in :issue:`30541`.) |
| 426 | |
Xiang Zhang | 267b9d2 | 2017-02-28 17:12:52 +0800 | [diff] [blame] | 427 | xmlrpc.server |
| 428 | ------------- |
| 429 | |
| 430 | :meth:`register_function` of :class:`xmlrpc.server.SimpleXMLRPCDispatcher` and |
Garvit Khatri | 1cf93a7 | 2017-03-28 23:43:38 +0800 | [diff] [blame] | 431 | its subclasses can be used as a decorator. (Contributed by Xiang Zhang in |
| 432 | :issue:`7769`.) |
Xiang Zhang | 267b9d2 | 2017-02-28 17:12:52 +0800 | [diff] [blame] | 433 | |
Benjamin Peterson | 279a962 | 2017-06-22 22:31:08 -0700 | [diff] [blame] | 434 | unicodedata |
| 435 | ----------- |
| 436 | |
| 437 | The internal :mod:`unicodedata` database has been upgraded to use `Unicode 10 |
| 438 | <http://www.unicode.org/versions/Unicode10.0.0/>`_. (Contributed by Benjamin |
| 439 | Peterson.) |
| 440 | |
Ratnadeep Debnath | 21024f0 | 2017-02-25 14:30:28 +0530 | [diff] [blame] | 441 | urllib.parse |
| 442 | ------------ |
| 443 | |
Daniel Himmelstein | dadca48 | 2017-08-10 21:45:12 -0400 | [diff] [blame] | 444 | :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] | 445 | adding `~` to the set of characters that is never quoted by default. |
| 446 | (Contributed by Christian Theune and Ratnadeep Debnath in :issue:`16285`.) |
| 447 | |
Xiang Zhang | 13f1f42 | 2017-05-03 11:16:21 +0800 | [diff] [blame] | 448 | uu |
| 449 | -- |
| 450 | |
| 451 | Function :func:`~uu.encode` now accepts an optional *backtick* |
| 452 | keyword argument. When it's true, zeros are represented by ``'`'`` |
| 453 | instead of spaces. (Contributed by Xiang Zhang in :issue:`30103`.) |
| 454 | |
scoder | 101a5e8 | 2017-09-30 15:35:21 +0200 | [diff] [blame] | 455 | xml.etree |
| 456 | --------- |
| 457 | |
| 458 | :ref:`ElementPath <elementtree-xpath>` predicates in the :meth:`find` |
| 459 | methods can now compare text of the current node with ``[. = "text"]``, |
| 460 | not only text in children. Predicates also allow adding spaces for |
| 461 | better readability. (Contributed by Stefan Behnel in :issue:`31648`.) |
| 462 | |
Paul Moore | 0780bf7 | 2017-08-26 18:04:12 +0100 | [diff] [blame] | 463 | zipapp |
| 464 | ------ |
| 465 | |
| 466 | Function :func:`zipapp.create_archive` now accepts an optional *filter* |
Zhiming Wang | d87b105 | 2017-09-29 13:31:52 -0400 | [diff] [blame] | 467 | argument to allow the user to select which files should be included in the |
| 468 | archive, and an optional *compressed* argument to generate a compressed |
Paul Moore | 0780bf7 | 2017-08-26 18:04:12 +0100 | [diff] [blame] | 469 | archive. |
| 470 | |
Zhiming Wang | d87b105 | 2017-09-29 13:31:52 -0400 | [diff] [blame] | 471 | A command line option ``--compress`` has also been added to support |
| 472 | compression. |
| 473 | |
Ned Deily | 4829bc6 | 2016-09-12 17:29:04 -0400 | [diff] [blame] | 474 | |
| 475 | Optimizations |
| 476 | ============= |
| 477 | |
Yury Selivanov | f239213 | 2016-12-13 19:03:51 -0500 | [diff] [blame] | 478 | * Added two new opcodes: ``LOAD_METHOD`` and ``CALL_METHOD`` to avoid |
| 479 | instantiation of bound method objects for method calls, which results |
Garvit Khatri | 1cf93a7 | 2017-03-28 23:43:38 +0800 | [diff] [blame] | 480 | in method calls being faster up to 20%. (Contributed by Yury Selivanov and |
| 481 | INADA Naoki in :issue:`26110`.) |
Yury Selivanov | f239213 | 2016-12-13 19:03:51 -0500 | [diff] [blame] | 482 | |
Serhiy Storchaka | 0a58f72 | 2017-03-30 09:11:10 +0300 | [diff] [blame] | 483 | * Searching some unlucky Unicode characters (like Ukrainian capital "Є") |
Cody Scott | 72fa301 | 2017-11-09 13:58:59 -0500 | [diff] [blame] | 484 | in a string was up to 25 times slower than searching other characters. |
| 485 | Now it is slower only by 3 times in the worst case. |
Serhiy Storchaka | 0a58f72 | 2017-03-30 09:11:10 +0300 | [diff] [blame] | 486 | (Contributed by Serhiy Storchaka in :issue:`24821`.) |
| 487 | |
Serhiy Storchaka | 97553fd | 2017-03-11 23:37:16 +0200 | [diff] [blame] | 488 | * Fast implementation from standard C library is now used for functions |
Paul Romano | 992f613 | 2017-09-15 12:00:57 -0500 | [diff] [blame] | 489 | :func:`~math.erf` and :func:`~math.erfc` in the :mod:`math` module. |
| 490 | (Contributed by Serhiy Storchaka in :issue:`26121`.) |
Serhiy Storchaka | 97553fd | 2017-03-11 23:37:16 +0200 | [diff] [blame] | 491 | |
Serhiy Storchaka | ea720fe | 2017-03-30 09:12:31 +0300 | [diff] [blame] | 492 | * The :func:`os.fwalk` function has been sped up by 2 times. This was done |
| 493 | using the :func:`os.scandir` function. |
| 494 | (Contributed by Serhiy Storchaka in :issue:`25996`.) |
| 495 | |
Serhiy Storchaka | d4d79bc | 2017-11-04 14:16:35 +0200 | [diff] [blame] | 496 | * The :func:`shutil.rmtree` function has been sped up to 20--40%. |
| 497 | This was done using the :func:`os.scandir` function. |
| 498 | (Contributed by Serhiy Storchaka in :issue:`28564`.) |
| 499 | |
Serhiy Storchaka | 6d336a0 | 2017-05-09 23:37:14 +0300 | [diff] [blame] | 500 | * Optimized case-insensitive matching and searching of :mod:`regular |
| 501 | expressions <re>`. Searching some patterns can now be up to 20 times faster. |
| 502 | (Contributed by Serhiy Storchaka in :issue:`30285`.) |
| 503 | |
INADA Naoki | c1c47c1 | 2017-10-05 17:19:26 +0900 | [diff] [blame] | 504 | * :func:`re.compile` now converts ``flags`` parameter to int object if |
| 505 | it is ``RegexFlag``. It is now as fast as Python 3.5, and faster than |
Cody Scott | 72fa301 | 2017-11-09 13:58:59 -0500 | [diff] [blame] | 506 | Python 3.6 by about 10% depending on the pattern. |
INADA Naoki | c1c47c1 | 2017-10-05 17:19:26 +0900 | [diff] [blame] | 507 | (Contributed by INADA Naoki in :issue:`31671`.) |
| 508 | |
Giampaolo Rodola | fbfaa6f | 2017-06-09 22:20:41 +0200 | [diff] [blame] | 509 | * :meth:`selectors.EpollSelector.modify`, :meth:`selectors.PollSelector.modify` |
| 510 | and :meth:`selectors.DevpollSelector.modify` may be around 10% faster under |
| 511 | heavy loads. (Contributed by Giampaolo Rodola' in :issue:`30014`) |
Ned Deily | 4829bc6 | 2016-09-12 17:29:04 -0400 | [diff] [blame] | 512 | |
| 513 | Build and C API Changes |
| 514 | ======================= |
| 515 | |
Zachary Ware | f40d4dd | 2016-09-17 01:25:24 -0500 | [diff] [blame] | 516 | * A full copy of libffi is no longer bundled for use when building the |
| 517 | :mod:`_ctypes <ctypes>` module on non-OSX UNIX platforms. An installed copy |
| 518 | of libffi is now required when building ``_ctypes`` on such platforms. |
| 519 | Contributed by Zachary Ware in :issue:`27979`. |
Ned Deily | 4829bc6 | 2016-09-12 17:29:04 -0400 | [diff] [blame] | 520 | |
Serhiy Storchaka | 007d7ff | 2016-11-22 07:58:08 +0200 | [diff] [blame] | 521 | * The fields :c:member:`name` and :c:member:`doc` of structures |
| 522 | :c:type:`PyMemberDef`, :c:type:`PyGetSetDef`, |
| 523 | :c:type:`PyStructSequence_Field`, :c:type:`PyStructSequence_Desc`, |
| 524 | and :c:type:`wrapperbase` are now of type ``const char *`` rather of |
| 525 | ``char *``. (Contributed by Serhiy Storchaka in :issue:`28761`.) |
| 526 | |
Serhiy Storchaka | 2a404b6 | 2017-01-22 23:07:07 +0200 | [diff] [blame] | 527 | * The result of :c:func:`PyUnicode_AsUTF8AndSize` and :c:func:`PyUnicode_AsUTF8` |
Garvit Khatri | 1cf93a7 | 2017-03-28 23:43:38 +0800 | [diff] [blame] | 528 | is now of type ``const char *`` rather of ``char *``. (Contributed by Serhiy |
| 529 | Storchaka in :issue:`28769`.) |
Serhiy Storchaka | 2a404b6 | 2017-01-22 23:07:07 +0200 | [diff] [blame] | 530 | |
Oren Milman | 0ccc0f6 | 2017-10-08 11:17:46 +0300 | [diff] [blame] | 531 | * The result of :c:func:`PyMapping_Keys`, :c:func:`PyMapping_Values` and |
| 532 | :c:func:`PyMapping_Items` is now always a list, rather than a list or a |
| 533 | tuple. (Contributed by Oren Milman in :issue:`28280`.) |
| 534 | |
Serhiy Storchaka | 6e08baf | 2017-01-25 13:27:44 +0200 | [diff] [blame] | 535 | * Added functions :c:func:`PySlice_Unpack` and :c:func:`PySlice_AdjustIndices`. |
| 536 | (Contributed by Serhiy Storchaka in :issue:`27867`.) |
| 537 | |
Antoine Pitrou | f7ecfac | 2017-05-28 11:35:14 +0200 | [diff] [blame] | 538 | * :c:func:`PyOS_AfterFork` is deprecated in favour of the new functions |
| 539 | :c:func:`PyOS_BeforeFork`, :c:func:`PyOS_AfterFork_Parent` and |
| 540 | :c:func:`PyOS_AfterFork_Child`. (Contributed by Antoine Pitrou in |
| 541 | :issue:`16500`.) |
| 542 | |
Zachary Ware | cb8c048 | 2017-06-15 22:34:59 -0500 | [diff] [blame] | 543 | * The Windows build process no longer depends on Subversion to pull in external |
| 544 | sources, a Python script is used to download zipfiles from GitHub instead. |
| 545 | If Python 3.6 is not found on the system (via ``py -3.6``), NuGet is used to |
| 546 | download a copy of 32-bit Python for this purpose. (Contributed by Zachary |
| 547 | Ware in :issue:`30450`.) |
| 548 | |
xdegaye | 56d1f5c | 2017-10-26 15:09:06 +0200 | [diff] [blame] | 549 | * The ``PyExc_RecursionErrorInst`` singleton that was part of the public API |
| 550 | has been removed as its members being never cleared may cause a segfault |
| 551 | during finalization of the interpreter. Contributed by Xavier de Gaye in |
| 552 | :issue:`22898` and :issue:`30697`. |
| 553 | |
Antoine Pitrou | a6a4dc8 | 2017-09-07 18:56:24 +0200 | [diff] [blame] | 554 | * Support for building ``--without-threads`` is removed. |
| 555 | (Contributed by Antoine Pitrou in :issue:`31370`.). |
| 556 | |
Ned Deily | 4829bc6 | 2016-09-12 17:29:04 -0400 | [diff] [blame] | 557 | |
Nick Coghlan | 5a85167 | 2017-09-08 10:14:16 +1000 | [diff] [blame] | 558 | Other CPython Implementation Changes |
| 559 | ==================================== |
| 560 | |
| 561 | * Trace hooks may now opt out of receiving ``line`` events from the interpreter |
| 562 | by setting the new ``f_trace_lines`` attribute to :const:`False` on the frame |
| 563 | being traced. (Contributed by Nick Coghlan in :issue:`31344`.) |
| 564 | |
| 565 | * Trace hooks may now opt in to receiving ``opcode`` events from the interpreter |
| 566 | by setting the new ``f_trace_opcodes`` attribute to :const:`True` on the frame |
| 567 | being traced. (Contributed by Nick Coghlan in :issue:`31344`.) |
| 568 | |
| 569 | |
Ned Deily | 4829bc6 | 2016-09-12 17:29:04 -0400 | [diff] [blame] | 570 | Deprecated |
| 571 | ========== |
| 572 | |
Serhiy Storchaka | 73a7e9b | 2017-12-01 06:54:17 +0200 | [diff] [blame^] | 573 | * Yield expressions (both ``yield`` and ``yield from`` clauses) are now deprecated |
| 574 | in comprehensions and generator expressions (aside from the iterable expression |
| 575 | in the leftmost :keyword:`for` clause). This ensures that comprehensions |
| 576 | always immediately return a container of the appropriate type (rather than |
| 577 | potentially returning a :term:`generator iterator` object), while generator |
| 578 | expressions won't attempt to interleave their implicit output with the output |
| 579 | from any explicit yield expressions. |
| 580 | |
| 581 | In Python 3.7, such expressions emit :exc:`DeprecationWarning` when compiled, |
| 582 | in Python 3.8+ they will emit :exc:`SyntaxError`. (Contributed by Serhiy |
| 583 | Storchaka in :issue:`10544`.) |
| 584 | |
Serhiy Storchaka | 6e08baf | 2017-01-25 13:27:44 +0200 | [diff] [blame] | 585 | - Function :c:func:`PySlice_GetIndicesEx` is deprecated and replaced with |
| 586 | a macro if ``Py_LIMITED_API`` is not set or set to the value between |
| 587 | ``0x03050400`` and ``0x03060000`` (not including) or ``0x03060100`` or |
| 588 | higher. (Contributed by Serhiy Storchaka in :issue:`27867`.) |
Ned Deily | 4829bc6 | 2016-09-12 17:29:04 -0400 | [diff] [blame] | 589 | |
Garvit Khatri | 1cf93a7 | 2017-03-28 23:43:38 +0800 | [diff] [blame] | 590 | - Deprecated :meth:`format` from :mod:`locale`, use the :meth:`format_string` |
| 591 | instead. (Contributed by Garvit in :issue:`10379`.) |
| 592 | |
Matthias Bussonnier | 1d4601c | 2017-02-15 18:00:32 -0800 | [diff] [blame] | 593 | - Methods |
| 594 | :meth:`MetaPathFinder.find_module() <importlib.abc.MetaPathFinder.find_module>` |
| 595 | (replaced by |
| 596 | :meth:`MetaPathFinder.find_spec() <importlib.abc.MetaPathFinder.find_spec>` |
| 597 | ) and |
| 598 | :meth:`PathEntryFinder.find_loader() <importlib.abc.PathEntryFinder.find_loader>` |
| 599 | (replaced by |
| 600 | :meth:`PathEntryFinder.find_spec() <importlib.abc.PathEntryFinder.find_spec>`) |
| 601 | both deprecated in Python 3.4 now emit :exc:`DeprecationWarning`. (Contributed |
| 602 | by Matthias Bussonnier in :issue:`29576`) |
| 603 | |
Serhiy Storchaka | f659598 | 2017-03-12 13:15:01 +0200 | [diff] [blame] | 604 | - 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] | 605 | now deprecated. It never correctly worked. (Contributed by Serhiy Storchaka |
| 606 | in :issue:`28692`.) |
Serhiy Storchaka | f659598 | 2017-03-12 13:15:01 +0200 | [diff] [blame] | 607 | |
Victor Stinner | 89a1c93 | 2017-05-15 11:01:21 +0200 | [diff] [blame] | 608 | - The :mod:`macpath` is now deprecated and will be removed in Python 3.8. |
| 609 | |
Ned Deily | 4829bc6 | 2016-09-12 17:29:04 -0400 | [diff] [blame] | 610 | |
Serhiy Storchaka | aefa7eb | 2017-03-23 15:48:39 +0200 | [diff] [blame] | 611 | Changes in the C API |
| 612 | -------------------- |
| 613 | |
| 614 | - The type of results of :c:func:`PyThread_start_new_thread` and |
| 615 | :c:func:`PyThread_get_thread_ident`, and the *id* parameter of |
| 616 | :c:func:`PyThreadState_SetAsyncExc` changed from :c:type:`long` to |
| 617 | :c:type:`unsigned long`. |
| 618 | (Contributed by Serhiy Storchaka in :issue:`6532`.) |
| 619 | |
Serhiy Storchaka | e613e6a | 2017-06-27 16:03:14 +0300 | [diff] [blame] | 620 | - :c:func:`PyUnicode_AsWideCharString` now raises a :exc:`ValueError` if the |
| 621 | second argument is *NULL* and the :c:type:`wchar_t*` string contains null |
| 622 | characters. (Contributed by Serhiy Storchaka in :issue:`30708`.) |
| 623 | |
Serhiy Storchaka | aefa7eb | 2017-03-23 15:48:39 +0200 | [diff] [blame] | 624 | |
Steve (Gadget) Barnes | 5b8f972 | 2017-06-28 20:14:52 +0100 | [diff] [blame] | 625 | Windows Only |
| 626 | ------------ |
| 627 | - The python launcher, (py.exe), can accept 32 & 64 bit specifiers **without** |
| 628 | having to specify a minor version as well. So ``py -3-32`` and ``py -3-64`` |
| 629 | become valid as well as ``py -3.7-32``, also the -*m*-64 and -*m.n*-64 forms |
| 630 | are now accepted to force 64 bit python even if 32 bit would have otherwise |
| 631 | been used. If the specified version is not available py.exe will error exit. |
| 632 | (Contributed by Steve Barnes in :issue:`30291`.) |
| 633 | |
| 634 | - The launcher can be run as "py -0" to produce a list of the installed pythons, |
| 635 | *with default marked with an asterix*. Running "py -0p" will include the paths. |
| 636 | If py is run with a version specifier that cannot be matched it will also print |
| 637 | the *short form* list of available specifiers. |
| 638 | (Contributed by Steve Barnes in :issue:`30362`.) |
| 639 | |
Ned Deily | 4829bc6 | 2016-09-12 17:29:04 -0400 | [diff] [blame] | 640 | Removed |
| 641 | ======= |
| 642 | |
Serhiy Storchaka | ff3dbe9 | 2016-12-06 19:25:19 +0200 | [diff] [blame] | 643 | API and Feature Removals |
| 644 | ------------------------ |
| 645 | |
Victor Stinner | 01b5aab | 2017-10-24 02:02:00 -0700 | [diff] [blame] | 646 | * The ``os.stat_float_times()`` function has been removed. It was introduced in |
| 647 | Python 2.3 for backward compatibility with Python 2.2, and was deprecated |
| 648 | since Python 3.1. |
| 649 | |
Serhiy Storchaka | ff3dbe9 | 2016-12-06 19:25:19 +0200 | [diff] [blame] | 650 | * Unknown escapes consisting of ``'\'`` and an ASCII letter in replacement |
Serhiy Storchaka | b2d6179 | 2017-01-13 21:14:40 +0200 | [diff] [blame] | 651 | templates for :func:`re.sub` were deprecated in Python 3.5, and will now |
| 652 | cause an error. |
Ned Deily | 4829bc6 | 2016-09-12 17:29:04 -0400 | [diff] [blame] | 653 | |
Serhiy Storchaka | 4f76fb1 | 2017-01-13 13:25:24 +0200 | [diff] [blame] | 654 | * Removed support of the *exclude* argument in :meth:`tarfile.TarFile.add`. |
Serhiy Storchaka | b2d6179 | 2017-01-13 21:14:40 +0200 | [diff] [blame] | 655 | 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] | 656 | |
Serhiy Storchaka | 9ed707e | 2017-01-13 20:55:05 +0200 | [diff] [blame] | 657 | * The ``splitunc()`` function in the :mod:`ntpath` module was deprecated in |
| 658 | Python 3.1, and has now been removed. Use the :func:`~os.path.splitdrive` |
| 659 | function instead. |
| 660 | |
Raymond Hettinger | 8b57d73 | 2017-09-10 10:23:36 -0700 | [diff] [blame] | 661 | * :func:`collections.namedtuple` no longer supports the *verbose* parameter |
| 662 | or ``_source`` attribute which showed the generated source code for the |
| 663 | named tuple class. This was part of an optimization designed to speed-up |
| 664 | class creation. (Contributed by Jelle Zijlstra with further improvements |
| 665 | by INADA Naoki, Serhiy Storchaka, and Raymond Hettinger in :issue:`28638`.) |
| 666 | |
Serhiy Storchaka | 2e56424 | 2017-03-06 17:01:06 +0200 | [diff] [blame] | 667 | * Functions :func:`bool`, :func:`float`, :func:`list` and :func:`tuple` no |
| 668 | longer take keyword arguments. The first argument of :func:`int` can now |
Daniel Porteous | 77f68e3 | 2017-06-21 10:21:48 +1000 | [diff] [blame] | 669 | be passed only as positional argument. |
Serhiy Storchaka | 2e56424 | 2017-03-06 17:01:06 +0200 | [diff] [blame] | 670 | |
Serhiy Storchaka | edef358 | 2017-05-15 13:21:31 +0300 | [diff] [blame] | 671 | * Removed previously deprecated in Python 2.4 classes ``Plist``, ``Dict`` and |
| 672 | ``_InternalDict`` in the :mod:`plistlib` module. Dict values in the result |
| 673 | of functions :func:`~plistlib.readPlist` and |
| 674 | :func:`~plistlib.readPlistFromBytes` are now normal dicts. You no longer |
| 675 | can use attribute access to access items of these dictionaries. |
| 676 | |
Ned Deily | 4829bc6 | 2016-09-12 17:29:04 -0400 | [diff] [blame] | 677 | |
| 678 | Porting to Python 3.7 |
| 679 | ===================== |
| 680 | |
| 681 | This section lists previously described changes and other bugfixes |
| 682 | that may require changes to your code. |
| 683 | |
| 684 | |
Serhiy Storchaka | 9165f77 | 2017-11-15 08:49:40 +0200 | [diff] [blame] | 685 | Changes in Python behavior |
| 686 | -------------------------- |
| 687 | |
| 688 | * Due to an oversight, earlier Python versions erroneously accepted the |
| 689 | following syntax:: |
| 690 | |
| 691 | f(1 for x in [1],) |
| 692 | |
Serhiy Storchaka | ddbce13 | 2017-11-15 17:39:37 +0200 | [diff] [blame] | 693 | class C(1 for x in [1]): |
| 694 | pass |
| 695 | |
Serhiy Storchaka | 9165f77 | 2017-11-15 08:49:40 +0200 | [diff] [blame] | 696 | Python 3.7 now correctly raises a :exc:`SyntaxError`, as a generator |
| 697 | expression always needs to be directly inside a set of parentheses |
Serhiy Storchaka | ddbce13 | 2017-11-15 17:39:37 +0200 | [diff] [blame] | 698 | and cannot have a comma on either side, and the duplication of the |
| 699 | parentheses can be omitted only on calls. |
| 700 | (Contributed by Serhiy Storchaka in :issue:`32012` and :issue:`32023`.) |
Serhiy Storchaka | 9165f77 | 2017-11-15 08:49:40 +0200 | [diff] [blame] | 701 | |
| 702 | |
Serhiy Storchaka | 009b0a1 | 2017-01-13 09:10:51 +0200 | [diff] [blame] | 703 | Changes in the Python API |
| 704 | ------------------------- |
| 705 | |
Victor Stinner | ac577d7 | 2017-11-28 21:33:20 +0100 | [diff] [blame] | 706 | * The ``asyncio.windows_utils.socketpair()`` function has been |
| 707 | removed: use directly :func:`socket.socketpair` which is available on all |
| 708 | platforms since Python 3.5 (before, it wasn't available on Windows). |
| 709 | ``asyncio.windows_utils.socketpair()`` was just an alias to |
| 710 | ``socket.socketpair`` on Python 3.5 and newer. |
| 711 | |
Victor Stinner | 4271dfd | 2017-11-28 15:19:56 +0100 | [diff] [blame] | 712 | * :mod:`asyncio`: The module doesn't export :mod:`selectors` and |
| 713 | :mod:`_overlapped` modules as ``asyncio.selectors`` and |
| 714 | ``asyncio._overlapped``. Replace ``from asyncio import selectors`` with |
| 715 | ``import selectors`` for example. |
| 716 | |
Sanyam Khurana | b9c3da5 | 2017-06-13 22:41:14 +0530 | [diff] [blame] | 717 | * :meth:`pkgutil.walk_packages` now raises ValueError if *path* is a string. |
| 718 | Previously an empty list was returned. (Contributed by Sanyam Khurana in |
| 719 | :issue:`24744`.) |
| 720 | |
Serhiy Storchaka | 009b0a1 | 2017-01-13 09:10:51 +0200 | [diff] [blame] | 721 | * A format string argument for :meth:`string.Formatter.format` |
| 722 | is now :ref:`positional-only <positional-only_parameter>`. |
Garvit Khatri | 1cf93a7 | 2017-03-28 23:43:38 +0800 | [diff] [blame] | 723 | Passing it as a keyword argument was deprecated in Python 3.5. (Contributed |
| 724 | by Serhiy Storchaka in :issue:`29193`.) |
Serhiy Storchaka | cc28337 | 2017-01-13 09:23:15 +0200 | [diff] [blame] | 725 | |
| 726 | * Attributes :attr:`~http.cookies.Morsel.key`, |
| 727 | :attr:`~http.cookies.Morsel.value` and |
| 728 | :attr:`~http.cookies.Morsel.coded_value` of class |
| 729 | :class:`http.cookies.Morsel` are now read-only. |
Serhiy Storchaka | b2d6179 | 2017-01-13 21:14:40 +0200 | [diff] [blame] | 730 | Assigning to them was deprecated in Python 3.5. |
Serhiy Storchaka | cc28337 | 2017-01-13 09:23:15 +0200 | [diff] [blame] | 731 | Use the :meth:`~http.cookies.Morsel.set` method for setting them. |
| 732 | (Contributed by Serhiy Storchaka in :issue:`29192`.) |
INADA Naoki | 015bce6 | 2017-01-16 17:23:30 +0900 | [diff] [blame] | 733 | |
INADA Naoki | cb41b27 | 2017-02-23 00:31:59 +0900 | [diff] [blame] | 734 | * ``Module``, ``FunctionDef``, ``AsyncFunctionDef``, and |
| 735 | ``ClassDef`` AST nodes now have a new ``docstring`` field. |
| 736 | The first statement in their body is not considered as a docstring |
| 737 | anymore. ``co_firstlineno`` and ``co_lnotab`` of code object for class |
Garvit Khatri | 1cf93a7 | 2017-03-28 23:43:38 +0800 | [diff] [blame] | 738 | and module are affected by this change. (Contributed by INADA Naoki and |
| 739 | Eugene Toder in :issue:`29463`.) |
INADA Naoki | 015bce6 | 2017-01-16 17:23:30 +0900 | [diff] [blame] | 740 | |
Serhiy Storchaka | e304e33 | 2017-03-24 13:27:42 +0200 | [diff] [blame] | 741 | * The *mode* argument of :func:`os.makedirs` no longer affects the file |
| 742 | permission bits of newly-created intermediate-level directories. |
| 743 | To set their file permission bits you can set the umask before invoking |
| 744 | ``makedirs()``. |
| 745 | (Contributed by Serhiy Storchaka in :issue:`19930`.) |
| 746 | |
Victor Stinner | f87b85f | 2017-06-23 15:11:12 +0200 | [diff] [blame] | 747 | * The :attr:`struct.Struct.format` type is now :class:`str` instead of |
| 748 | :class:`bytes`. (Contributed by Victor Stinner in :issue:`21071`.) |
| 749 | |
Segev Finer | 9f3bdcb | 2017-06-28 23:51:00 +0300 | [diff] [blame] | 750 | * Due to internal changes in :mod:`socket` you won't be able to |
| 751 | :func:`socket.fromshare` a socket :func:`~socket.socket.share`-ed in older |
| 752 | Python versions. |
| 753 | |
Utkarsh Upadhyay | 8e45318 | 2017-07-28 14:42:56 +0200 | [diff] [blame] | 754 | * ``repr`` for :class:`datetime.timedelta` has changed to include keyword arguments |
| 755 | in the output. (Contributed by Utkarsh Upadhyay in :issue:`30302`.) |
| 756 | |
Serhiy Storchaka | d4d79bc | 2017-11-04 14:16:35 +0200 | [diff] [blame] | 757 | * Because :func:`shutil.rmtree` is now implemented using the :func:`os.scandir` |
| 758 | function, the user specified handler *onerror* is now called with the first |
| 759 | argument ``os.scandir`` instead of ``os.listdir`` when listing the direcory |
| 760 | is failed. |
| 761 | |
Serhiy Storchaka | 05cb728 | 2017-11-16 12:38:26 +0200 | [diff] [blame] | 762 | * Support of nested sets and set operations in regular expressions as in |
| 763 | `Unicode Technical Standard #18`_ might be added in the future. This would |
| 764 | change the syntax, so to facilitate this change a :exc:`FutureWarning` will |
| 765 | be raised in ambiguous cases for the time being. |
| 766 | That include sets starting with a literal ``'['`` or containing literal |
| 767 | character sequences ``'--'``, ``'&&'``, ``'~~'``, and ``'||'``. To |
| 768 | avoid a warning escape them with a backslash. |
| 769 | (Contributed by Serhiy Storchaka in :issue:`30349`.) |
| 770 | |
Jesse-Bakker | 706e10b | 2017-11-30 00:05:07 +0100 | [diff] [blame] | 771 | * :class:`tracemalloc.Traceback` frames are now sorted from oldest to most |
| 772 | recent to be more consistent with :mod:`traceback`. |
| 773 | (Contributed by Jesse Bakker in :issue:`32121`.) |
| 774 | |
Serhiy Storchaka | 05cb728 | 2017-11-16 12:38:26 +0200 | [diff] [blame] | 775 | .. _Unicode Technical Standard #18: https://unicode.org/reports/tr18/ |
| 776 | |
Serhiy Storchaka | e304e33 | 2017-03-24 13:27:42 +0200 | [diff] [blame] | 777 | |
Serhiy Storchaka | 4d3f084 | 2017-10-08 12:53:34 +0300 | [diff] [blame] | 778 | Changes in the C API |
| 779 | -------------------- |
| 780 | |
| 781 | * The function :c:func:`PySlice_GetIndicesEx` is considered not safe for |
| 782 | resizable sequences. If the slice indices are not instances of :class:`int`, |
| 783 | but objects that implement the :meth:`!__index__` method, the sequence can be |
| 784 | resized after passing its length to :c:func:`!PySlice_GetIndicesEx`. This |
| 785 | can lead to returning indices out of the length of the sequence. For |
| 786 | avoiding possible problems use new functions :c:func:`PySlice_Unpack` and |
| 787 | :c:func:`PySlice_AdjustIndices`. |
| 788 | (Contributed by Serhiy Storchaka in :issue:`27867`.) |
| 789 | |
| 790 | |
INADA Naoki | 015bce6 | 2017-01-16 17:23:30 +0900 | [diff] [blame] | 791 | CPython bytecode changes |
| 792 | ------------------------ |
| 793 | |
Martin Panter | 91a8866 | 2017-01-24 00:30:06 +0000 | [diff] [blame] | 794 | * Added two new opcodes: :opcode:`LOAD_METHOD` and :opcode:`CALL_METHOD`. |
INADA Naoki | 015bce6 | 2017-01-16 17:23:30 +0900 | [diff] [blame] | 795 | (Contributed by Yury Selivanov and INADA Naoki in :issue:`26110`.) |
Julien Palard | 809d173 | 2017-10-24 11:22:22 +0200 | [diff] [blame] | 796 | |
| 797 | |
Nick Coghlan | 1b46131 | 2017-11-05 14:58:45 +1000 | [diff] [blame] | 798 | Other CPython implementation changes |
| 799 | ------------------------------------ |
| 800 | |
| 801 | * In preparation for potential future changes to the public CPython runtime |
| 802 | initialization API (see :pep:`432` for details), CPython's internal startup |
| 803 | and configuration management logic has been significantly refactored. While |
| 804 | these updates are intended to be entirely transparent to both embedding |
| 805 | applications and users of the regular CPython CLI, they're being mentioned |
| 806 | here as the refactoring changes the internal order of various operations |
| 807 | during interpreter startup, and hence may uncover previously latent defects, |
| 808 | either in embedding applications, or in CPython itself. |
| 809 | (Contributed by Nick Coghlan and Eric Snow as part of :issue:`22257`.) |
| 810 | |
| 811 | |
Julien Palard | 809d173 | 2017-10-24 11:22:22 +0200 | [diff] [blame] | 812 | Documentation |
| 813 | ============= |
| 814 | |
| 815 | .. _whatsnew37-pep545: |
| 816 | |
| 817 | PEP 545: Python Documentation Translations |
| 818 | ------------------------------------------ |
| 819 | |
| 820 | :pep:`545` describes the process to translate Python documentation, |
| 821 | and two translations have been added: |
| 822 | |
Berker Peksag | 28ab3ce | 2017-11-08 16:36:58 +0300 | [diff] [blame] | 823 | - Japanese: https://docs.python.org/ja/ and associated GitHub |
Julien Palard | 809d173 | 2017-10-24 11:22:22 +0200 | [diff] [blame] | 824 | repository: https://github.com/python/python-docs-ja |
| 825 | |
Berker Peksag | 28ab3ce | 2017-11-08 16:36:58 +0300 | [diff] [blame] | 826 | - French: https://docs.python.org/fr/ and associated GitHub |
Julien Palard | 809d173 | 2017-10-24 11:22:22 +0200 | [diff] [blame] | 827 | repository: https://github.com/python/python-docs-fr |
| 828 | |
| 829 | (Contributed by Julien Palard, Inada Naoki, and Victor Stinner in |
Berker Peksag | 28ab3ce | 2017-11-08 16:36:58 +0300 | [diff] [blame] | 830 | :issue:`26546`.) |