Yury Selivanov | d1da507 | 2015-05-27 22:09:10 -0400 | [diff] [blame] | 1 | **************************** |
| 2 | What's New In Python 3.6 |
| 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.6, compared to 3.5. |
| 49 | |
| 50 | For full details, see the :source:`Misc/NEWS` file. |
| 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.6 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.6. |
| 63 | Brevity is key. |
| 64 | |
Paul Moore | 835416c | 2016-05-22 12:28:41 +0100 | [diff] [blame] | 65 | New syntax features: |
| 66 | |
Martin Panter | bc1ee46 | 2016-02-13 00:41:37 +0000 | [diff] [blame] | 67 | * PEP 498: :ref:`Formatted string literals <whatsnew-fstrings>` |
Yury Selivanov | d1da507 | 2015-05-27 22:09:10 -0400 | [diff] [blame] | 68 | |
Brett Cannon | 68ed978 | 2016-08-26 14:45:15 -0700 | [diff] [blame] | 69 | Standard library improvements: |
| 70 | |
Victor Stinner | e66987e | 2016-09-06 16:33:52 -0700 | [diff] [blame] | 71 | Security improvements: |
| 72 | |
| 73 | * On Linux, :func:`os.urandom` now blocks until the system urandom entropy pool |
| 74 | is initialized to increase the security. See the :pep:`524` for the |
| 75 | rationale. |
| 76 | |
Paul Moore | 835416c | 2016-05-22 12:28:41 +0100 | [diff] [blame] | 77 | Windows improvements: |
| 78 | |
Steve Dower | cc16be8 | 2016-09-08 10:35:16 -0700 | [diff] [blame^] | 79 | * PEP 529: :ref:`Change Windows filesystem encoding to UTF-8 <pep-529>` |
| 80 | |
Paul Moore | 835416c | 2016-05-22 12:28:41 +0100 | [diff] [blame] | 81 | * The ``py.exe`` launcher, when used interactively, no longer prefers |
| 82 | Python 2 over Python 3 when the user doesn't specify a version (via |
| 83 | command line arguments or a config file). Handling of shebang lines |
| 84 | remains unchanged - "python" refers to Python 2 in that case. |
| 85 | |
Steve Dower | 19ab0fd | 2016-09-06 20:40:11 -0700 | [diff] [blame] | 86 | * ``python.exe`` and ``pythonw.exe`` have been marked as long-path aware, |
| 87 | which means that when the 260 character path limit may no longer apply. |
| 88 | See :ref:`removing the MAX_PATH limitation <max-path>` for details. |
| 89 | |
Yury Selivanov | d1da507 | 2015-05-27 22:09:10 -0400 | [diff] [blame] | 90 | .. PEP-sized items next. |
| 91 | |
| 92 | .. _pep-4XX: |
| 93 | |
| 94 | .. PEP 4XX: Virtual Environments |
| 95 | .. ============================= |
| 96 | |
| 97 | |
| 98 | .. (Implemented by Foo Bar.) |
| 99 | |
| 100 | .. .. seealso:: |
| 101 | |
| 102 | :pep:`4XX` - Python Virtual Environments |
| 103 | PEP written by Carl Meyer |
| 104 | |
Eric Snow | 92a6c17 | 2016-09-05 14:50:11 -0700 | [diff] [blame] | 105 | .. XXX PEP 520: :ref:`Preserving Class Attribute Definition Order<whatsnew-deforder>` |
Yury Selivanov | d1da507 | 2015-05-27 22:09:10 -0400 | [diff] [blame] | 106 | |
Victor Stinner | 34be807 | 2016-03-14 12:04:26 +0100 | [diff] [blame] | 107 | New Features |
| 108 | ============ |
| 109 | |
Brett Cannon | 3cebf93 | 2016-09-05 15:33:46 -0700 | [diff] [blame] | 110 | .. _pep-523: |
| 111 | |
| 112 | PEP 523: Adding a frame evaluation API to CPython |
| 113 | ================================================= |
| 114 | |
| 115 | While Python provides extensive support to customize how code |
| 116 | executes, one place it has not done so is in the evaluation of frame |
| 117 | objects. If you wanted some way to intercept frame evaluation in |
| 118 | Python there really wasn't any way without directly manipulating |
| 119 | function pointers for defined functions. |
| 120 | |
| 121 | :pep:`523` changes this by providing an API to make frame |
| 122 | evaluation pluggable at the C level. This will allow for tools such |
| 123 | as debuggers and JITs to intercept frame evaluation before the |
| 124 | execution of Python code begins. This enables the use of alternative |
| 125 | evaluation implementations for Python code, tracking frame |
| 126 | evaluation, etc. |
| 127 | |
| 128 | This API is not part of the limited C API and is marked as private to |
| 129 | signal that usage of this API is expected to be limited and only |
Brett Cannon | 5c4de28 | 2016-09-07 11:16:41 -0700 | [diff] [blame] | 130 | applicable to very select, low-level use-cases. Semantics of the |
| 131 | API will change with Python as necessary. |
Brett Cannon | 3cebf93 | 2016-09-05 15:33:46 -0700 | [diff] [blame] | 132 | |
| 133 | .. seealso:: |
| 134 | |
| 135 | :pep:`523` - Adding a frame evaluation API to CPython |
| 136 | PEP written by Brett Cannon and Dino Viehland. |
| 137 | |
| 138 | |
Brett Cannon | 68ed978 | 2016-08-26 14:45:15 -0700 | [diff] [blame] | 139 | .. _pep-519: |
| 140 | |
| 141 | PEP 519: Adding a file system path protocol |
| 142 | =========================================== |
| 143 | |
| 144 | File system paths have historically been represented as :class:`str` |
| 145 | or :class:`bytes` objects. This has led to people who write code which |
| 146 | operate on file system paths to assume that such objects are only one |
| 147 | of those two types (an :class:`int` representing a file descriptor |
| 148 | does not count as that is not a file path). Unfortunately that |
| 149 | assumption prevents alternative object representations of file system |
| 150 | paths like :mod:`pathlib` from working with pre-existing code, |
| 151 | including Python's standard library. |
| 152 | |
| 153 | To fix this situation, a new interface represented by |
| 154 | :class:`os.PathLike` has been defined. By implementing the |
| 155 | :meth:`~os.PathLike.__fspath__` method, an object signals that it |
| 156 | represents a path. An object can then provide a low-level |
| 157 | representation of a file system path as a :class:`str` or |
| 158 | :class:`bytes` object. This means an object is considered |
| 159 | :term:`path-like <path-like object>` if it implements |
| 160 | :class:`os.PathLike` or is a :class:`str` or :class:`bytes` object |
| 161 | which represents a file system path. Code can use :func:`os.fspath`, |
| 162 | :func:`os.fsdecode`, or :func:`os.fsencode` to explicitly get a |
| 163 | :class:`str` and/or :class:`bytes` representation of a path-like |
| 164 | object. |
| 165 | |
| 166 | The built-in :func:`open` function has been updated to accept |
| 167 | :class:`os.PathLike` objects as have all relevant functions in the |
Brett Cannon | a571120 | 2016-09-06 19:36:01 -0700 | [diff] [blame] | 168 | :mod:`os` and :mod:`os.path` modules. :c:func:`PyUnicode_FSConverter` |
| 169 | and :c:func:`PyUnicode_FSConverter` have been changed to accept |
| 170 | path-like objects. The :class:`os.DirEntry` class |
Brett Cannon | 68ed978 | 2016-08-26 14:45:15 -0700 | [diff] [blame] | 171 | and relevant classes in :mod:`pathlib` have also been updated to |
Brett Cannon | a571120 | 2016-09-06 19:36:01 -0700 | [diff] [blame] | 172 | implement :class:`os.PathLike`. |
| 173 | |
| 174 | The hope in is that updating the fundamental functions for operating |
| 175 | on file system paths will lead to third-party code to implicitly |
| 176 | support all :term:`path-like objects <path-like object>` without any |
| 177 | code changes or at least very minimal ones (e.g. calling |
| 178 | :func:`os.fspath` at the beginning of code before operating on a |
| 179 | path-like object). |
Brett Cannon | 68ed978 | 2016-08-26 14:45:15 -0700 | [diff] [blame] | 180 | |
| 181 | Here are some examples of how the new interface allows for |
| 182 | :class:`pathlib.Path` to be used more easily and transparently with |
| 183 | pre-existing code:: |
| 184 | |
| 185 | >>> import pathlib |
| 186 | >>> with open(pathlib.Path("README")) as f: |
| 187 | ... contents = f.read() |
| 188 | ... |
| 189 | >>> import os.path |
| 190 | >>> os.path.splitext(pathlib.Path("some_file.txt")) |
| 191 | ('some_file', '.txt') |
| 192 | >>> os.path.join("/a/b", pathlib.Path("c")) |
| 193 | '/a/b/c' |
| 194 | >>> import os |
| 195 | >>> os.fspath(pathlib.Path("some_file.txt")) |
| 196 | 'some_file.txt' |
| 197 | |
| 198 | (Implemented by Brett Cannon, Ethan Furman, Dusty Phillips, and Jelle Zijlstra.) |
| 199 | |
| 200 | .. seealso:: |
| 201 | |
| 202 | :pep:`519` - Adding a file system path protocol |
| 203 | PEP written by Brett Cannon and Koos Zevenhoven. |
| 204 | |
| 205 | |
Martin Panter | bc1ee46 | 2016-02-13 00:41:37 +0000 | [diff] [blame] | 206 | .. _whatsnew-fstrings: |
| 207 | |
| 208 | PEP 498: Formatted string literals |
| 209 | ---------------------------------- |
| 210 | |
| 211 | Formatted string literals are a new kind of string literal, prefixed |
| 212 | with ``'f'``. They are similar to the format strings accepted by |
| 213 | :meth:`str.format`. They contain replacement fields surrounded by |
| 214 | curly braces. The replacement fields are expressions, which are |
| 215 | evaluated at run time, and then formatted using the :func:`format` protocol. |
| 216 | |
| 217 | >>> name = "Fred" |
| 218 | >>> f"He said his name is {name}." |
| 219 | 'He said his name is Fred.' |
| 220 | |
| 221 | See :pep:`498` and the main documentation at :ref:`f-strings`. |
| 222 | |
Steve Dower | cc16be8 | 2016-09-08 10:35:16 -0700 | [diff] [blame^] | 223 | .. _pep-529: |
| 224 | |
| 225 | PEP 529: Change Windows filesystem encoding to UTF-8 |
| 226 | ---------------------------------------------------- |
| 227 | |
| 228 | Representing filesystem paths is best performed with str (Unicode) rather than |
| 229 | bytes. However, there are some situations where using bytes is sufficient and |
| 230 | correct. |
| 231 | |
| 232 | Prior to Python 3.6, data loss could result when using bytes paths on Windows. |
| 233 | With this change, using bytes to represent paths is now supported on Windows, |
| 234 | provided those bytes are encoded with the encoding returned by |
| 235 | :func:`sys.getfilesystemencoding()`, which now defaults to ``'utf-8'``. |
| 236 | |
| 237 | Applications that do not use str to represent paths should use |
| 238 | :func:`os.fsencode()` and :func:`os.fsdecode()` to ensure their bytes are |
| 239 | correctly encoded. To revert to the previous behaviour, set |
| 240 | :envvar:`PYTHONLEGACYWINDOWSFSENCODING` or call |
| 241 | :func:`sys._enablelegacywindowsfsencoding`. |
| 242 | |
| 243 | See :pep:`529` for more information and discussion of code modifications that |
| 244 | may be required. |
| 245 | |
| 246 | .. note:: |
| 247 | |
| 248 | This change is considered experimental for 3.6.0 beta releases. The default |
| 249 | encoding may change before the final release. |
Martin Panter | bc1ee46 | 2016-02-13 00:41:37 +0000 | [diff] [blame] | 250 | |
Nick Coghlan | d78448e | 2016-07-30 16:26:03 +1000 | [diff] [blame] | 251 | PEP 487: Simpler customization of class creation |
| 252 | ------------------------------------------------ |
| 253 | |
| 254 | Upon subclassing a class, the ``__init_subclass__`` classmethod (if defined) is |
| 255 | called on the base class. This makes it straightforward to write classes that |
| 256 | customize initialization of future subclasses without introducing the |
| 257 | complexity of a full custom metaclass. |
| 258 | |
| 259 | The descriptor protocol has also been expanded to include a new optional method, |
| 260 | ``__set_name__``. Whenever a new class is defined, the new method will be called |
| 261 | on all descriptors included in the definition, providing them with a reference |
| 262 | to the class being defined and the name given to the descriptor within the |
| 263 | class namespace. |
| 264 | |
| 265 | Also see :pep:`487` and the updated class customization documentation at |
| 266 | :ref:`class-customization` and :ref:`descriptors`. |
| 267 | |
| 268 | (Contributed by Martin Teichmann in :issue:`27366`) |
| 269 | |
| 270 | |
Victor Stinner | 34be807 | 2016-03-14 12:04:26 +0100 | [diff] [blame] | 271 | PYTHONMALLOC environment variable |
| 272 | --------------------------------- |
| 273 | |
Martin Panter | df1d31c | 2016-06-20 08:00:45 +0000 | [diff] [blame] | 274 | The new :envvar:`PYTHONMALLOC` environment variable allows setting the Python |
Victor Stinner | 34be807 | 2016-03-14 12:04:26 +0100 | [diff] [blame] | 275 | memory allocators and/or install debug hooks. |
| 276 | |
| 277 | It is now possible to install debug hooks on Python memory allocators on Python |
| 278 | compiled in release mode using ``PYTHONMALLOC=debug``. Effects of debug hooks: |
| 279 | |
| 280 | * Newly allocated memory is filled with the byte ``0xCB`` |
| 281 | * Freed memory is filled with the byte ``0xDB`` |
| 282 | * Detect violations of Python memory allocator API. For example, |
| 283 | :c:func:`PyObject_Free` called on a memory block allocated by |
| 284 | :c:func:`PyMem_Malloc`. |
| 285 | * Detect write before the start of the buffer (buffer underflow) |
| 286 | * Detect write after the end of the buffer (buffer overflow) |
Victor Stinner | c4aec36 | 2016-03-14 22:26:53 +0100 | [diff] [blame] | 287 | * Check that the :term:`GIL <global interpreter lock>` is held when allocator |
Victor Stinner | c2fc568 | 2016-03-18 11:04:31 +0100 | [diff] [blame] | 288 | functions of :c:data:`PYMEM_DOMAIN_OBJ` (ex: :c:func:`PyObject_Malloc`) and |
| 289 | :c:data:`PYMEM_DOMAIN_MEM` (ex: :c:func:`PyMem_Malloc`) domains are called. |
| 290 | |
Victor Stinner | 9b46a57 | 2016-03-18 15:10:43 +0100 | [diff] [blame] | 291 | Checking if the GIL is held is also a new feature of Python 3.6. |
Victor Stinner | 34be807 | 2016-03-14 12:04:26 +0100 | [diff] [blame] | 292 | |
| 293 | See the :c:func:`PyMem_SetupDebugHooks` function for debug hooks on Python |
| 294 | memory allocators. |
| 295 | |
| 296 | It is now also possible to force the usage of the :c:func:`malloc` allocator of |
| 297 | the C library for all Python memory allocations using ``PYTHONMALLOC=malloc``. |
| 298 | It helps to use external memory debuggers like Valgrind on a Python compiled in |
| 299 | release mode. |
| 300 | |
Victor Stinner | 0611c26 | 2016-03-15 22:22:13 +0100 | [diff] [blame] | 301 | On error, the debug hooks on Python memory allocators now use the |
| 302 | :mod:`tracemalloc` module to get the traceback where a memory block was |
| 303 | allocated. |
| 304 | |
| 305 | Example of fatal error on buffer overflow using |
| 306 | ``python3.6 -X tracemalloc=5`` (store 5 frames in traces):: |
| 307 | |
| 308 | Debug memory block at address p=0x7fbcd41666f8: API 'o' |
| 309 | 4 bytes originally requested |
| 310 | The 7 pad bytes at p-7 are FORBIDDENBYTE, as expected. |
| 311 | The 8 pad bytes at tail=0x7fbcd41666fc are not all FORBIDDENBYTE (0xfb): |
| 312 | at tail+0: 0x02 *** OUCH |
| 313 | at tail+1: 0xfb |
| 314 | at tail+2: 0xfb |
| 315 | at tail+3: 0xfb |
| 316 | at tail+4: 0xfb |
| 317 | at tail+5: 0xfb |
| 318 | at tail+6: 0xfb |
| 319 | at tail+7: 0xfb |
| 320 | The block was made by call #1233329 to debug malloc/realloc. |
| 321 | Data at p: 1a 2b 30 00 |
| 322 | |
| 323 | Memory block allocated at (most recent call first): |
| 324 | File "test/test_bytes.py", line 323 |
| 325 | File "unittest/case.py", line 600 |
| 326 | File "unittest/case.py", line 648 |
| 327 | File "unittest/suite.py", line 122 |
| 328 | File "unittest/suite.py", line 84 |
| 329 | |
| 330 | Fatal Python error: bad trailing pad byte |
| 331 | |
| 332 | Current thread 0x00007fbcdbd32700 (most recent call first): |
| 333 | File "test/test_bytes.py", line 323 in test_hex |
| 334 | File "unittest/case.py", line 600 in run |
| 335 | File "unittest/case.py", line 648 in __call__ |
| 336 | File "unittest/suite.py", line 122 in run |
| 337 | File "unittest/suite.py", line 84 in __call__ |
| 338 | File "unittest/suite.py", line 122 in run |
| 339 | File "unittest/suite.py", line 84 in __call__ |
| 340 | ... |
| 341 | |
| 342 | (Contributed by Victor Stinner in :issue:`26516` and :issue:`26564`.) |
Victor Stinner | 34be807 | 2016-03-14 12:04:26 +0100 | [diff] [blame] | 343 | |
| 344 | |
Eric Snow | 92a6c17 | 2016-09-05 14:50:11 -0700 | [diff] [blame] | 345 | .. _whatsnew-deforder: |
| 346 | |
| 347 | PEP 520: Preserving Class Attribute Definition Order |
| 348 | ---------------------------------------------------- |
| 349 | |
| 350 | Attributes in a class definition body have a natural ordering: the same |
| 351 | order in which the names appear in the source. This order is now |
| 352 | preserved in the new class's ``__definition_order__`` attribute. It is |
| 353 | a tuple of the attribute names, in the order in which they appear in |
| 354 | the class definition body. |
| 355 | |
| 356 | For types that don't have a definition (e.g. builtins), or the attribute |
| 357 | order could not be determined, ``__definition_order__`` is ``None``. |
| 358 | |
| 359 | Also, the effective default class *execution* namespace (returned from |
| 360 | ``type.__prepare__()``) is now an insertion-order-preserving mapping. |
| 361 | For CPython, it is now ``collections.OrderedDict``. Note that the |
| 362 | class namespace, ``cls.__dict__``, is unchanged. |
| 363 | |
| 364 | .. seealso:: |
| 365 | |
| 366 | :pep:`520` - Preserving Class Attribute Definition Order |
| 367 | PEP written and implemented by Eric Snow. |
| 368 | |
| 369 | |
Yury Selivanov | d1da507 | 2015-05-27 22:09:10 -0400 | [diff] [blame] | 370 | Other Language Changes |
| 371 | ====================== |
| 372 | |
Nick Coghlan | 02d03df | 2016-08-16 10:58:14 +1000 | [diff] [blame] | 373 | Some smaller changes made to the core Python language are: |
| 374 | |
Benjamin Peterson | e5e3edb | 2016-09-08 10:13:42 -0700 | [diff] [blame] | 375 | * :func:`dict` now uses a "compact" representation `pioneered by PyPy |
| 376 | <https://morepypy.blogspot.com/2015/01/faster-more-memory-efficient-and-more.html>`_. |
| 377 | :pep:`PEP 468` (Preserving the order of ``**kwargs`` in a function.) is |
| 378 | implemented by this. (Contributed by INADA Naoki in :issue:`27350`.) |
Victor Stinner | 742da04 | 2016-09-07 17:40:12 -0700 | [diff] [blame] | 379 | |
Nick Coghlan | 02d03df | 2016-08-16 10:58:14 +1000 | [diff] [blame] | 380 | * Long sequences of repeated traceback lines are now abbreviated as |
| 381 | ``"[Previous line repeated {count} more times]"`` (see |
| 382 | :ref:`py36-traceback` for an example). |
| 383 | (Contributed by Emanuel Barry in :issue:`26823`.) |
Yury Selivanov | d1da507 | 2015-05-27 22:09:10 -0400 | [diff] [blame] | 384 | |
Eric Snow | 46f97b8 | 2016-09-07 16:56:15 -0700 | [diff] [blame] | 385 | * Import now raises the new exception :exc:`ModuleNotFoundError` |
| 386 | (subclass of :exc:`ImportError`) when it cannot find a module. Code |
| 387 | that current checks for ImportError (in try-except) will still work. |
| 388 | |
Yury Selivanov | d1da507 | 2015-05-27 22:09:10 -0400 | [diff] [blame] | 389 | |
| 390 | New Modules |
| 391 | =========== |
| 392 | |
| 393 | * None yet. |
| 394 | |
| 395 | |
| 396 | Improved Modules |
| 397 | ================ |
| 398 | |
Victor Stinner | e66987e | 2016-09-06 16:33:52 -0700 | [diff] [blame] | 399 | On Linux, :func:`os.urandom` now blocks until the system urandom entropy pool |
| 400 | is initialized to increase the security. See the :pep:`524` for the rationale. |
| 401 | |
Yury Selivanov | b4a0d52 | 2016-05-16 16:25:16 -0400 | [diff] [blame] | 402 | |
| 403 | asyncio |
| 404 | ------- |
| 405 | |
| 406 | Since the :mod:`asyncio` module is :term:`provisional <provisional api>`, |
| 407 | all changes introduced in Python 3.6 have also been backported to Python |
| 408 | 3.5.x. |
| 409 | |
| 410 | Notable changes in the :mod:`asyncio` module since Python 3.5.0: |
| 411 | |
| 412 | * The :func:`~asyncio.ensure_future` function and all functions that |
| 413 | use it, such as :meth:`loop.run_until_complete() <asyncio.BaseEventLoop.run_until_complete>`, |
| 414 | now accept all kinds of :term:`awaitable objects <awaitable>`. |
| 415 | (Contributed by Yury Selivanov.) |
| 416 | |
| 417 | * New :func:`~asyncio.run_coroutine_threadsafe` function to submit |
| 418 | coroutines to event loops from other threads. |
| 419 | (Contributed by Vincent Michel.) |
| 420 | |
| 421 | * New :meth:`Transport.is_closing() <asyncio.BaseTransport.is_closing>` |
| 422 | method to check if the transport is closing or closed. |
| 423 | (Contributed by Yury Selivanov.) |
| 424 | |
| 425 | * The :meth:`loop.create_server() <asyncio.BaseEventLoop.create_server>` |
| 426 | method can now accept a list of hosts. |
| 427 | (Contributed by Yann Sionneau.) |
| 428 | |
| 429 | * New :meth:`loop.create_future() <asyncio.BaseEventLoop.create_future>` |
| 430 | method to create Future objects. This allows alternative event |
| 431 | loop implementations, such as |
| 432 | `uvloop <https://github.com/MagicStack/uvloop>`_, to provide a faster |
| 433 | :class:`asyncio.Future` implementation. |
| 434 | (Contributed by Yury Selivanov.) |
| 435 | |
| 436 | * New :meth:`loop.get_exception_handler() <asyncio.BaseEventLoop.get_exception_handler>` |
| 437 | method to get the current exception handler. |
| 438 | (Contributed by Yury Selivanov.) |
| 439 | |
| 440 | * New :func:`~asyncio.timeout` context manager to simplify timeouts |
| 441 | handling code. |
| 442 | (Contributed by Andrew Svetlov.) |
| 443 | |
| 444 | * New :meth:`StreamReader.readuntil() <asyncio.StreamReader.readuntil>` |
| 445 | method to read data from the stream until a separator bytes |
| 446 | sequence appears. |
| 447 | (Contributed by Mark Korenberg.) |
| 448 | |
| 449 | * The :meth:`loop.getaddrinfo() <asyncio.BaseEventLoop.getaddrinfo>` |
| 450 | method is optimized to avoid calling the system ``getaddrinfo`` |
| 451 | function if the address is already resolved. |
| 452 | (Contributed by A. Jesse Jiryu Davis.) |
| 453 | |
| 454 | |
Brett Cannon | 9e080e0 | 2016-04-08 12:15:27 -0700 | [diff] [blame] | 455 | contextlib |
| 456 | ---------- |
| 457 | |
| 458 | The :class:`contextlib.AbstractContextManager` class has been added to |
| 459 | provide an abstract base class for context managers. It provides a |
| 460 | sensible default implementation for `__enter__()` which returns |
Martin Panter | 3872d62 | 2016-04-10 02:41:25 +0000 | [diff] [blame] | 461 | ``self`` and leaves `__exit__()` an abstract method. A matching |
Brett Cannon | 9e080e0 | 2016-04-08 12:15:27 -0700 | [diff] [blame] | 462 | class has been added to the :mod:`typing` module as |
| 463 | :class:`typing.ContextManager`. |
| 464 | (Contributed by Brett Cannon in :issue:`25609`.) |
| 465 | |
| 466 | |
Vinay Sajip | fd0f84b | 2016-08-06 10:43:44 +0100 | [diff] [blame] | 467 | venv |
| 468 | ---- |
| 469 | |
| 470 | :mod:`venv` accepts a new parameter ``--prompt``. This parameter provides an |
| 471 | alternative prefix for the virtual environment. (Proposed by Łukasz.Balcerzak |
| 472 | and ported to 3.6 by Stéphane Wirtel in :issue:`22829`.) |
| 473 | |
| 474 | |
Berker Peksag | b6c9572 | 2015-10-08 13:58:49 +0300 | [diff] [blame] | 475 | datetime |
| 476 | -------- |
| 477 | |
Martin Panter | fad4b60 | 2015-11-14 01:29:17 +0000 | [diff] [blame] | 478 | The :meth:`datetime.strftime() <datetime.datetime.strftime>` and |
| 479 | :meth:`date.strftime() <datetime.date.strftime>` methods now support ISO 8601 date |
Berker Peksag | b6c9572 | 2015-10-08 13:58:49 +0300 | [diff] [blame] | 480 | directives ``%G``, ``%u`` and ``%V``. |
| 481 | (Contributed by Ashley Anderson in :issue:`12006`.) |
| 482 | |
| 483 | |
Jason R. Coombs | c758d51 | 2016-08-21 16:09:27 -0400 | [diff] [blame] | 484 | distutils.command.sdist |
| 485 | ----------------------- |
| 486 | |
| 487 | The ``default_format`` attribute has been removed from |
| 488 | :class:`distutils.command.sdist.sdist` and the ``formats`` |
| 489 | attribute defaults to ``['gztar']``. Although not anticipated, |
| 490 | Any code relying on the presence of ``default_format`` may |
| 491 | need to be adapted. See :issue:`27819` for more details. |
| 492 | |
| 493 | |
R David Murray | 56b1f1b | 2016-09-07 16:48:35 -0400 | [diff] [blame] | 494 | email |
| 495 | ----- |
| 496 | |
R David Murray | 8e7cdb2 | 2016-09-07 21:21:58 -0400 | [diff] [blame] | 497 | The new email API, enabled via the *policy* keyword to various constructors, is |
| 498 | no longer provisional. The :mod:`email` documentation has been reorganized and |
| 499 | rewritten to focus on the new API, while retaining the old documentation for |
| 500 | the legacy API. (Contributed by R. David Murray in :issue:`24277`.) |
| 501 | |
R David Murray | 56b1f1b | 2016-09-07 16:48:35 -0400 | [diff] [blame] | 502 | The :mod:`email.mime` classes now all accept an optional *policy* keyword. |
| 503 | (Contributed by Berker Peksag in :issue:`27331`.) |
| 504 | |
| 505 | |
Steve Dower | 6cebd48 | 2016-09-06 19:55:55 -0700 | [diff] [blame] | 506 | encodings |
| 507 | --------- |
| 508 | |
| 509 | On Windows, added the ``'oem'`` encoding to use ``CP_OEMCP`` and the ``'ansi'`` |
| 510 | alias for the existing ``'mbcs'`` encoding, which uses the ``CP_ACP`` code page. |
| 511 | |
Victor Stinner | 404cdc5 | 2016-03-23 10:39:17 +0100 | [diff] [blame] | 512 | faulthandler |
| 513 | ------------ |
| 514 | |
Serhiy Storchaka | b6a9c97 | 2016-04-17 09:39:28 +0300 | [diff] [blame] | 515 | On Windows, the :mod:`faulthandler` module now installs a handler for Windows |
Victor Stinner | 404cdc5 | 2016-03-23 10:39:17 +0100 | [diff] [blame] | 516 | exceptions: see :func:`faulthandler.enable`. (Contributed by Victor Stinner in |
| 517 | :issue:`23848`.) |
| 518 | |
| 519 | |
Martin Panter | 3c0d0ba | 2016-08-24 06:33:33 +0000 | [diff] [blame] | 520 | http.client |
| 521 | ----------- |
| 522 | |
| 523 | :meth:`HTTPConnection.request() <http.client.HTTPConnection.request>` and |
| 524 | :meth:`~http.client.HTTPConnection.endheaders` both now support |
| 525 | chunked encoding request bodies. |
| 526 | (Contributed by Demian Brecht and Rolf Krahl in :issue:`12319`.) |
| 527 | |
| 528 | |
Terry Jan Reedy | d9792a0 | 2016-06-13 00:41:53 -0400 | [diff] [blame] | 529 | idlelib and IDLE |
| 530 | ---------------- |
| 531 | |
| 532 | The idlelib package is being modernized and refactored to make IDLE look and work better and to make the code easier to understand, test, and improve. Part of making IDLE look better, especially on Linux and Mac, is using ttk widgets, mostly in the dialogs. As a result, IDLE no longer runs with tcl/tk 8.4. It now requires tcl/tk 8.5 or 8.6. We recommend running the latest release of either. |
| 533 | |
| 534 | 'Modernizing' includes renaming and consolidation of idlelib modules. The renaming of files with partial uppercase names is similar to the renaming of, for instance, Tkinter and TkFont to tkinter and tkinter.font in 3.0. As a result, imports of idlelib files that worked in 3.5 will usually not work in 3.6. At least a module name change will be needed (see idlelib/README.txt), sometimes more. (Name changes contributed by Al Swiegart and Terry Reedy in :issue:`24225`. Most idlelib patches since have been and will be part of the process.) |
| 535 | |
Terry Jan Reedy | dffd42f | 2016-06-13 00:42:42 -0400 | [diff] [blame] | 536 | In compensation, the eventual result with be that some idlelib classes will be easier to use, with better APIs and docstrings explaining them. Additional useful information will be added to idlelib when available. |
Terry Jan Reedy | d9792a0 | 2016-06-13 00:41:53 -0400 | [diff] [blame] | 537 | |
| 538 | |
Brett Cannon | 696c35e | 2016-06-25 10:58:17 -0700 | [diff] [blame] | 539 | importlib |
| 540 | --------- |
| 541 | |
| 542 | :class:`importlib.util.LazyLoader` now calls |
| 543 | :meth:`~importlib.abc.Loader.create_module` on the wrapped loader, removing the |
| 544 | restriction that :class:`importlib.machinery.BuiltinImporter` and |
| 545 | :class:`importlib.machinery.ExtensionFileLoader` couldn't be used with |
| 546 | :class:`importlib.util.LazyLoader`. |
| 547 | |
Brett Cannon | 035a100 | 2016-09-07 18:39:18 -0700 | [diff] [blame] | 548 | :func:`importlib.util.cache_from_source`, |
| 549 | :func:`importlib.util.source_from_cache`, and |
| 550 | :func:`importlib.util.spec_from_file_location` now accept a |
| 551 | :term:`path-like object`. |
| 552 | |
Brett Cannon | 696c35e | 2016-06-25 10:58:17 -0700 | [diff] [blame] | 553 | |
Serhiy Storchaka | ffe96ae | 2016-02-11 13:21:30 +0200 | [diff] [blame] | 554 | os |
| 555 | -- |
| 556 | |
| 557 | A new :meth:`~os.scandir.close` method allows explicitly closing a |
| 558 | :func:`~os.scandir` iterator. The :func:`~os.scandir` iterator now |
| 559 | supports the :term:`context manager` protocol. If a :func:`scandir` |
| 560 | iterator is neither exhausted nor explicitly closed a :exc:`ResourceWarning` |
| 561 | will be emitted in its destructor. |
| 562 | (Contributed by Serhiy Storchaka in :issue:`25994`.) |
| 563 | |
Victor Stinner | 9b1f474 | 2016-09-06 16:18:52 -0700 | [diff] [blame] | 564 | The Linux ``getrandom()`` syscall (get random bytes) is now exposed as the new |
| 565 | :func:`os.getrandom` function. |
| 566 | (Contributed by Victor Stinner, part of the :pep:`524`) |
| 567 | |
Brett Cannon | 035a100 | 2016-09-07 18:39:18 -0700 | [diff] [blame] | 568 | See the summary for :ref:`PEP 519 <pep-519>` for details on how the |
| 569 | :mod:`os` and :mod:`os.path` modules now support |
| 570 | :term:`path-like objects <path-like object>`. |
| 571 | |
| 572 | |
Serhiy Storchaka | 0d554d7 | 2015-10-10 22:42:18 +0300 | [diff] [blame] | 573 | pickle |
| 574 | ------ |
| 575 | |
Martin Panter | fad4b60 | 2015-11-14 01:29:17 +0000 | [diff] [blame] | 576 | Objects that need calling ``__new__`` with keyword arguments can now be pickled |
Serhiy Storchaka | 0d554d7 | 2015-10-10 22:42:18 +0300 | [diff] [blame] | 577 | using :ref:`pickle protocols <pickle-protocols>` older than protocol version 4. |
| 578 | Protocol version 4 already supports this case. (Contributed by Serhiy |
| 579 | Storchaka in :issue:`24164`.) |
| 580 | |
| 581 | |
Martin Panter | f0dbf7a | 2016-05-15 01:26:25 +0000 | [diff] [blame] | 582 | readline |
| 583 | -------- |
| 584 | |
| 585 | Added :func:`~readline.set_auto_history` to enable or disable |
| 586 | automatic addition of input to the history list. (Contributed by |
| 587 | Tyler Crompton in :issue:`26870`.) |
| 588 | |
| 589 | |
Martin Panter | fad4b60 | 2015-11-14 01:29:17 +0000 | [diff] [blame] | 590 | rlcompleter |
| 591 | ----------- |
Serhiy Storchaka | ab82422 | 2015-09-27 13:43:50 +0300 | [diff] [blame] | 592 | |
| 593 | Private and special attribute names now are omitted unless the prefix starts |
Martin Panter | fad4b60 | 2015-11-14 01:29:17 +0000 | [diff] [blame] | 594 | with underscores. A space or a colon is added after some completed keywords. |
Serhiy Storchaka | ab82422 | 2015-09-27 13:43:50 +0300 | [diff] [blame] | 595 | (Contributed by Serhiy Storchaka in :issue:`25011` and :issue:`25209`.) |
| 596 | |
Martin Panter | 6fe3926 | 2015-11-13 23:54:02 +0000 | [diff] [blame] | 597 | Names of most attributes listed by :func:`dir` are now completed. |
| 598 | Previously, names of properties and slots which were not yet created on |
| 599 | an instance were excluded. (Contributed by Martin Panter in :issue:`25590`.) |
| 600 | |
Serhiy Storchaka | ab82422 | 2015-09-27 13:43:50 +0300 | [diff] [blame] | 601 | |
Brett Cannon | 5f0507d | 2016-04-08 15:04:28 -0700 | [diff] [blame] | 602 | site |
| 603 | ---- |
| 604 | |
| 605 | When specifying paths to add to :attr:`sys.path` in a `.pth` file, |
| 606 | you may now specify file paths on top of directories (e.g. zip files). |
| 607 | (Contributed by Wolfgang Langner in :issue:`26587`). |
| 608 | |
| 609 | |
Berker Peksag | e0b70cd | 2016-06-14 15:25:36 +0300 | [diff] [blame] | 610 | sqlite3 |
| 611 | ------- |
| 612 | |
Berker Peksag | b84fd04 | 2016-09-07 01:07:06 +0300 | [diff] [blame] | 613 | :attr:`sqlite3.Cursor.lastrowid` now supports the ``REPLACE`` statement. |
| 614 | (Contributed by Alex LordThorsen in :issue:`16864`.) |
Berker Peksag | e0b70cd | 2016-06-14 15:25:36 +0300 | [diff] [blame] | 615 | |
| 616 | |
Steve Dower | ea93ac0 | 2016-06-17 12:52:18 -0700 | [diff] [blame] | 617 | socket |
| 618 | ------ |
| 619 | |
| 620 | The :func:`~socket.socket.ioctl` function now supports the :data:`~socket.SIO_LOOPBACK_FAST_PATH` |
| 621 | control code. |
| 622 | (Contributed by Daniel Stokes in :issue:`26536`.) |
| 623 | |
R David Murray | bdfa0eb | 2016-08-23 21:12:40 -0400 | [diff] [blame] | 624 | The :meth:`~socket.socket.getsockopt` constants ``SO_DOMAIN``, |
| 625 | ``SO_PROTOCOL``, ``SO_PEERSEC``, and ``SO_PASSSEC`` are now supported. |
| 626 | (Contributed by Christian Heimes in :issue:`26907`.) |
| 627 | |
Steve Dower | ea93ac0 | 2016-06-17 12:52:18 -0700 | [diff] [blame] | 628 | |
Martin Panter | 0cab9c1 | 2016-04-13 00:36:52 +0000 | [diff] [blame] | 629 | socketserver |
| 630 | ------------ |
| 631 | |
| 632 | Servers based on the :mod:`socketserver` module, including those |
| 633 | defined in :mod:`http.server`, :mod:`xmlrpc.server` and |
| 634 | :mod:`wsgiref.simple_server`, now support the :term:`context manager` |
| 635 | protocol. |
| 636 | (Contributed by Aviv Palivoda in :issue:`26404`.) |
| 637 | |
Martin Panter | 34eeed4 | 2016-06-29 10:12:22 +0000 | [diff] [blame] | 638 | The :attr:`~socketserver.StreamRequestHandler.wfile` attribute of |
| 639 | :class:`~socketserver.StreamRequestHandler` classes now implements |
| 640 | the :class:`io.BufferedIOBase` writable interface. In particular, |
| 641 | calling :meth:`~io.BufferedIOBase.write` is now guaranteed to send the |
| 642 | data in full. (Contributed by Martin Panter in :issue:`26721`.) |
| 643 | |
Martin Panter | 0cab9c1 | 2016-04-13 00:36:52 +0000 | [diff] [blame] | 644 | |
Victor Stinner | 5a48e21 | 2016-05-20 12:11:15 +0200 | [diff] [blame] | 645 | subprocess |
| 646 | ---------- |
| 647 | |
| 648 | :class:`subprocess.Popen` destructor now emits a :exc:`ResourceWarning` warning |
| 649 | if the child process is still running. Use the context manager protocol (``with |
| 650 | proc: ...``) or call explicitly the :meth:`~subprocess.Popen.wait` method to |
| 651 | read the exit status of the child process (Contributed by Victor Stinner in |
| 652 | :issue:`26741`). |
| 653 | |
Steve Dower | 050acae | 2016-09-06 20:16:17 -0700 | [diff] [blame] | 654 | The :class:`subprocess.Popen` constructor and all functions that pass arguments |
| 655 | through to it now accept *encoding* and *errors* arguments. Specifying either |
| 656 | of these will enable text mode for the *stdin*, *stdout* and *stderr* streams. |
Victor Stinner | 5a48e21 | 2016-05-20 12:11:15 +0200 | [diff] [blame] | 657 | |
R David Murray | 4f09806 | 2015-11-28 12:24:52 -0500 | [diff] [blame] | 658 | telnetlib |
| 659 | --------- |
| 660 | |
| 661 | :class:`~telnetlib.Telnet` is now a context manager (contributed by |
| 662 | Stéphane Wirtel in :issue:`25485`). |
| 663 | |
| 664 | |
Serhiy Storchaka | 8122174 | 2016-06-26 09:46:57 +0300 | [diff] [blame] | 665 | tkinter |
| 666 | ------- |
| 667 | |
| 668 | Added methods :meth:`~tkinter.Variable.trace_add`, |
| 669 | :meth:`~tkinter.Variable.trace_remove` and :meth:`~tkinter.Variable.trace_info` |
| 670 | in the :class:`tkinter.Variable` class. They replace old methods |
| 671 | :meth:`~tkinter.Variable.trace_variable`, :meth:`~tkinter.Variable.trace`, |
| 672 | :meth:`~tkinter.Variable.trace_vdelete` and |
| 673 | :meth:`~tkinter.Variable.trace_vinfo` that use obsolete Tcl commands and might |
| 674 | not work in future versions of Tcl. |
| 675 | (Contributed by Serhiy Storchaka in :issue:`22115`). |
| 676 | |
| 677 | |
Nick Coghlan | 02d03df | 2016-08-16 10:58:14 +1000 | [diff] [blame] | 678 | .. _py36-traceback: |
| 679 | |
Nick Coghlan | d003423 | 2016-08-15 13:11:34 +1000 | [diff] [blame] | 680 | traceback |
| 681 | --------- |
| 682 | |
Nick Coghlan | 02d03df | 2016-08-16 10:58:14 +1000 | [diff] [blame] | 683 | Both the traceback module and the interpreter's builtin exception display now |
| 684 | abbreviate long sequences of repeated lines in tracebacks as shown in the |
| 685 | following example:: |
| 686 | |
| 687 | >>> def f(): f() |
| 688 | ... |
| 689 | >>> f() |
| 690 | Traceback (most recent call last): |
| 691 | File "<stdin>", line 1, in <module> |
| 692 | File "<stdin>", line 1, in f |
| 693 | File "<stdin>", line 1, in f |
| 694 | File "<stdin>", line 1, in f |
| 695 | [Previous line repeated 995 more times] |
| 696 | RecursionError: maximum recursion depth exceeded |
| 697 | |
Nick Coghlan | d003423 | 2016-08-15 13:11:34 +1000 | [diff] [blame] | 698 | (Contributed by Emanuel Barry in :issue:`26823`.) |
| 699 | |
| 700 | |
Brett Cannon | 9e080e0 | 2016-04-08 12:15:27 -0700 | [diff] [blame] | 701 | typing |
| 702 | ------ |
| 703 | |
| 704 | The :class:`typing.ContextManager` class has been added for |
| 705 | representing :class:`contextlib.AbstractContextManager`. |
| 706 | (Contributed by Brett Cannon in :issue:`25609`.) |
| 707 | |
| 708 | |
Victor Stinner | 2c2a4e6 | 2016-03-11 22:17:48 +0100 | [diff] [blame] | 709 | unittest.mock |
| 710 | ------------- |
| 711 | |
| 712 | The :class:`~unittest.mock.Mock` class has the following improvements: |
| 713 | |
| 714 | * Two new methods, :meth:`Mock.assert_called() |
| 715 | <unittest.mock.Mock.assert_called>` and :meth:`Mock.assert_called_once() |
| 716 | <unittest.mock.Mock.assert_called_once>` to check if the mock object |
| 717 | was called. |
| 718 | (Contributed by Amit Saha in :issue:`26323`.) |
| 719 | |
| 720 | |
Martin Panter | 3c0d0ba | 2016-08-24 06:33:33 +0000 | [diff] [blame] | 721 | urllib.request |
| 722 | -------------- |
| 723 | |
Martin Panter | ef91bb2 | 2016-08-27 01:39:26 +0000 | [diff] [blame] | 724 | If a HTTP request has a file or iterable body (other than a |
| 725 | bytes object) but no Content-Length header, rather than |
Martin Panter | 3c0d0ba | 2016-08-24 06:33:33 +0000 | [diff] [blame] | 726 | throwing an error, :class:`~urllib.request.AbstractHTTPHandler` now |
| 727 | falls back to use chunked transfer encoding. |
| 728 | (Contributed by Demian Brecht and Rolf Krahl in :issue:`12319`.) |
| 729 | |
| 730 | |
Berker Peksag | 960e848 | 2015-10-08 12:27:06 +0300 | [diff] [blame] | 731 | urllib.robotparser |
| 732 | ------------------ |
| 733 | |
Martin Panter | fad4b60 | 2015-11-14 01:29:17 +0000 | [diff] [blame] | 734 | :class:`~urllib.robotparser.RobotFileParser` now supports the ``Crawl-delay`` and |
Berker Peksag | 960e848 | 2015-10-08 12:27:06 +0300 | [diff] [blame] | 735 | ``Request-rate`` extensions. |
| 736 | (Contributed by Nikolay Bogoychev in :issue:`16099`.) |
| 737 | |
| 738 | |
Victor Stinner | 914cde8 | 2016-03-19 01:03:51 +0100 | [diff] [blame] | 739 | warnings |
| 740 | -------- |
| 741 | |
| 742 | A new optional *source* parameter has been added to the |
| 743 | :func:`warnings.warn_explicit` function: the destroyed object which emitted a |
| 744 | :exc:`ResourceWarning`. A *source* attribute has also been added to |
| 745 | :class:`warnings.WarningMessage` (contributed by Victor Stinner in |
| 746 | :issue:`26568` and :issue:`26567`). |
| 747 | |
| 748 | When a :exc:`ResourceWarning` warning is logged, the :mod:`tracemalloc` is now |
| 749 | used to try to retrieve the traceback where the detroyed object was allocated. |
| 750 | |
| 751 | Example with the script ``example.py``:: |
| 752 | |
Victor Stinner | ee803a8 | 2016-03-19 10:33:25 +0100 | [diff] [blame] | 753 | import warnings |
Victor Stinner | 914cde8 | 2016-03-19 01:03:51 +0100 | [diff] [blame] | 754 | |
Victor Stinner | ee803a8 | 2016-03-19 10:33:25 +0100 | [diff] [blame] | 755 | def func(): |
| 756 | return open(__file__) |
| 757 | |
| 758 | f = func() |
| 759 | f = None |
Victor Stinner | 914cde8 | 2016-03-19 01:03:51 +0100 | [diff] [blame] | 760 | |
| 761 | Output of the command ``python3.6 -Wd -X tracemalloc=5 example.py``:: |
| 762 | |
Victor Stinner | ee803a8 | 2016-03-19 10:33:25 +0100 | [diff] [blame] | 763 | example.py:7: ResourceWarning: unclosed file <_io.TextIOWrapper name='example.py' mode='r' encoding='UTF-8'> |
Victor Stinner | 914cde8 | 2016-03-19 01:03:51 +0100 | [diff] [blame] | 764 | f = None |
| 765 | Object allocated at (most recent call first): |
Victor Stinner | ee803a8 | 2016-03-19 10:33:25 +0100 | [diff] [blame] | 766 | File "example.py", lineno 4 |
| 767 | return open(__file__) |
| 768 | File "example.py", lineno 6 |
| 769 | f = func() |
Victor Stinner | 914cde8 | 2016-03-19 01:03:51 +0100 | [diff] [blame] | 770 | |
| 771 | The "Object allocated at" traceback is new and only displayed if |
Victor Stinner | ee803a8 | 2016-03-19 10:33:25 +0100 | [diff] [blame] | 772 | :mod:`tracemalloc` is tracing Python memory allocations and if the |
| 773 | :mod:`warnings` was already imported. |
Victor Stinner | 914cde8 | 2016-03-19 01:03:51 +0100 | [diff] [blame] | 774 | |
| 775 | |
Steve Dower | 80ac11d | 2016-05-24 15:42:04 -0700 | [diff] [blame] | 776 | winreg |
| 777 | ------ |
| 778 | |
Steve Dower | 4d4bc42 | 2016-05-25 11:26:07 -0700 | [diff] [blame] | 779 | Added the 64-bit integer type :data:`REG_QWORD <winreg.REG_QWORD>`. |
Steve Dower | 80ac11d | 2016-05-24 15:42:04 -0700 | [diff] [blame] | 780 | (Contributed by Clement Rouault in :issue:`23026`.) |
| 781 | |
| 782 | |
Zachary Ware | c401881 | 2016-09-06 16:32:43 -0500 | [diff] [blame] | 783 | winsound |
| 784 | -------- |
| 785 | |
| 786 | Allowed keyword arguments to be passed to :func:`Beep <winsound.Beep>`, |
| 787 | :func:`MessageBeep <winsound.MessageBeep>`, and :func:`PlaySound |
| 788 | <winsound.PlaySound>` (:issue:`27982`). |
| 789 | |
| 790 | |
Serhiy Storchaka | 503f908 | 2016-02-08 00:02:25 +0200 | [diff] [blame] | 791 | zipfile |
| 792 | ------- |
| 793 | |
| 794 | A new :meth:`ZipInfo.from_file() <zipfile.ZipInfo.from_file>` class method |
Martin Panter | 288ed03 | 2016-02-10 05:45:55 +0000 | [diff] [blame] | 795 | allows making a :class:`~zipfile.ZipInfo` instance from a filesystem file. |
Serhiy Storchaka | 503f908 | 2016-02-08 00:02:25 +0200 | [diff] [blame] | 796 | A new :meth:`ZipInfo.is_dir() <zipfile.ZipInfo.is_dir>` method can be used |
| 797 | to check if the :class:`~zipfile.ZipInfo` instance represents a directory. |
| 798 | (Contributed by Thomas Kluyver in :issue:`26039`.) |
| 799 | |
Serhiy Storchaka | 18ee29d | 2016-05-13 13:52:49 +0300 | [diff] [blame] | 800 | The :meth:`ZipFile.open() <zipfile.ZipFile.open>` method can now be used to |
| 801 | write data into a ZIP file, as well as for extracting data. |
| 802 | (Contributed by Thomas Kluyver in :issue:`26039`.) |
| 803 | |
Serhiy Storchaka | 503f908 | 2016-02-08 00:02:25 +0200 | [diff] [blame] | 804 | |
Martin Panter | 1fe0d13 | 2016-02-10 10:06:36 +0000 | [diff] [blame] | 805 | zlib |
| 806 | ---- |
| 807 | |
| 808 | The :func:`~zlib.compress` function now accepts keyword arguments. |
| 809 | (Contributed by Aviv Palivoda in :issue:`26243`.) |
| 810 | |
| 811 | |
Serhiy Storchaka | b275210 | 2016-04-27 23:13:46 +0300 | [diff] [blame] | 812 | fileinput |
| 813 | --------- |
| 814 | |
| 815 | :func:`~fileinput.hook_encoded` now supports the *errors* argument. |
| 816 | (Contributed by Joseph Hackman in :issue:`25788`.) |
| 817 | |
| 818 | |
Yury Selivanov | d1da507 | 2015-05-27 22:09:10 -0400 | [diff] [blame] | 819 | Optimizations |
| 820 | ============= |
| 821 | |
Martin Panter | fad4b60 | 2015-11-14 01:29:17 +0000 | [diff] [blame] | 822 | * The ASCII decoder is now up to 60 times as fast for error handlers |
Victor Stinner | ebcf9ed | 2015-10-14 10:10:00 +0200 | [diff] [blame] | 823 | ``surrogateescape``, ``ignore`` and ``replace`` (Contributed |
| 824 | by Victor Stinner in :issue:`24870`). |
Yury Selivanov | d1da507 | 2015-05-27 22:09:10 -0400 | [diff] [blame] | 825 | |
Terry Jan Reedy | 6dc9ce1 | 2015-10-20 01:07:53 -0400 | [diff] [blame] | 826 | * The ASCII and the Latin1 encoders are now up to 3 times as fast for the |
Martin Panter | fad4b60 | 2015-11-14 01:29:17 +0000 | [diff] [blame] | 827 | error handler ``surrogateescape`` (Contributed by Victor Stinner in :issue:`25227`). |
Victor Stinner | c3713e9 | 2015-09-29 12:32:13 +0200 | [diff] [blame] | 828 | |
Martin Panter | fad4b60 | 2015-11-14 01:29:17 +0000 | [diff] [blame] | 829 | * The UTF-8 encoder is now up to 75 times as fast for error handlers |
Victor Stinner | ebcf9ed | 2015-10-14 10:10:00 +0200 | [diff] [blame] | 830 | ``ignore``, ``replace``, ``surrogateescape``, ``surrogatepass`` (Contributed |
| 831 | by Victor Stinner in :issue:`25267`). |
Victor Stinner | 01ada39 | 2015-10-01 21:54:51 +0200 | [diff] [blame] | 832 | |
Martin Panter | fad4b60 | 2015-11-14 01:29:17 +0000 | [diff] [blame] | 833 | * The UTF-8 decoder is now up to 15 times as fast for error handlers |
Victor Stinner | ebcf9ed | 2015-10-14 10:10:00 +0200 | [diff] [blame] | 834 | ``ignore``, ``replace`` and ``surrogateescape`` (Contributed |
| 835 | by Victor Stinner in :issue:`25301`). |
| 836 | |
| 837 | * ``bytes % args`` is now up to 2 times faster. (Contributed by Victor Stinner |
| 838 | in :issue:`25349`). |
| 839 | |
| 840 | * ``bytearray % args`` is now between 2.5 and 5 times faster. (Contributed by |
| 841 | Victor Stinner in :issue:`25399`). |
Victor Stinner | 1d65d91 | 2015-10-05 13:43:50 +0200 | [diff] [blame] | 842 | |
Victor Stinner | 2bf8993 | 2015-10-14 11:25:33 +0200 | [diff] [blame] | 843 | * Optimize :meth:`bytes.fromhex` and :meth:`bytearray.fromhex`: they are now |
| 844 | between 2x and 3.5x faster. (Contributed by Victor Stinner in :issue:`25401`). |
| 845 | |
Victor Stinner | fac3956 | 2016-03-21 10:38:58 +0100 | [diff] [blame] | 846 | * Optimize ``bytes.replace(b'', b'.')`` and ``bytearray.replace(b'', b'.')``: |
| 847 | up to 80% faster. (Contributed by Josh Snider in :issue:`26574`). |
| 848 | |
Victor Stinner | 8153ac8 | 2016-04-24 22:33:26 +0200 | [diff] [blame] | 849 | * Allocator functions of the :c:func:`PyMem_Malloc` domain |
| 850 | (:c:data:`PYMEM_DOMAIN_MEM`) now use the :ref:`pymalloc memory allocator |
| 851 | <pymalloc>` instead of :c:func:`malloc` function of the C library. The |
| 852 | pymalloc allocator is optimized for objects smaller or equal to 512 bytes |
| 853 | with a short lifetime, and use :c:func:`malloc` for larger memory blocks. |
| 854 | (Contributed by Victor Stinner in :issue:`26249`). |
| 855 | |
Victor Stinner | 19ed27e | 2016-05-20 11:42:37 +0200 | [diff] [blame] | 856 | * :func:`pickle.load` and :func:`pickle.loads` are now up to 10% faster when |
| 857 | deserializing many small objects (Contributed by Victor Stinner in |
| 858 | :issue:`27056`). |
Yury Selivanov | d1da507 | 2015-05-27 22:09:10 -0400 | [diff] [blame] | 859 | |
Serhiy Storchaka | 9171a8b | 2016-08-14 10:52:18 +0300 | [diff] [blame] | 860 | - Passing :term:`keyword arguments <keyword argument>` to a function has an |
| 861 | overhead in comparison with passing :term:`positional arguments |
| 862 | <positional argument>`. Now in extension functions implemented with using |
| 863 | Argument Clinic this overhead is significantly decreased. |
| 864 | (Contributed by Serhiy Storchaka in :issue:`27574`). |
| 865 | |
Serhiy Storchaka | 28ab634 | 2016-09-06 22:33:41 +0300 | [diff] [blame] | 866 | * Optimized :func:`~glob.glob` and :func:`~glob.iglob` functions in the |
| 867 | :mod:`glob` module; they are now about 3--6 times faster. |
| 868 | (Contributed by Serhiy Storchaka in :issue:`25596`). |
| 869 | |
Serhiy Storchaka | 680cb15 | 2016-09-07 10:58:05 +0300 | [diff] [blame] | 870 | * Optimized globbing in :mod:`pathlib` by using :func:`os.scandir`; |
| 871 | it is now about 1.5--4 times faster. |
| 872 | (Contributed by Serhiy Storchaka in :issue:`26032`). |
Serhiy Storchaka | 9171a8b | 2016-08-14 10:52:18 +0300 | [diff] [blame] | 873 | |
Yury Selivanov | d1da507 | 2015-05-27 22:09:10 -0400 | [diff] [blame] | 874 | Build and C API Changes |
| 875 | ======================= |
| 876 | |
Benjamin Peterson | cfbd48b | 2016-09-08 10:27:20 -0700 | [diff] [blame] | 877 | * Python now requires some C99 support in the toolchain to build. For more |
| 878 | information, see :pep:`7`. |
| 879 | |
Brett Cannon | 63d98bc | 2016-09-06 17:12:40 -0700 | [diff] [blame] | 880 | * The ``--with-optimizations`` configure flag has been added. Turning it on |
| 881 | will activate LTO and PGO build support (when available). |
| 882 | (Original patch by Alecsandru Patrascu of Intel in :issue:`26539`.) |
| 883 | |
Martin Panter | b4ce1fc | 2015-11-30 03:18:29 +0000 | [diff] [blame] | 884 | * New :c:func:`Py_FinalizeEx` API which indicates if flushing buffered data |
| 885 | failed (:issue:`5319`). |
Yury Selivanov | d1da507 | 2015-05-27 22:09:10 -0400 | [diff] [blame] | 886 | |
Serhiy Storchaka | f41b82f | 2016-06-09 16:30:29 +0300 | [diff] [blame] | 887 | * :c:func:`PyArg_ParseTupleAndKeywords` now supports :ref:`positional-only |
| 888 | parameters <positional-only_parameter>`. Positional-only parameters are |
| 889 | defined by empty names. |
Berker Peksag | e807e89 | 2016-07-01 12:12:19 +0300 | [diff] [blame] | 890 | (Contributed by Serhiy Storchaka in :issue:`26282`). |
Serhiy Storchaka | f41b82f | 2016-06-09 16:30:29 +0300 | [diff] [blame] | 891 | |
Nick Coghlan | d003423 | 2016-08-15 13:11:34 +1000 | [diff] [blame] | 892 | * ``PyTraceback_Print`` method now abbreviates long sequences of repeated lines |
| 893 | as ``"[Previous line repeated {count} more times]"``. |
| 894 | (Contributed by Emanuel Barry in :issue:`26823`.) |
| 895 | |
Yury Selivanov | d1da507 | 2015-05-27 22:09:10 -0400 | [diff] [blame] | 896 | |
| 897 | Deprecated |
| 898 | ========== |
| 899 | |
Yury Selivanov | 7a21911 | 2015-05-28 17:10:29 -0400 | [diff] [blame] | 900 | New Keywords |
| 901 | ------------ |
| 902 | |
Yury Selivanov | 62f27b5 | 2015-08-03 14:57:21 -0400 | [diff] [blame] | 903 | ``async`` and ``await`` are not recommended to be used as variable, class, |
| 904 | function or module names. Introduced by :pep:`492` in Python 3.5, they will |
| 905 | become proper keywords in Python 3.7. |
Yury Selivanov | 7a21911 | 2015-05-28 17:10:29 -0400 | [diff] [blame] | 906 | |
| 907 | |
Yury Selivanov | d1da507 | 2015-05-27 22:09:10 -0400 | [diff] [blame] | 908 | Deprecated Python modules, functions and methods |
| 909 | ------------------------------------------------ |
| 910 | |
Brett Cannon | 9e080e0 | 2016-04-08 12:15:27 -0700 | [diff] [blame] | 911 | * :meth:`importlib.machinery.SourceFileLoader.load_module` and |
| 912 | :meth:`importlib.machinery.SourcelessFileLoader.load_module` are now |
| 913 | deprecated. They were the only remaining implementations of |
Brett Cannon | eae3079 | 2015-12-28 17:55:27 -0800 | [diff] [blame] | 914 | :meth:`importlib.abc.Loader.load_module` in :mod:`importlib` that had not |
| 915 | been deprecated in previous versions of Python in favour of |
| 916 | :meth:`importlib.abc.Loader.exec_module`. |
Yury Selivanov | d1da507 | 2015-05-27 22:09:10 -0400 | [diff] [blame] | 917 | |
| 918 | |
| 919 | Deprecated functions and types of the C API |
| 920 | ------------------------------------------- |
| 921 | |
| 922 | * None yet. |
| 923 | |
| 924 | |
| 925 | Deprecated features |
| 926 | ------------------- |
| 927 | |
Brett Cannon | 9b63868 | 2015-10-16 15:14:27 -0700 | [diff] [blame] | 928 | * The ``pyvenv`` script has been deprecated in favour of ``python3 -m venv``. |
| 929 | This prevents confusion as to what Python interpreter ``pyvenv`` is |
| 930 | connected to and thus what Python interpreter will be used by the virtual |
Brett Cannon | 63b8505 | 2016-01-15 13:33:03 -0800 | [diff] [blame] | 931 | environment. (Contributed by Brett Cannon in :issue:`25154`.) |
| 932 | |
| 933 | * When performing a relative import, falling back on ``__name__`` and |
| 934 | ``__path__`` from the calling module when ``__spec__`` or |
| 935 | ``__package__`` are not defined now raises an :exc:`ImportWarning`. |
| 936 | (Contributed by Rose Ames in :issue:`25791`.) |
Yury Selivanov | d1da507 | 2015-05-27 22:09:10 -0400 | [diff] [blame] | 937 | |
Serhiy Storchaka | 0122ae9 | 2016-07-06 12:21:58 +0300 | [diff] [blame] | 938 | * Unlike to other :mod:`dbm` implementations, the :mod:`dbm.dumb` module |
| 939 | creates database in ``'r'`` and ``'w'`` modes if it doesn't exist and |
| 940 | allows modifying database in ``'r'`` mode. This behavior is now deprecated |
| 941 | and will be removed in 3.8. |
| 942 | (Contributed by Serhiy Storchaka in :issue:`21708`.) |
Yury Selivanov | d1da507 | 2015-05-27 22:09:10 -0400 | [diff] [blame] | 943 | |
Serhiy Storchaka | d73c318 | 2016-08-06 23:22:08 +0300 | [diff] [blame] | 944 | * Undocumented support of general :term:`bytes-like objects <bytes-like object>` |
Serhiy Storchaka | febc332 | 2016-08-06 23:29:29 +0300 | [diff] [blame] | 945 | as paths in :mod:`os` functions, :func:`compile` and similar functions is |
| 946 | now deprecated. |
| 947 | (Contributed by Serhiy Storchaka in :issue:`25791` and :issue:`26754`.) |
Serhiy Storchaka | d73c318 | 2016-08-06 23:22:08 +0300 | [diff] [blame] | 948 | |
Jason R. Coombs | 5c071c1 | 2016-09-01 13:55:33 -0400 | [diff] [blame] | 949 | * The undocumented ``extra_path`` argument to a distutils Distribution |
| 950 | is now considered |
| 951 | deprecated, will raise a warning during install if set. Support for this |
| 952 | parameter will be dropped in a future Python release and likely earlier |
| 953 | through third party tools. See :issue:`27919` for details. |
| 954 | |
Serhiy Storchaka | d73c318 | 2016-08-06 23:22:08 +0300 | [diff] [blame] | 955 | |
Martin Panter | 7e3a91a | 2016-02-10 04:40:48 +0000 | [diff] [blame] | 956 | Deprecated Python behavior |
| 957 | -------------------------- |
| 958 | |
| 959 | * Raising the :exc:`StopIteration` exception inside a generator will now generate a |
| 960 | :exc:`DeprecationWarning`, and will trigger a :exc:`RuntimeError` in Python 3.7. |
| 961 | See :ref:`whatsnew-pep-479` for details. |
| 962 | |
| 963 | |
Yury Selivanov | d1da507 | 2015-05-27 22:09:10 -0400 | [diff] [blame] | 964 | Removed |
| 965 | ======= |
| 966 | |
| 967 | API and Feature Removals |
| 968 | ------------------------ |
| 969 | |
Yury Selivanov | 5661316 | 2015-07-23 17:51:34 +0300 | [diff] [blame] | 970 | * ``inspect.getmoduleinfo()`` was removed (was deprecated since CPython 3.3). |
Yury Selivanov | 6dfbc5d | 2015-07-23 17:49:00 +0300 | [diff] [blame] | 971 | :func:`inspect.getmodulename` should be used for obtaining the module |
| 972 | name for a given path. |
| 973 | |
Senthil Kumaran | 613065b | 2016-01-17 20:12:16 -0800 | [diff] [blame] | 974 | * ``traceback.Ignore`` class and ``traceback.usage``, ``traceback.modname``, |
| 975 | ``traceback.fullmodname``, ``traceback.find_lines_from_code``, |
| 976 | ``traceback.find_lines``, ``traceback.find_strings``, |
| 977 | ``traceback.find_executable_lines`` methods were removed from the |
| 978 | :mod:`traceback` module. They were undocumented methods deprecated since |
| 979 | Python 3.2 and equivalent functionality is available from private methods. |
| 980 | |
Serhiy Storchaka | 2e208b7 | 2016-05-16 22:35:46 +0300 | [diff] [blame] | 981 | * The ``tk_menuBar()`` and ``tk_bindForTraversal()`` dummy methods in |
| 982 | :mod:`tkinter` widget classes were removed (corresponding Tk commands |
| 983 | were obsolete since Tk 4.0). |
| 984 | |
Serhiy Storchaka | e670be2 | 2016-06-11 19:32:44 +0300 | [diff] [blame] | 985 | * The :meth:`~zipfile.ZipFile.open` method of the :class:`zipfile.ZipFile` |
| 986 | class no longer supports the ``'U'`` mode (was deprecated since Python 3.4). |
| 987 | Use :class:`io.TextIOWrapper` for reading compressed text files in |
| 988 | :term:`universal newlines` mode. |
| 989 | |
Yury Selivanov | d1da507 | 2015-05-27 22:09:10 -0400 | [diff] [blame] | 990 | |
| 991 | Porting to Python 3.6 |
| 992 | ===================== |
| 993 | |
| 994 | This section lists previously described changes and other bugfixes |
| 995 | that may require changes to your code. |
| 996 | |
Serhiy Storchaka | 7e160ce | 2016-07-03 21:03:53 +0300 | [diff] [blame] | 997 | Changes in 'python' Command Behavior |
| 998 | ------------------------------------ |
| 999 | |
| 1000 | * The output of a special Python build with defined ``COUNT_ALLOCS``, |
| 1001 | ``SHOW_ALLOC_COUNT`` or ``SHOW_TRACK_COUNT`` macros is now off by |
| 1002 | default. It can be re-enabled using the ``-X showalloccount`` option. |
| 1003 | It now outputs to ``stderr`` instead of ``stdout``. |
| 1004 | (Contributed by Serhiy Storchaka in :issue:`23034`.) |
| 1005 | |
| 1006 | |
Yury Selivanov | d1da507 | 2015-05-27 22:09:10 -0400 | [diff] [blame] | 1007 | Changes in the Python API |
| 1008 | ------------------------- |
| 1009 | |
Victor Stinner | e66987e | 2016-09-06 16:33:52 -0700 | [diff] [blame] | 1010 | * On Linux, :func:`os.urandom` now blocks until the system urandom entropy pool |
| 1011 | is initialized to increase the security. |
| 1012 | |
Brett Cannon | 696c35e | 2016-06-25 10:58:17 -0700 | [diff] [blame] | 1013 | * When :meth:`importlib.abc.Loader.exec_module` is defined, |
| 1014 | :meth:`importlib.abc.Loader.create_module` must also be defined. |
| 1015 | |
Eric Snow | 46f97b8 | 2016-09-07 16:56:15 -0700 | [diff] [blame] | 1016 | * :c:func:`PyErr_SetImportError` now sets :exc:`TypeError` when its **msg** |
| 1017 | argument is not set. Previously only ``NULL`` was returned. |
| 1018 | |
Victor Stinner | f3914eb | 2016-01-20 12:16:21 +0100 | [diff] [blame] | 1019 | * The format of the ``co_lnotab`` attribute of code objects changed to support |
| 1020 | negative line number delta. By default, Python does not emit bytecode with |
| 1021 | negative line number delta. Functions using ``frame.f_lineno``, |
| 1022 | ``PyFrame_GetLineNumber()`` or ``PyCode_Addr2Line()`` are not affected. |
| 1023 | Functions decoding directly ``co_lnotab`` should be updated to use a signed |
| 1024 | 8-bit integer type for the line number delta, but it's only required to |
| 1025 | support applications using negative line number delta. See |
| 1026 | ``Objects/lnotab_notes.txt`` for the ``co_lnotab`` format and how to decode |
| 1027 | it, and see the :pep:`511` for the rationale. |
| 1028 | |
Brett Cannon | 1e3c3e9 | 2015-12-27 13:17:04 -0800 | [diff] [blame] | 1029 | * The functions in the :mod:`compileall` module now return booleans instead |
| 1030 | of ``1`` or ``0`` to represent success or failure, respectively. Thanks to |
| 1031 | booleans being a subclass of integers, this should only be an issue if you |
| 1032 | were doing identity checks for ``1`` or ``0``. See :issue:`25768`. |
| 1033 | |
Robert Collins | dfa95c9 | 2015-08-10 09:53:30 +1200 | [diff] [blame] | 1034 | * Reading the :attr:`~urllib.parse.SplitResult.port` attribute of |
| 1035 | :func:`urllib.parse.urlsplit` and :func:`~urllib.parse.urlparse` results |
| 1036 | now raises :exc:`ValueError` for out-of-range values, rather than |
| 1037 | returning :const:`None`. See :issue:`20059`. |
Yury Selivanov | d1da507 | 2015-05-27 22:09:10 -0400 | [diff] [blame] | 1038 | |
Brett Cannon | c0d91af | 2015-10-16 12:21:37 -0700 | [diff] [blame] | 1039 | * The :mod:`imp` module now raises a :exc:`DeprecationWarning` instead of |
| 1040 | :exc:`PendingDeprecationWarning`. |
| 1041 | |
Martin Panter | 28a465c | 2015-11-14 12:52:08 +0000 | [diff] [blame] | 1042 | * The following modules have had missing APIs added to their :attr:`__all__` |
Martin Panter | 0d3535a | 2016-06-06 02:09:08 +0000 | [diff] [blame] | 1043 | attributes to match the documented APIs: |
| 1044 | :mod:`calendar`, :mod:`cgi`, :mod:`csv`, |
Martin Panter | dcfebb3 | 2016-04-01 06:55:55 +0000 | [diff] [blame] | 1045 | :mod:`~xml.etree.ElementTree`, :mod:`enum`, |
Martin Panter | 0d3535a | 2016-06-06 02:09:08 +0000 | [diff] [blame] | 1046 | :mod:`fileinput`, :mod:`ftplib`, :mod:`logging`, :mod:`mailbox`, |
| 1047 | :mod:`mimetypes`, :mod:`optparse`, :mod:`plistlib`, :mod:`smtpd`, |
| 1048 | :mod:`subprocess`, :mod:`tarfile`, :mod:`threading` and |
Martin Panter | 28a465c | 2015-11-14 12:52:08 +0000 | [diff] [blame] | 1049 | :mod:`wave`. This means they will export new symbols when ``import *`` |
| 1050 | is used. See :issue:`23883`. |
| 1051 | |
Brett Cannon | 849113a | 2016-01-22 15:25:50 -0800 | [diff] [blame] | 1052 | * When performing a relative import, if ``__package__`` does not compare equal |
| 1053 | to ``__spec__.parent`` then :exc:`ImportWarning` is raised. |
| 1054 | (Contributed by Brett Cannon in :issue:`25791`.) |
Brett Cannon | 63b8505 | 2016-01-15 13:33:03 -0800 | [diff] [blame] | 1055 | |
Brett Cannon | 9fa8126 | 2016-01-22 16:39:02 -0800 | [diff] [blame] | 1056 | * When a relative import is performed and no parent package is known, then |
| 1057 | :exc:`ImportError` will be raised. Previously, :exc:`SystemError` could be |
Martin Panter | d9108d1 | 2016-02-21 08:49:56 +0000 | [diff] [blame] | 1058 | raised. (Contributed by Brett Cannon in :issue:`18018`.) |
| 1059 | |
| 1060 | * Servers based on the :mod:`socketserver` module, including those |
| 1061 | defined in :mod:`http.server`, :mod:`xmlrpc.server` and |
| 1062 | :mod:`wsgiref.simple_server`, now only catch exceptions derived |
| 1063 | from :exc:`Exception`. Therefore if a request handler raises |
| 1064 | an exception like :exc:`SystemExit` or :exc:`KeyboardInterrupt`, |
| 1065 | :meth:`~socketserver.BaseServer.handle_error` is no longer called, and |
| 1066 | the exception will stop a single-threaded server. (Contributed by |
| 1067 | Martin Panter in :issue:`23430`.) |
Brett Cannon | 9fa8126 | 2016-01-22 16:39:02 -0800 | [diff] [blame] | 1068 | |
Berker Peksag | 3c3d7f4 | 2016-03-19 11:44:17 +0200 | [diff] [blame] | 1069 | * :func:`spwd.getspnam` now raises a :exc:`PermissionError` instead of |
| 1070 | :exc:`KeyError` if the user doesn't have privileges. |
Yury Selivanov | d1da507 | 2015-05-27 22:09:10 -0400 | [diff] [blame] | 1071 | |
Martin Panter | 50ab1a3 | 2016-04-11 00:38:12 +0000 | [diff] [blame] | 1072 | * The :meth:`socket.socket.close` method now raises an exception if |
| 1073 | an error (e.g. EBADF) was reported by the underlying system call. |
| 1074 | See :issue:`26685`. |
| 1075 | |
Serhiy Storchaka | 8c740c4 | 2016-05-29 23:43:24 +0300 | [diff] [blame] | 1076 | * The *decode_data* argument for :class:`smtpd.SMTPChannel` and |
| 1077 | :class:`smtpd.SMTPServer` constructors is now ``False`` by default. |
| 1078 | This means that the argument passed to |
| 1079 | :meth:`~smtpd.SMTPServer.process_message` is now a bytes object by |
| 1080 | default, and ``process_message()`` will be passed keyword arguments. |
| 1081 | Code that has already been updated in accordance with the deprecation |
| 1082 | warning generated by 3.5 will not be affected. |
| 1083 | |
Serhiy Storchaka | aacd53f | 2016-06-22 00:03:20 +0300 | [diff] [blame] | 1084 | * All optional parameters of the :func:`~json.dump`, :func:`~json.dumps`, |
| 1085 | :func:`~json.load` and :func:`~json.loads` functions and |
| 1086 | :class:`~json.JSONEncoder` and :class:`~json.JSONDecoder` class |
| 1087 | constructors in the :mod:`json` module are now :ref:`keyword-only |
| 1088 | <keyword-only_parameter>`. |
| 1089 | (Contributed by Serhiy Storchaka in :issue:`18726`.) |
| 1090 | |
Nick Coghlan | 607e1c4 | 2016-07-31 12:42:49 +1000 | [diff] [blame] | 1091 | * As part of :pep:`487`, the handling of keyword arguments passed to |
| 1092 | :class:`type` (other than the metaclass hint, ``metaclass``) is now |
| 1093 | consistently delegated to :meth:`object.__init_subclass__`. This means that |
| 1094 | :meth:`type.__new__` and :meth:`type.__init__` both now accept arbitrary |
| 1095 | keyword arguments, but :meth:`object.__init_subclass__` (which is called from |
| 1096 | :meth:`type.__new__`) will reject them by default. Custom metaclasses |
| 1097 | accepting additional keyword arguments will need to adjust their calls to |
| 1098 | :meth:`type.__new__` (whether direct or via :class:`super`) accordingly. |
| 1099 | |
Jason R. Coombs | c758d51 | 2016-08-21 16:09:27 -0400 | [diff] [blame] | 1100 | * In :class:`distutils.command.sdist.sdist`, the ``default_format`` |
| 1101 | attribute has been removed and is no longer honored. Instead, the |
| 1102 | gzipped tarfile format is the default on all platforms and no |
| 1103 | platform-specific selection is made. |
| 1104 | In environments where distributions are |
| 1105 | built on Windows and zip distributions are required, configure |
| 1106 | the project with a ``setup.cfg`` file containing the following:: |
| 1107 | |
| 1108 | [sdist] |
| 1109 | formats=zip |
| 1110 | |
| 1111 | This behavior has also been backported to earlier Python versions |
| 1112 | by Setuptools 26.0.0. |
Serhiy Storchaka | aacd53f | 2016-06-22 00:03:20 +0300 | [diff] [blame] | 1113 | |
Martin Panter | ef91bb2 | 2016-08-27 01:39:26 +0000 | [diff] [blame] | 1114 | * In the :mod:`urllib.request` module and the |
| 1115 | :meth:`http.client.HTTPConnection.request` method, if no Content-Length |
| 1116 | header field has been specified and the request body is a file object, |
| 1117 | it is now sent with HTTP 1.1 chunked encoding. If a file object has to |
| 1118 | be sent to a HTTP 1.0 server, the Content-Length value now has to be |
| 1119 | specified by the caller. See :issue:`12319`. |
| 1120 | |
Yury Selivanov | d1da507 | 2015-05-27 22:09:10 -0400 | [diff] [blame] | 1121 | Changes in the C API |
| 1122 | -------------------- |
| 1123 | |
Victor Stinner | f5c4b99 | 2016-04-22 16:26:23 +0200 | [diff] [blame] | 1124 | * :c:func:`PyMem_Malloc` allocator family now uses the :ref:`pymalloc allocator |
| 1125 | <pymalloc>` rather than system :c:func:`malloc`. Applications calling |
| 1126 | :c:func:`PyMem_Malloc` without holding the GIL can now crash. Set the |
| 1127 | :envvar:`PYTHONMALLOC` environment variable to ``debug`` to validate the |
| 1128 | usage of memory allocators in your application. See :issue:`26249`. |
| 1129 | |
Martin Panter | b4ce1fc | 2015-11-30 03:18:29 +0000 | [diff] [blame] | 1130 | * :c:func:`Py_Exit` (and the main interpreter) now override the exit status |
| 1131 | with 120 if flushing buffered data failed. See :issue:`5319`. |