1.. bpo: 44600 2.. date: 2021-07-25-20-04-54 3.. nonce: 0WMldg 4.. release date: 2021-08-02 5.. section: Security 6 7Fix incorrect line numbers while tracing some failed patterns in :ref:`match 8<match>` statements. Patch by Charles Burkland. 9 10.. 11 12.. bpo: 44792 13.. date: 2021-07-31-12-12-57 14.. nonce: mOReTW 15.. section: Core and Builtins 16 17Improve syntax errors for if expressions. Patch by Miguel Brito 18 19.. 20 21.. bpo: 34013 22.. date: 2021-07-27-11-14-22 23.. nonce: SjLFe- 24.. section: Core and Builtins 25 26Generalize the invalid legacy statement custom error message (like the one 27generated when "print" is called without parentheses) to include more 28generic expressions. Patch by Pablo Galindo 29 30.. 31 32.. bpo: 44732 33.. date: 2021-07-26-15-27-03 34.. nonce: IxObt3 35.. section: Core and Builtins 36 37Rename ``types.Union`` to ``types.UnionType``. 38 39.. 40 41.. bpo: 44698 42.. date: 2021-07-21-15-26-56 43.. nonce: DA4_0o 44.. section: Core and Builtins 45 46Fix undefined behaviour in complex object exponentiation. 47 48.. 49 50.. bpo: 44653 51.. date: 2021-07-19-20-49-06 52.. nonce: WcqGyI 53.. section: Core and Builtins 54 55Support :mod:`typing` types in parameter substitution in the union type. 56 57.. 58 59.. bpo: 44676 60.. date: 2021-07-19-19-53-46 61.. nonce: WgIMvh 62.. section: Core and Builtins 63 64Add ability to serialise ``types.Union`` objects. Patch provided by Yurii 65Karabas. 66 67.. 68 69.. bpo: 44633 70.. date: 2021-07-17-21-04-04 71.. nonce: 5-zKeI 72.. section: Core and Builtins 73 74Parameter substitution of the union type with wrong types now raises 75``TypeError`` instead of returning ``NotImplemented``. 76 77.. 78 79.. bpo: 44662 80.. date: 2021-07-17-13-41-58 81.. nonce: q22kWR 82.. section: Core and Builtins 83 84Add ``__module__`` to ``types.Union``. This also fixes ``types.Union`` 85issues with ``typing.Annotated``. Patch provided by Yurii Karabas. 86 87.. 88 89.. bpo: 44655 90.. date: 2021-07-16-21-35-14 91.. nonce: 95I7M6 92.. section: Core and Builtins 93 94Include the name of the type in unset __slots__ attribute errors. Patch by 95Pablo Galindo 96 97.. 98 99.. bpo: 44655 100.. date: 2021-07-16-20-25-37 101.. nonce: I3wRjL 102.. section: Core and Builtins 103 104Don't include a missing attribute with the same name as the failing one when 105offering suggestions for missing attributes. Patch by Pablo Galindo 106 107.. 108 109.. bpo: 44646 110.. date: 2021-07-16-09-59-13 111.. nonce: Yb6s05 112.. section: Core and Builtins 113 114Fix the hash of the union type: it no longer depends on the order of 115arguments. 116 117.. 118 119.. bpo: 44636 120.. date: 2021-07-16-09-36-12 121.. nonce: ZWebi8 122.. section: Core and Builtins 123 124Collapse union of equal types. E.g. the result of ``int | int`` is now 125``int``. Fix comparison of the union type with non-hashable objects. E.g. 126``int | str == {}`` no longer raises a TypeError. 127 128.. 129 130.. bpo: 44635 131.. date: 2021-07-14-13-54-07 132.. nonce: 7ZMAdB 133.. section: Core and Builtins 134 135Convert ``None`` to ``type(None)`` in the union type constructor. 136 137.. 138 139.. bpo: 44589 140.. date: 2021-07-13-23-19-41 141.. nonce: 59OH8T 142.. section: Core and Builtins 143 144Mapping patterns in ``match`` statements with two or more equal literal keys 145will now raise a :exc:`SyntaxError` at compile-time. 146 147.. 148 149.. bpo: 44606 150.. date: 2021-07-13-20-22-12 151.. nonce: S3Bv2w 152.. section: Core and Builtins 153 154Fix ``__instancecheck__`` and ``__subclasscheck__`` for the union type. 155 156.. 157 158.. bpo: 42073 159.. date: 2021-07-13-17-47-32 160.. nonce: 9wopiC 161.. section: Core and Builtins 162 163The ``@classmethod`` decorator can now wrap other classmethod-like 164descriptors. 165 166.. 167 168.. bpo: 44490 169.. date: 2021-07-06-22-22-15 170.. nonce: BJxPbZ 171.. section: Core and Builtins 172 173:mod:`typing` now searches for type parameters in ``types.Union`` objects. 174``get_type_hints`` will also properly resolve annotations with nested 175``types.Union`` objects. Patch provided by Yurii Karabas. 176 177.. 178 179.. bpo: 44490 180.. date: 2021-07-01-11-59-34 181.. nonce: xY80VR 182.. section: Core and Builtins 183 184Add ``__parameters__`` attribute and ``__getitem__`` operator to 185``types.Union``. Patch provided by Yurii Karabas. 186 187.. 188 189.. bpo: 44472 190.. date: 2021-06-21-11-19-54 191.. nonce: Vvm1yn 192.. section: Core and Builtins 193 194Fix ltrace functionality when exceptions are raised. Patch by Pablo Galindo 195 196.. 197 198.. bpo: 44806 199.. date: 2021-08-02-14-37-32 200.. nonce: wOW_Qn 201.. section: Library 202 203Non-protocol subclasses of :class:`typing.Protocol` ignore now the 204``__init__`` method inherited from protocol base classes. 205 206.. 207 208.. bpo: 44793 209.. date: 2021-07-31-20-28-20 210.. nonce: woaQSg 211.. section: Library 212 213Fix checking the number of arguments when subscribe a generic type with 214``ParamSpec`` parameter. 215 216.. 217 218.. bpo: 44784 219.. date: 2021-07-31-08-45-31 220.. nonce: fIMIDS 221.. section: Library 222 223In importlib.metadata tests, override warnings behavior under expected 224DeprecationWarnings (importlib_metadata 4.6.3). 225 226.. 227 228.. bpo: 44667 229.. date: 2021-07-30-23-27-30 230.. nonce: tu0Xrv 231.. section: Library 232 233The :func:`tokenize.tokenize` doesn't incorrectly generate a ``NEWLINE`` 234token if the source doesn't end with a new line character but the last line 235is a comment, as the function is already generating a ``NL`` token. Patch by 236Pablo Galindo 237 238.. 239 240.. bpo: 44752 241.. date: 2021-07-27-22-11-29 242.. nonce: _bvbrZ 243.. section: Library 244 245:mod:`rcompleter` does not call :func:`getattr` on :class:`property` objects 246to avoid the side-effect of evaluating the corresponding method. 247 248.. 249 250.. bpo: 44720 251.. date: 2021-07-24-02-17-59 252.. nonce: shU5Qm 253.. section: Library 254 255``weakref.proxy`` objects referencing non-iterators now raise ``TypeError`` 256rather than dereferencing the null ``tp_iternext`` slot and crashing. 257 258.. 259 260.. bpo: 44704 261.. date: 2021-07-21-23-16-30 262.. nonce: iqHLxQ 263.. section: Library 264 265The implementation of ``collections.abc.Set._hash()`` now matches that of 266``frozenset.__hash__()``. 267 268.. 269 270.. bpo: 44666 271.. date: 2021-07-21-10-43-22 272.. nonce: CEThkv 273.. section: Library 274 275Fixed issue in :func:`compileall.compile_file` when ``sys.stdout`` is 276redirected. Patch by Stefan Hölzl. 277 278.. 279 280.. bpo: 42854 281.. date: 2021-07-20-21-51-35 282.. nonce: ThuDMI 283.. section: Library 284 285Fixed a bug in the :mod:`_ssl` module that was throwing :exc:`OverflowError` 286when using :meth:`_ssl._SSLSocket.write` and :meth:`_ssl._SSLSocket.read` 287for a big value of the ``len`` parameter. Patch by Pablo Galindo 288 289.. 290 291.. bpo: 44353 292.. date: 2021-07-19-22-43-15 293.. nonce: HF81_Q 294.. section: Library 295 296Refactor ``typing.NewType`` from function into callable class. Patch 297provided by Yurii Karabas. 298 299.. 300 301.. bpo: 44524 302.. date: 2021-07-19-14-04-42 303.. nonce: Nbf2JC 304.. section: Library 305 306Add missing ``__name__`` and ``__qualname__`` attributes to ``typing`` 307module classes. Patch provided by Yurii Karabas. 308 309.. 310 311.. bpo: 40897 312.. date: 2021-07-16-13-40-31 313.. nonce: aveAre 314.. section: Library 315 316Give priority to using the current class constructor in 317:func:`inspect.signature`. Patch by Weipeng Hong. 318 319.. 320 321.. bpo: 44648 322.. date: 2021-07-15-16-51-32 323.. nonce: 2o49TB 324.. section: Library 325 326Fixed wrong error being thrown by :func:`inspect.getsource` when examining a 327class in the interactive session. Instead of :exc:`TypeError`, it should be 328:exc:`OSError` with appropriate error message. 329 330.. 331 332.. bpo: 44608 333.. date: 2021-07-13-09-01-33 334.. nonce: R3IcM1 335.. section: Library 336 337Fix memory leak in :func:`_tkinter._flatten` if it is called with a sequence 338or set, but not list or tuple. 339 340.. 341 342.. bpo: 44559 343.. date: 2021-07-12-10-43-31 344.. nonce: YunVKY 345.. section: Library 346 347[Enum] module reverted to 3.9; 3.10 changes pushed until 3.11 348 349.. 350 351.. bpo: 41928 352.. date: 2021-07-09-07-14-37 353.. nonce: Q1jMrr 354.. section: Library 355 356Update :func:`shutil.copyfile` to raise :exc:`FileNotFoundError` instead of 357confusing :exc:`IsADirectoryError` when a path ending with a 358:const:`os.path.sep` does not exist; :func:`shutil.copy` and 359:func:`shutil.copy2` are also affected. 360 361.. 362 363.. bpo: 44566 364.. date: 2021-07-05-18-13-25 365.. nonce: o51Bd1 366.. section: Library 367 368handle StopIteration subclass raised from @contextlib.contextmanager 369generator 370 371.. 372 373.. bpo: 41249 374.. date: 2021-07-04-11-33-34 375.. nonce: sHdwBE 376.. section: Library 377 378Fixes ``TypedDict`` to work with ``typing.get_type_hints()`` and postponed 379evaluation of annotations across modules. 380 381.. 382 383.. bpo: 44461 384.. date: 2021-06-29-21-17-17 385.. nonce: acqRnV 386.. section: Library 387 388Fix bug with :mod:`pdb`'s handling of import error due to a package which 389does not have a ``__main__`` module 390 391.. 392 393.. bpo: 43625 394.. date: 2021-06-29-07-27-08 395.. nonce: ZlAxhp 396.. section: Library 397 398Fix a bug in the detection of CSV file headers by 399:meth:`csv.Sniffer.has_header` and improve documentation of same. 400 401.. 402 403.. bpo: 42892 404.. date: 2021-06-24-19-16-20 405.. nonce: qvRNhI 406.. section: Library 407 408Fixed an exception thrown while parsing a malformed multipart email by 409:class:`email.message.EmailMessage`. 410 411.. 412 413.. bpo: 27827 414.. date: 2021-06-12-21-25-35 415.. nonce: TMWh1i 416.. section: Library 417 418:meth:`pathlib.PureWindowsPath.is_reserved` now identifies a greater range 419of reserved filenames, including those with trailing spaces or colons. 420 421.. 422 423.. bpo: 38741 424.. date: 2019-11-12-18-59-33 425.. nonce: W7IYkq 426.. section: Library 427 428:mod:`configparser`: using ']' inside a section header will no longer cut 429the section name short at the ']' 430 431.. 432 433.. bpo: 27513 434.. date: 2019-06-03-23-53-25 435.. nonce: qITN7d 436.. section: Library 437 438:func:`email.utils.getaddresses` now accepts :class:`email.header.Header` 439objects along with string values. Patch by Zackery Spytz. 440 441.. 442 443.. bpo: 29298 444.. date: 2017-09-20-14-43-03 445.. nonce: _78CSN 446.. section: Library 447 448Fix ``TypeError`` when required subparsers without ``dest`` do not receive 449arguments. Patch by Anthony Sottile. 450 451.. 452 453.. bpo: 44740 454.. date: 2021-07-26-23-48-31 455.. nonce: zMFGMV 456.. section: Documentation 457 458Replaced occurences of uppercase "Web" and "Internet" with lowercase 459versions per the 2016 revised Associated Press Style Book. 460 461.. 462 463.. bpo: 44693 464.. date: 2021-07-25-23-04-15 465.. nonce: JuCbNq 466.. section: Documentation 467 468Update the definition of __future__ in the glossary by replacing the 469confusing word "pseudo-module" with a more accurate description. 470 471.. 472 473.. bpo: 35183 474.. date: 2021-07-22-08-28-03 475.. nonce: p9BWTB 476.. section: Documentation 477 478Add typical examples to os.path.splitext docs 479 480.. 481 482.. bpo: 30511 483.. date: 2021-07-20-21-03-18 484.. nonce: eMFkRi 485.. section: Documentation 486 487Clarify that :func:`shutil.make_archive` is not thread-safe due to reliance 488on changing the current working directory. 489 490.. 491 492.. bpo: 44561 493.. date: 2021-07-18-22-43-14 494.. nonce: T7HpWm 495.. section: Documentation 496 497Update of three expired hyperlinks in Doc/distributing/index.rst: "Project 498structure", "Building and packaging the project", and "Uploading the project 499to the Python Packaging Index". 500 501.. 502 503.. bpo: 44613 504.. date: 2021-07-12-11-39-20 505.. nonce: DIXNzc 506.. section: Documentation 507 508importlib.metadata is no longer provisional. 509 510.. 511 512.. bpo: 44544 513.. date: 2021-07-02-14-02-29 514.. nonce: _5_aCz 515.. section: Documentation 516 517List all kwargs for :func:`textwrap.wrap`, :func:`textwrap.fill`, and 518:func:`textwrap.shorten`. Now, there are nav links to attributes of 519:class:`TextWrap`, which makes navigation much easier while minimizing 520duplication in the documentation. 521 522.. 523 524.. bpo: 44453 525.. date: 2021-06-18-06-44-45 526.. nonce: 3PIkj2 527.. section: Documentation 528 529Fix documentation for the return type of :func:`sysconfig.get_path`. 530 531.. 532 533.. bpo: 44734 534.. date: 2021-07-24-20-09-15 535.. nonce: KKsNOV 536.. section: Tests 537 538Fixed floating point precision issue in turtle tests. 539 540.. 541 542.. bpo: 44708 543.. date: 2021-07-22-16-38-39 544.. nonce: SYNaac 545.. section: Tests 546 547Regression tests, when run with -w, are now re-running only the affected 548test methods instead of re-running the entire test file. 549 550.. 551 552.. bpo: 44647 553.. date: 2021-07-16-14-02-33 554.. nonce: 5LzqIy 555.. section: Tests 556 557Added a permanent Unicode-valued environment variable to regression tests to 558ensure they handle this use case in the future. If your test environment 559breaks because of that, report a bug to us, and temporarily set 560PYTHONREGRTEST_UNICODE_GUARD=0 in your test environment. 561 562.. 563 564.. bpo: 44515 565.. date: 2021-06-26-18-37-36 566.. nonce: e9fO6f 567.. section: Tests 568 569Adjust recently added contextlib tests to avoid assuming the use of a 570refcounted GC 571 572.. 573 574.. bpo: 44572 575.. date: 2021-07-13-15-32-49 576.. nonce: gXvhDc 577.. section: Windows 578 579Avoid consuming standard input in the :mod:`platform` module 580 581.. 582 583.. bpo: 40263 584.. date: 2020-04-13-15-20-28 585.. nonce: 1KKEbu 586.. section: Windows 587 588This is a follow-on bug from https://bugs.python.org/issue26903. Once that 589is applied we run into an off-by-one assertion problem. The assert was not 590correct. 591 592.. 593 594.. bpo: 41972 595.. date: 2021-07-12-15-42-02 596.. nonce: yUjE8j 597.. section: macOS 598 599The framework build's user header path in sysconfig is changed to add a 600'pythonX.Y' component to match distutils's behavior. 601 602.. 603 604.. bpo: 34932 605.. date: 2021-03-29-21-11-23 606.. nonce: f3Hdyd 607.. section: macOS 608 609Add socket.TCP_KEEPALIVE support for macOS. Patch by Shane Harvey. 610 611.. 612 613.. bpo: 44756 614.. date: 2021-07-28-00-51-55 615.. nonce: pvAajB 616.. section: Tools/Demos 617 618In the Makefile for documentation (:file:`Doc/Makefile`), the ``build`` rule 619is dependent on the ``venv`` rule. Therefore, ``html``, ``latex``, and other 620build-dependent rules are also now dependent on ``venv``. The ``venv`` rule 621only performs an action if ``$(VENVDIR)`` does not exist. 622:file:`Doc/README.rst` was updated; most users now only need to type ``make 623html``. 624 625.. 626 627.. bpo: 41103 628.. date: 2021-07-29-16-04-28 629.. nonce: hiKKcF 630.. section: C API 631 632Reverts removal of the old buffer protocol because they are part of stable 633ABI. 634 635.. 636 637.. bpo: 42747 638.. date: 2021-07-20-16-21-06 639.. nonce: rRxjUY 640.. section: C API 641 642The ``Py_TPFLAGS_HAVE_VERSION_TAG`` type flag now does nothing. The 643``Py_TPFLAGS_HAVE_AM_SEND`` flag (which was added in 3.10) is removed. Both 644were unnecessary because it is not possible to have type objects with the 645relevant fields missing. 646