+++++++++++
Python News
+++++++++++

What's New in Python 3.11.0 final?
==================================

*Release date: 2022-10-24*

Security
--------

- gh-issue-97616: Fix multiplying a list by an integer (``list *= int``):
  detect the integer overflow when the new allocated length is close to the
  maximum size. Issue reported by Jordan Limor.  Patch by Victor Stinner.

- gh-issue-97514: On Linux the :mod:`multiprocessing` module returns to
  using filesystem backed unix domain sockets for communication with the
  *forkserver* process instead of the Linux abstract socket namespace.  Only
  code that chooses to use the :ref:`"forkserver" start method
  <multiprocessing-start-methods>` is affected.

  Abstract sockets have no permissions and could allow any user on the
  system in the same `network namespace
  <https://man7.org/linux/man-pages/man7/network_namespaces.7.html>`_ (often
  the whole system) to inject code into the multiprocessing *forkserver*
  process. This was a potential privilege escalation. Filesystem based
  socket permissions restrict this to the *forkserver* process user as was
  the default in Python 3.8 and earlier.

  This prevents Linux `CVE-2022-42919
  <https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-42919>`_.

Core and Builtins
-----------------

- gh-issue-97002: Fix an issue where several frame objects could be backed
  by the same interpreter frame, possibly leading to corrupted memory and
  hard crashes of the interpreter.

- gh-issue-97752: Fix possible data corruption or crashes when accessing the
  ``f_back`` member of newly-created generator or coroutine frames.

- gh-issue-96975: Fix a crash occurring when :c:func:`PyEval_GetFrame` is
  called while the topmost Python frame is in a partially-initialized state.

- gh-issue-96848: Fix command line parsing: reject :option:`-X
  int_max_str_digits <-X>` option with no value (invalid) when the
  :envvar:`PYTHONINTMAXSTRDIGITS` environment variable is set to a valid
  limit. Patch by Victor Stinner.

- gh-issue-96821: Fix undefined behaviour in ``_testcapimodule.c``.

- gh-issue-95778: When :exc:`ValueError` is raised if an integer is larger
  than the limit, mention the :func:`sys.set_int_max_str_digits` function in
  the error message. Patch by Victor Stinner.

- gh-issue-96587: Correctly raise ``SyntaxError`` on exception groups
  (:pep:`654`) on python versions prior to 3.11

- bpo-42316: Document some places where an assignment expression needs
  parentheses.

Library
-------

- gh-issue-98331: Update the bundled copies of pip and setuptools to
  versions 22.3 and 65.5.0 respectively.

- gh-issue-90985: Earlier in 3.11 we deprecated
  ``asyncio.Task.cancel("message")``. We realized we were too harsh, and
  have undeprecated it.

- gh-issue-97545: Make Semaphore run faster.

- gh-issue-96865: fix Flag to use boundary CONFORM

  This restores previous Flag behavior of allowing flags with non-sequential
  values to be combined; e.g.

  class Skip(Flag):         TWO = 2         EIGHT = 8

  Skip.TWO | Skip.EIGHT -> <Skip.TWO|EIGHT: 10>

- gh-issue-90155: Fix broken :class:`asyncio.Semaphore` when acquire is
  cancelled.

Documentation
-------------

- gh-issue-97741: Fix ``!`` in c domain ref target syntax via a ``conf.py``
  patch, so it works as intended to disable ref target resolution.

- gh-issue-93031: Update tutorial introduction output to use 3.10+
  SyntaxError invalid range.

Tests
-----

- gh-issue-95027: On Windows, when the Python test suite is run with the
  ``-jN`` option, the ANSI code page is now used as the encoding for the
  stdout temporary file, rather than using UTF-8 which can lead to decoding
  errors. Patch by Victor Stinner.

Build
-----

- gh-issue-96729: Ensure that Windows releases built with
  ``Tools\msi\buildrelease.bat`` are upgradable to and from official Python
  releases.

Windows
-------

- gh-issue-98360: Fixes :mod:`multiprocessing` spawning child processes on
  Windows from a virtual environment to ensure that child processes that
  also use :mod:`multiprocessing` to spawn more children will recognize that
  they are in a virtual environment.

- gh-issue-98414: Fix :file:`py.exe` launcher handling of ``-V:<company>/``
  option when default preferences have been set in environment variables or
  configuration files.

- gh-issue-90989: Clarify some text in the Windows installer.

macOS
-----

- gh-issue-97897: The macOS 13 SDK includes support for the ``mkfifoat`` and
  ``mknodat`` system calls. Using the ``dir_fd`` option with either
  :func:`os.mkfifo` or :func:`os.mknod` could result in a segfault if
  cpython is built with the macOS 13 SDK but run on an earlier version of
  macOS. Prevent this by adding runtime support for detection of these
  system calls ("weaklinking") as is done for other newer syscalls on macOS.


What's New in Python 3.11.0 release candidate 2?
================================================

*Release date: 2022-09-11*

Security
--------

- gh-issue-95778: Converting between :class:`int` and :class:`str` in bases
  other than 2 (binary), 4, 8 (octal), 16 (hexadecimal), or 32 such as base
  10 (decimal) now raises a :exc:`ValueError` if the number of digits in
  string form is above a limit to avoid potential denial of service attacks
  due to the algorithmic complexity. This is a mitigation for
  `CVE-2020-10735
  <https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-10735>`_.

  This new limit can be configured or disabled by environment variable,
  command line flag, or :mod:`sys` APIs. See the :ref:`integer string
  conversion length limitation <int_max_str_digits>` documentation.  The
  default limit is 4300 digits in string form.

  Patch by Gregory P. Smith [Google] and Christian Heimes [Red Hat] with
  feedback from Victor Stinner, Thomas Wouters, Steve Dower, Ned Deily, and
  Mark Dickinson.

Core and Builtins
-----------------

- gh-issue-96678: Fix case of undefined behavior in ceval.c

- gh-issue-96641: Do not expose ``KeyWrapper`` in :mod:`_functools`.

- gh-issue-96636: Ensure that tracing, ``sys.setrace()``, is turned on
  immediately. In pre-release versions of 3.11, some tracing events might
  have been lost when turning on tracing in a ``__del__`` method or
  interrupt.

- gh-issue-96572: Fix use after free in trace refs build mode. Patch by
  Kumar Aditya.

- gh-issue-96611: When loading a file with invalid UTF-8 inside a multi-line
  string, a correct SyntaxError is emitted.

- gh-issue-96612: Make sure that incomplete frames do not show up in
  tracemalloc traces.

- gh-issue-96569: Remove two cases of undefined behavior, by adding NULL
  checks.

- gh-issue-96582: Fix possible ``NULL`` pointer dereference in
  ``_PyThread_CurrentFrames``. Patch by Kumar Aditya.

- gh-issue-96352: Fix :exc:`AttributeError` missing ``name`` and ``obj``
  attributes in :meth:`object.__getattribute__`. Patch by Philip Georgi.

- gh-issue-96268: Loading a file with invalid UTF-8 will now report the
  broken character at the correct location.

- gh-issue-96187: Fixed a bug that caused ``_PyCode_GetExtra`` to return
  garbage for negative indexes. Patch by Pablo Galindo

- gh-issue-96071: Fix a deadlock in :c:func:`PyGILState_Ensure` when
  allocating new thread state. Patch by Kumar Aditya.

- gh-issue-96046: :c:func:`PyType_Ready` now initializes ``ht_cached_keys``
  and performs additional checks to ensure that type objects are properly
  configured. This avoids crashes in 3rd party packages that don't use
  regular API to create new types.

- gh-issue-95818: Skip over incomplete frames in
  :c:func:`PyThreadState_GetFrame`.

- gh-issue-95876: Fix format string in
  ``_PyPegen_raise_error_known_location`` that can lead to memory corruption
  on some 64bit systems. The function was building a tuple with ``i`` (int)
  instead of ``n`` (Py_ssize_t) for Py_ssize_t arguments.

- gh-issue-95605: Fix misleading contents of error message when converting
  an all-whitespace string to :class:`float`.

- gh-issue-94996: :func:`ast.parse` will no longer parse function
  definitions with positional-only params when passed ``feature_version``
  less than ``(3, 8)``. Patch by Shantanu Jain.

Library
-------

- gh-issue-96700: Fix incorrect error message in the :mod:`io` module.

- gh-issue-96652: Fix the faulthandler implementation of
  ``faulthandler.register(signal, chain=True)`` if the ``sigaction()``
  function is not available: don't call the previous signal handler if it's
  NULL. Patch by Victor Stinner.

- gh-issue-68163: Correct conversion of :class:`numbers.Rational`'s to
  :class:`float`.

- gh-issue-96385: Fix ``TypeVarTuple.__typing_prepare_subst__``.
  ``TypeError`` was not raised when using more than one ``TypeVarTuple``,
  like ``[*T, *V]`` in type alias substitutions.

- gh-issue-90467: Fix :class:`asyncio.streams.StreamReaderProtocol` to keep
  a strong reference to the created task, so that it's not garbage collected

- gh-issue-96159: Fix a performance regression in logging
  TimedRotatingFileHandler. Only check for special files when the rollover
  time has passed.

- gh-issue-96175: Fix unused ``localName`` parameter in the ``Attr`` class
  in :mod:`xml.dom.minidom`.

- gh-issue-96125: Fix incorrect condition that causes
  ``sys.thread_info.name`` to be wrong on pthread platforms.

- gh-issue-95463: Remove an incompatible change from :issue:`28080` that
  caused a regression that ignored the utf8 in ``ZipInfo.flag_bits``. Patch
  by Pablo Galindo.

- gh-issue-95899: Fix :class:`asyncio.Runner` to call
  :func:`asyncio.set_event_loop` only once to avoid calling
  :meth:`~asyncio.AbstractChildWatcher.attach_loop` multiple times on child
  watchers. Patch by Kumar Aditya.

- gh-issue-95736: Fix :class:`unittest.IsolatedAsyncioTestCase` to set event
  loop before calling setup functions. Patch by Kumar Aditya.

- gh-issue-95704: When a task catches :exc:`asyncio.CancelledError` and
  raises some other error, the other error should generally not silently be
  suppressed.

- gh-issue-95231: Fail gracefully if :data:`~errno.EPERM` or
  :data:`~errno.ENOSYS` is raised when loading :mod:`crypt` methods. This
  may happen when trying to load ``MD5`` on a Linux kernel with :abbr:`FIPS
  (Federal Information Processing Standard)` enabled.

- gh-issue-74116: Allow :meth:`asyncio.StreamWriter.drain` to be awaited
  concurrently by multiple tasks. Patch by Kumar Aditya.

- gh-issue-92986: Fix :func:`ast.unparse` when ``ImportFrom.level`` is None

Documentation
-------------

- gh-issue-96098: Improve discoverability of the higher level
  concurrent.futures module by providing clearer links from the lower level
  threading and multiprocessing modules.

- gh-issue-95957: What's New 3.11 now has instructions for how to provide
  compiler and linker flags for Tcl/Tk and OpenSSL on RHEL 7 and CentOS 7.

Tests
-----

- gh-issue-95243: Mitigate the inherent race condition from using
  find_unused_port() in testSockName() by trying to find an unused port a
  few times before failing. Patch by Ross Burton.

Build
-----

- gh-issue-94682: Build and test with OpenSSL 1.1.1q

Windows
-------

- gh-issue-96577: Fixes a potential buffer overrun in :mod:`msilib`.

- gh-issue-96559: Fixes the Windows launcher not using the compatible
  interpretation of default tags found in configuration files when no tag
  was passed to the command.


What's New in Python 3.11.0 release candidate 1?
================================================

*Release date: 2022-08-05*

Core and Builtins
-----------------

- gh-issue-95150: Update code object hashing and equality to consider all
  debugging and exception handling tables. This fixes an issue where certain
  non-identical code objects could be "deduplicated" during compilation.

- gh-issue-95355: ``_PyPegen_Parser_New`` now properly detects token memory
  allocation errors. Patch by Honglin Zhu.

- gh-issue-90081: Run Python code in tracer/profiler function at full speed.
  Fixes slowdown in earlier versions of 3.11.

- gh-issue-95324: Emit a warning in debug mode if an object does not call
  :c:func:`PyObject_GC_UnTrack` before deallocation. Patch by Pablo Galindo.

- gh-issue-95185: Prevented crashes in the AST constructor when compiling
  some absurdly long expressions like ``"+0"*1000000``.
  :exc:`RecursionError` is now raised instead. Patch by Pablo Galindo

- gh-issue-93351: :class:`ast.AST` node positions are now validated when
  provided to :func:`compile` and other related functions. If invalid
  positions are detected, a :exc:`ValueError` will be raised.

- gh-issue-94938: Fix error detection in some builtin functions when keyword
  argument name is an instance of a str subclass with overloaded ``__eq__``
  and ``__hash__``. Previously it could cause SystemError or other undesired
  behavior.

Library
-------

- gh-issue-95609: Update bundled pip to 22.2.2.

- gh-issue-95289: Fix :class:`asyncio.TaskGroup` to propagate exception when
  :exc:`asyncio.CancelledError` was replaced with another exception by a
  context manger. Patch by Kumar Aditya and Guido van Rossum.

- gh-issue-95339: Update bundled pip to 22.2.1.

- gh-issue-95045: Fix GC crash when deallocating ``_lsprof.Profiler`` by
  untracking it before calling any callbacks. Patch by Kumar Aditya.

- gh-issue-95097: Fix :func:`asyncio.run` for :class:`asyncio.Task`
  implementations without :meth:`~asyncio.Task.uncancel` method. Patch by
  Kumar Aditya.

- gh-issue-93899: Fix check for existence of :data:`os.EFD_CLOEXEC`,
  :data:`os.EFD_NONBLOCK` and :data:`os.EFD_SEMAPHORE` flags on older kernel
  versions where these flags are not present. Patch by Kumar Aditya.

- gh-issue-95166: Fix :meth:`concurrent.futures.Executor.map` to cancel the
  currently waiting on future on an error - e.g. TimeoutError or
  KeyboardInterrupt.

- gh-issue-95109: Ensure that timeouts scheduled with
  :class:`asyncio.Timeout` that have already expired are delivered promptly.

- gh-issue-91810: Suppress writing an XML declaration in open files in
  ``ElementTree.write()`` with ``encoding='unicode'`` and
  ``xml_declaration=None``.

- gh-issue-91447: Fix findtext in the xml module to only give an empty
  string when the text attribute is set to None.

Documentation
-------------

- gh-issue-91207: Fix stylesheet not working in Windows CHM htmlhelp docs
  and add warning that they are deprecated. Contributed by C.A.M. Gerlach.

- gh-issue-95451: Update library documentation with :ref:`availability
  information <wasm-availability>` on WebAssembly platforms
  ``wasm32-emscripten`` and ``wasm32-wasi``.

- gh-issue-95415: Use consistent syntax for platform availability. The
  directive now supports a content body and emits a warning when it
  encounters an unknown platform.

- gh-issue-86128: Document a limitation in ThreadPoolExecutor where its exit
  handler is executed before any handlers in atexit.

Tests
-----

- gh-issue-95573: :source:`Lib/test/test_asyncio/test_ssl.py` exposed a bug
  in the macOS kernel where intense concurrent load on non-blocking sockets
  occasionally causes :const:`errno.ENOBUFS` ("No buffer space available")
  to be emitted. FB11063974 filed with Apple, in the mean time as a
  workaround buffer size used in tests on macOS is decreased to avoid
  intermittent failures.  Patch by Fantix King.

- gh-issue-95280: Fix problem with ``test_ssl`` ``test_get_ciphers`` on
  systems that require perfect forward secrecy (PFS) ciphers.

- gh-issue-94675: Add a regression test for :mod:`re` exponentional slowdown
  when using rjsmin.

Build
-----

- gh-issue-94801: Fix a regression in ``configure`` script that caused some
  header checks to ignore custom ``CPPFLAGS``. The regression was introduced
  in :gh:`94802`.

- gh-issue-95145: wasm32-wasi builds no longer depend on WASIX's pthread
  stubs. Python now has its own stubbed pthread API.

- gh-issue-95174: Python now detects missing ``dup`` function in WASI and
  works around some missing :mod:`errno`, :mod:`select`, and :mod:`socket`
  constants.

- gh-issue-95174: Python now skips missing :mod:`socket` functions and
  methods on WASI. WASI can only create sockets from existing fd / accept
  and has no netdb.

- gh-issue-95085: Platforms ``wasm32-unknown-emscripten`` and
  ``wasm32-unknown-wasi`` have been promoted to :pep:`11` tier 3 platform
  support.

Windows
-------

- gh-issue-95656: Enable the
  :meth:`~sqlite3.Connection.enable_load_extension` :mod:`sqlite3` API.

- gh-issue-95587: Fixes some issues where the Windows installer would
  incorrectly detect certain features of an existing install when upgrading.

- gh-issue-94399: Restores the behaviour of :ref:`launcher` for
  ``/usr/bin/env`` shebang lines, which will now search :envvar:`PATH` for
  an executable matching the given command. If none is found, the usual
  search process is used.

- gh-issue-95445: Fixes the unsuccessful removal of the HTML document
  directory when uninstalling with Windows msi.

- gh-issue-95359: Fix :ref:`launcher` handling of :file:`py.ini` commands
  (it was incorrectly expecting a ``py_`` prefix on keys) and crashes when
  reading per-user configuration file.

- gh-issue-95285: Fix :ref:`launcher` handling of command lines where it is
  only passed a short executable name.

IDLE
----

- gh-issue-65802: Document handling of extensions in Save As dialogs.

- gh-issue-95191: Include prompts when saving Shell (interactive input and
  output).

- gh-issue-95511: Fix the Shell context menu copy-with-prompts bug of
  copying an extra line when one selects whole lines.

- gh-issue-95471: In the Edit menu, move ``Select All`` and add a new
  separator.

- gh-issue-95411: Enable using IDLE's module browser with .pyw files.

- gh-issue-89610: Add .pyi as a recognized extension for IDLE on macOS.
  This allows opening stub files by double clicking on them in the Finder.

C API
-----

- gh-issue-92678: Restore the 3.10 behavior for multiple inheritance of C
  extension classes that store their dictionary at the end of the struct.

- gh-issue-94936: Added :c:func:`PyCode_GetVarnames`,
  :c:func:`PyCode_GetCellvars` and :c:func:`PyCode_GetFreevars` for
  accessing ``co_varnames``, ``co_cellvars`` and ``co_freevars``
  respectively via the C API.


What's New in Python 3.11.0 beta 5?
===================================

*Release date: 2022-07-25*

Core and Builtins
-----------------

- gh-issue-93351: :class:`ast.AST` node positions are now validated when
  provided to :func:`compile` and other related functions. If invalid
  positions are detected, a :exc:`ValueError` will be raised.

- gh-issue-94438: Fix an issue that caused extended opcode arguments and
  some conditional pops to be ignored when calculating valid jump targets
  for assignments to the ``f_lineno`` attribute of frame objects. In some
  cases, this could cause inconsistent internal state, resulting in a hard
  crash of the interpreter.

- gh-issue-95060: Undocumented ``PyCode_Addr2Location`` function now
  properly returns when ``addrq`` argument is less than zero.

- gh-issue-95113: Replace all ``EXTENDED_ARG_QUICK`` instructions with basic
  :opcode:`EXTENDED_ARG` instructions in unquickened code. Consumers of
  non-adaptive bytecode should be able to handle extended arguments the same
  way they were handled in CPython 3.10 and older.

- gh-issue-91409: Fix incorrect source location info caused by certain
  optimizations in the bytecode compiler.

- gh-issue-94036: Fix incorrect source location info for some multi-line
  attribute accesses and method calls.

- gh-issue-94739: Allow jumping within, out of, and across exception
  handlers in the debugger.

- gh-issue-94949: :func:`ast.parse` will no longer parse parenthesized
  context managers when passed ``feature_version`` less than ``(3, 9)``.
  Patch by Shantanu Jain.

- gh-issue-94947: :func:`ast.parse` will no longer parse assignment
  expressions when passed ``feature_version`` less than ``(3, 8)``. Patch by
  Shantanu Jain.

- gh-issue-91256: Ensures the program name is known for help text during
  interpreter startup.

- gh-issue-94869: Fix the column offsets for some expressions in multi-line
  f-strings :mod:`ast` nodes. Patch by Pablo Galindo.

- gh-issue-94822: Fix an issue where lookups of metaclass descriptors may be
  ignored when an identically-named attribute also exists on the class
  itself.

- gh-issue-91153: Fix an issue where a :class:`bytearray` item assignment
  could crash if it's resized by the new value's :meth:`__index__` method.

- gh-issue-90699: Fix reference counting bug in :meth:`bool.__repr__`. Patch
  by Kumar Aditya.

Library
-------

- gh-issue-95087: Fix IndexError in parsing invalid date in the :mod:`email`
  module.

- gh-issue-95199: Upgrade bundled setuptools to 63.2.0.

- gh-issue-95194: Upgrade bundled pip to 22.2.

- gh-issue-95132: Fix a :mod:`sqlite3` regression where ``*args`` and
  ``**kwds`` were incorrectly relayed from :py:func:`~sqlite3.connect` to
  the :class:`~sqlite3.Connection` factory. The regression was introduced in
  3.11a1 with PR 24421 (:gh:`85128`). Patch by Erlend E. Aasland.`

- gh-issue-93157: Fix :mod:`fileinput` module didn't support ``errors``
  option when ``inplace`` is true.

- gh-issue-95105: :meth:`wsgiref.types.InputStream.__iter__` should return
  ``Iterator[bytes]``, not ``Iterable[bytes]``. Patch by Shantanu Jain.

- gh-issue-94857: Fix refleak in ``_io.TextIOWrapper.reconfigure``. Patch by
  Kumar Aditya.

- gh-issue-94821: Fix binding of unix socket to empty address on Linux to
  use an available address from the abstract namespace, instead of "\0".

- gh-issue-89988: Fix memory leak in :class:`pickle.Pickler` when looking up
  :attr:`dispatch_table`. Patch by Kumar Aditya.

- bpo-47025: Drop support for :class:`bytes` on :attr:`sys.path`.

Tests
-----

- gh-issue-95212: Make multiprocessing test case
  ``test_shared_memory_recreate`` parallel-safe.

Build
-----

- gh-issue-94847: Fixed ``_decimal`` module build issue on GCC when
  compiling with LTO and pydebug. Debug builds no longer force inlining of
  functions.

- gh-issue-94841: Fix the possible performance regression of
  :c:func:`PyObject_Free` compiled with MSVC version 1932.

- gh-issue-94801: ``configure`` now uses custom flags like ``ZLIB_CFLAGS``
  and ``ZLIB_LIBS`` when searching for headers and libraries.

- gh-issue-94773: ``deepfreeze.py`` now supports code object with frozensets
  that contain incompatible, unsortable types.

Windows
-------

- gh-issue-90844: Allow virtual environments to correctly launch when they
  have spaces in the path.

- gh-issue-94772: Fix incorrect handling of shebang lines in py.exe launcher

C API
-----

- gh-issue-92678: Adds unstable C-API functions
  ``_PyObject_VisitManagedDict`` and ``_PyObject_ClearManagedDict`` to allow
  C extensions to allow the VM to manage their object's dictionaries.

- gh-issue-94930: Fix ``SystemError`` raised when
  :c:func:`PyArg_ParseTupleAndKeywords` is used with ``#`` in ``(...)`` but
  without ``PY_SSIZE_T_CLEAN`` defined.

- gh-issue-94864: Fix ``PyArg_Parse*`` with deprecated format units "u" and
  "Z". It returned 1 (success) when warnings are turned into exceptions.

- gh-issue-94731: Python again uses C-style casts for most casting
  operations when compiled with C++. This may trigger compiler warnings, if
  they are enabled with e.g. ``-Wold-style-cast `` or
  ``-Wzero-as-null-pointer-constant`` options for ``g++``.


What's New in Python 3.11.0 beta 4?
===================================

*Release date: 2022-07-11*

Security
--------

- gh-issue-87389: :mod:`http.server`: Fix an open redirection vulnerability
  in the HTTP server when an URI path starts with ``//``.  Vulnerability
  discovered, and initial fix proposed, by Hamza Avvan.

- gh-issue-79096: LWPCookieJar and MozillaCookieJar create files with file
  mode 600 instead of 644 (Microsoft Windows is not affected)

- gh-issue-92888: Fix ``memoryview`` use after free when accessing the
  backing buffer in certain cases.

- gh-issue-68966: The deprecated mailcap module now refuses to inject unsafe
  text (filenames, MIME types, parameters) into shell commands. Instead of
  using such text, it will warn and act as if a match was not found (or for
  test commands, as if the test failed).

Core and Builtins
-----------------

- gh-issue-94694: Fix an issue that could cause code with multi-line method
  lookups to have misleading or incorrect column offset information. In some
  cases (when compiling a hand-built AST) this could have resulted in a hard
  crash of the interpreter.

- gh-issue-93252: Fix an issue that caused internal frames to outlive failed
  Python function calls, possibly resulting in memory leaks or hard
  interpreter crashes.

- gh-issue-94215: Fix an issue where exceptions raised by line-tracing
  events would cause frames to be left in an invalid state, possibly
  resulting in a hard crash of the interpreter.

- gh-issue-92228: Disable the compiler's inline-small-exit-blocks
  optimization for exit blocks that are associated with source code lines.
  This fixes a bug where the debugger cannot tell where an exception handler
  ends and the following code block begins.

- gh-issue-94485: Line number of a module's ``RESUME`` instruction is set to
  0 as specified in :pep:`626`.

- gh-issue-94438: Account for instructions that can push NULL to the stack
  when setting line number in a frame. Prevents some (unlikely) crashes.

- gh-issue-91719: Reload ``opcode`` when raising ``unknown opcode error`` in
  the interpreter main loop, for C compilers to generate dispatching code
  independently.

- gh-issue-94329: Compile and run code with unpacking of extremely large
  sequences (1000s of elements). Such code failed to compile. It now
  compiles and runs correctly.

- gh-issue-94360: Fixed a tokenizer crash when reading encoded files with
  syntax errors from ``stdin`` with non utf-8 encoded text. Patch by Pablo
  Galindo

- gh-issue-88116: Fix an issue when reading line numbers from code objects
  if the encoded line numbers are close to ``INT_MIN``. Patch by Pablo
  Galindo

- gh-issue-94262: Don't create frame objects for incomplete frames. Prevents
  the creation of generators and closures from being observable to Python
  and C extensions, restoring the behavior of 3.10 and earlier.

- gh-issue-94192: Fix error for dictionary literals with invalid expression
  as value.

- gh-issue-93883: Revise the display strategy of traceback enhanced error
  locations.  The indicators are only shown when the location doesn't span
  the whole line.

- gh-issue-94021: Fix unreachable code warning in ``Python/specialize.c``.

- gh-issue-93516: Store offset of first traceable instruction in code object
  to avoid having to recompute it for each instruction when tracing.

- gh-issue-93516: Lazily create a table mapping bytecode offsets to line
  numbers to speed up calculation of line numbers when tracing.

- gh-issue-89828: :class:`types.GenericAlias` no longer relays the
  ``__class__`` attribute. For example, ``isinstance(list[int], type)`` no
  longer returns ``True``.

- gh-issue-93671: Fix some exponential backtrace case happening with deeply
  nested sequence patterns in match statements. Patch by Pablo Galindo

- gh-issue-93662: Make sure that the end column offsets are correct in
  multi-line method calls. Previously, the end column could precede the
  column offset.

- gh-issue-93461: :func:`importlib.invalidate_caches` now drops entries from
  :data:`sys.path_importer_cache` with a relative path as name. This solves
  a caching issue when a process changes its current working directory.

  ``FileFinder`` no longer inserts a dot in the path, e.g. ``/egg/./spam``
  is now ``/egg/spam``.

- gh-issue-93418: Fixed an assert where an f-string has an equal sign '='
  following an expression, but there's no trailing brace. For example,
  f"{i=".

- gh-issue-93382: Cache the result of :c:func:`PyCode_GetCode` function to
  restore the O(1) lookup of the :attr:`~types.CodeType.co_code` attribute.

- gh-issue-93354: Use exponential backoff for specialization counters in the
  interpreter. Can reduce the number of failed specializations significantly
  and avoid slowdown for those parts of a program that are not suitable for
  specialization.

- gh-issue-93021: Fix the :attr:`__text_signature__` for :meth:`__get__`
  methods implemented in C. Patch by Jelle Zijlstra.

- gh-issue-92930: Fixed a crash in ``_pickle.c`` from mutating collections
  during ``__reduce__`` or ``persistent_id``.

- gh-issue-92914: Always round the allocated size for lists up to the
  nearest even number.

- gh-issue-92858: Improve error message for some suites with syntax error
  before ':'

- bpo-46142: Make ``--help`` output shorter by moving some info to the new
  ``--help-env`` and ``--help-xoptions`` command-line options. Also add
  ``--help-all`` option to print complete usage.

Library
-------

- gh-issue-94736: Fix crash when deallocating an instance of a subclass of
  ``_multiprocessing.SemLock``. Patch by Kumar Aditya.

- gh-issue-94637: :meth:`SSLContext.set_default_verify_paths` now releases
  the GIL around ``SSL_CTX_set_default_verify_paths`` call. The function
  call performs I/O and CPU intensive work.

- gh-issue-94607: Fix subclassing complex generics with type variables in
  :mod:`typing`. Previously an error message saying ``Some type variables
  ... are not listed in Generic[...]`` was shown. :mod:`typing` no longer
  populates ``__parameters__`` with the ``__parameters__`` of a Python
  class.

- gh-issue-93910: The ability to access the other values of an enum on an
  enum (e.g. ``Color.RED.BLUE``) has been restored in order to fix a
  performance regression.

- gh-issue-93896: Fix :func:`asyncio.run` and
  :class:`unittest.IsolatedAsyncioTestCase` to always the set event loop as
  it was done in Python 3.10 and earlier. Patch by Kumar Aditya.

- gh-issue-94510: Re-entrant calls to :func:`sys.setprofile` and
  :func:`sys.settrace` now raise :exc:`RuntimeError`. Patch by Pablo
  Galindo.

- gh-issue-92336: Fix bug where :meth:`linecache.getline` fails on bad files
  with :exc:`UnicodeDecodeError` or :exc:`SyntaxError`. It now returns an
  empty string as per the documentation.

- gh-issue-94398: Once a :class:`asyncio.TaskGroup` has started shutting
  down (i.e., at least one task has failed and the task group has started
  cancelling the remaining tasks), it should not be possible to add new
  tasks to the task group.

- gh-issue-94254: Fixed types of :mod:`struct` module to be immutable. Patch
  by Kumar Aditya.

- gh-issue-94207: Made :class:`_struct.Struct` GC-tracked in order to fix a
  reference leak in the :mod:`_struct` module.

- gh-issue-91742: Fix :mod:`pdb` crash after jump caused by a null pointer
  dereference. Patch by Kumar Aditya.

- gh-issue-94101: Manual instantiation of :class:`ssl.SSLSession` objects is
  no longer allowed as it lead to misconfigured instances that crashed the
  interpreter when attributes where accessed on them.

- gh-issue-84753: :func:`inspect.iscoroutinefunction`,
  :func:`inspect.isgeneratorfunction`, and
  :func:`inspect.isasyncgenfunction` now properly return ``True`` for
  duck-typed function-like objects like instances of
  :class:`unittest.mock.AsyncMock`.

  This makes :func:`inspect.iscoroutinefunction` consistent with the
  behavior of :func:`asyncio.iscoroutinefunction`.  Patch by Mehdi ABAAKOUK.

- gh-issue-94028: Fix a regression in the :mod:`sqlite3` where statement
  objects were not properly cleared and reset after use in cursor iters. The
  regression was introduced by PR 27884 in Python 3.11a1. Patch by Erlend E.
  Aasland.

- gh-issue-93820: Pickle :class:`enum.Flag` by name.

- gh-issue-93847: Fix repr of enum of generic aliases.

- gh-issue-91404: Revert the :mod:`re` memory leak when a match is
  terminated by a signal or memory allocation failure as the implemented fix
  caused a major performance regression.

- gh-issue-83499: Fix double closing of file description in :mod:`tempfile`.

- gh-issue-93820: Fixed a regression when :func:`copy.copy`-ing
  :class:`enum.Flag` with multiple flag members.

- gh-issue-79512: Fixed names and ``__module__`` value of :mod:`weakref`
  classes :class:`~weakref.ReferenceType`, :class:`~weakref.ProxyType`,
  :class:`~weakref.CallableProxyType`. It makes them pickleable.

- gh-issue-91389: Fix an issue where :mod:`dis` utilities could report
  missing or incorrect position information in the presence of ``CACHE``
  entries.

- gh-issue-93626: Set ``__future__.annotations`` to have a ``None``
  mandatoryRelease to indicate that it is currently 'TBD'.

- gh-issue-90473: Emscripten and WASI have no home directory and cannot
  provide :pep:`370` user site directory.

- gh-issue-90494: :func:`copy.copy` and :func:`copy.deepcopy` now always
  raise a TypeError if ``__reduce__()`` returns a tuple with length 6
  instead of silently ignore the 6th item or produce incorrect result.

- gh-issue-90549: Fix a multiprocessing bug where a global named resource
  (such as a semaphore) could leak when a child process is spawned (as
  opposed to forked).

- gh-issue-93521: Fixed a case where dataclasses would try to add
  ``__weakref__`` into the ``__slots__`` for a dataclass that specified
  ``weakref_slot=True`` when it was already defined in one of its bases.
  This resulted in a ``TypeError`` upon the new class being created.

- gh-issue-79579: :mod:`sqlite3` now correctly detects DML queries with
  leading comments. Patch by Erlend E. Aasland.

- gh-issue-93421: Update :data:`sqlite3.Cursor.rowcount` when a DML
  statement has run to completion. This fixes the row count for SQL queries
  like ``UPDATE ... RETURNING``. Patch by Erlend E. Aasland.

- gh-issue-91162: Support splitting of unpacked arbitrary-length tuple over
  ``TypeVar`` and ``TypeVarTuple`` parameters. For example:

  * ``A[T, *Ts][*tuple[int, ...]]`` -> ``A[int, *tuple[int, ...]]``
  * ``A[*Ts, T][*tuple[int, ...]]`` -> ``A[*tuple[int, ...], int]``

- gh-issue-93353: Fix the :func:`importlib.resources.as_file` context
  manager to remove the temporary file if destroyed late during Python
  finalization: keep a local reference to the :func:`os.remove` function.
  Patch by Victor Stinner.

- gh-issue-83658: Make :class:`multiprocessing.Pool` raise an exception if
  ``maxtasksperchild`` is not ``None`` or a positive int.

- gh-issue-93156: Accessing the :attr:`pathlib.PurePath.parents` sequence of
  an absolute path using negative index values produced incorrect results.

- gh-issue-74696: :func:`shutil.make_archive` no longer temporarily changes
  the current working directory during creation of standard ``.zip`` or tar
  archives.

- gh-issue-89973: Fix :exc:`re.error` raised in :mod:`fnmatch` if the
  pattern contains a character range with upper bound lower than lower bound
  (e.g. ``[c-a]``). Now such ranges are interpreted as empty ranges.

- gh-issue-92932: Now :func:`~dis.dis` and :func:`~dis.get_instructions`
  handle operand values for instructions prefixed by ``EXTENDED_ARG_QUICK``.
  Patch by Sam Gross and Dong-hee Na.

- gh-issue-91577: Move imports in :class:`~multiprocessing.SharedMemory`
  methods to module level so that they can be executed late in python
  finalization.

- gh-issue-91456: Deprecate current default auto() behavior:  In 3.13 the
  default will be for for auto() to always return the largest member value
  incremented by 1, and to raise if incompatible value types are used.

- bpo-47231: Fixed an issue with inconsistent trailing slashes in tarfile
  longname directories.

- bpo-46755: In :class:`QueueHandler`, clear ``stack_info`` from
  :class:`LogRecord` to prevent stack trace from being written twice.

- bpo-46197: Fix :mod:`ensurepip` environment isolation for subprocess
  running ``pip``.

- bpo-45924: Fix :mod:`asyncio` incorrect traceback when future's exception
  is raised multiple times. Patch by Kumar Aditya.

- bpo-34828: :meth:`sqlite3.Connection.iterdump` now handles databases that
  use ``AUTOINCREMENT`` in one or more tables.

Documentation
-------------

- gh-issue-94321: Document the :pep:`246` style protocol type
  :class:`sqlite3.PrepareProtocol`.

- gh-issue-61162: Clarify :mod:`sqlite3` behavior when
  :ref:`sqlite3-connection-context-manager`.

- gh-issue-87260: Align :mod:`sqlite3` argument specs with the actual
  implementation.

- gh-issue-86986: The minimum Sphinx version required to build the
  documentation is now 3.2.

- gh-issue-88831: Augmented documentation of asyncio.create_task().
  Clarified the need to keep strong references to tasks and added a code
  snippet detailing how to to this.

- bpo-47161: Document that :class:`pathlib.PurePath` does not collapse
  initial double slashes because they denote UNC paths.

Tests
-----

- gh-issue-91330: Added more tests for :mod:`dataclasses` to cover behavior
  with data descriptor-based fields.

- gh-issue-94208: ``test_ssl`` is now checking for supported TLS version and
  protocols in more tests.

- gh-issue-94315: Tests now check for DAC override capability instead of
  relying on :func:`os.geteuid`.

- gh-issue-93951: In test_bdb.StateTestCase.test_skip, avoid including
  auxiliary importers.

- gh-issue-93957: Provide nicer error reporting from subprocesses in
  test_venv.EnsurePipTest.test_with_pip.

- gh-issue-84461: ``run_tests.py`` now handles cross compiling env vars
  correctly and pass ``HOSTRUNNER`` to regression tests.

- gh-issue-93616: ``test_modulefinder`` now creates a temporary directory in
  ``ModuleFinderTest.setUp()`` instead of module scope.

- gh-issue-93575: Fix issue with test_unicode test_raiseMemError. The test
  case now use ``test.support.calcobjsize`` to calculate size of PyUnicode
  structs. :func:`sys.getsizeof` may return different size when string has
  UTF-8 memory.

- gh-issue-90473: WASI does not have a ``chmod(2)`` syscall.
  :func:`os.chmod` is now a dummy function on WASI. Skip all tests that
  depend on working :func:`os.chmod`.

- gh-issue-90473: Skip tests on WASI that require symlinks with absolute
  paths.

- gh-issue-57539: Increase calendar test coverage for
  :meth:`calendar.LocaleTextCalendar.formatweekday`.

- gh-issue-90473: Skip symlink tests on WASI. wasmtime uses ``openat2(2)``
  with ``RESOLVE_BENEATH`` flag, which prevents symlinks with absolute
  paths.

- gh-issue-89858: Fix ``test_embed`` for out-of-tree builds. Patch by Kumar
  Aditya.

- gh-issue-92886: Fixing tests that fail when running with optimizations
  (``-O``) in ``test_imaplib.py``.

- gh-issue-92886: Fixing tests that fail when running with optimizations
  (``-O``) in ``test_zipimport.py``

- bpo-47016: Create a GitHub Actions workflow for verifying bundled pip and
  setuptools. Patch by Illia Volochii and Adam Turner.

Build
-----

- gh-issue-94404: ``makesetup`` now works around an issue with sed on macOS
  and uses correct CFLAGS for object files that end up in a shared
  extension. Module CFLAGS are used before PY_STDMODULE_CFLAGS to avoid
  clashes with system headers.

- gh-issue-93584: Address race condition in ``Makefile`` when installing a
  PGO build. All ``test`` and ``install`` targets now depend on ``all``
  target.

- gh-issue-93491: ``configure`` now detects and reports :pep:`11` support
  tiers.

Windows
-------

- gh-issue-93824: Drag and drop of files onto Python files in Windows
  Explorer has been enabled for Windows ARM64.

- bpo-42658: Support native Windows case-insensitive path comparisons by
  using ``LCMapStringEx`` instead of :func:`str.lower` in
  :func:`ntpath.normcase`. Add ``LCMapStringEx`` to the :mod:`_winapi`
  module.

Tools/Demos
-----------

- gh-issue-94538: Fix Argument Clinic output to custom file destinations.
  Patch by Erlend E. Aasland.

- gh-issue-94430: Allow parameters named ``module`` and ``self`` with custom
  C names in Argument Clinic. Patch by Erlend E. Aasland

C API
-----

- gh-issue-93937: The following frame functions and type are now directly
  available with ``#include <Python.h>``, it's no longer needed to add
  ``#include <frameobject.h>``:

  * :c:func:`PyFrame_Check`
  * :c:func:`PyFrame_GetBack`
  * :c:func:`PyFrame_GetBuiltins`
  * :c:func:`PyFrame_GetGenerator`
  * :c:func:`PyFrame_GetGlobals`
  * :c:func:`PyFrame_GetLasti`
  * :c:func:`PyFrame_GetLocals`
  * :c:type:`PyFrame_Type`

  Patch by Victor Stinner.

- gh-issue-91321: Fix the compatibility of the Python C API with C++ older
  than C++11. Patch by Victor Stinner.

- gh-issue-91731: Avoid defining the ``static_assert`` when compiling with
  C++ 11, where this is a keyword and redefining it can lead to undefined
  behavior. Patch by Pablo Galindo

- gh-issue-93442: Add C++ overloads for _Py_CAST_impl() to handle 0/NULL.
  This will allow C++ extensions that pass 0 or NULL to macros using
  _Py_CAST() to continue to compile.


What's New in Python 3.11.0 beta 3?
===================================

*Release date: 2022-06-01*

Core and Builtins
-----------------

- gh-issue-93359: Ensure that custom :mod:`ast` nodes without explicit end
  positions can be compiled. Patch by Pablo Galindo.

- gh-issue-93345: Fix a crash in substitution of a ``TypeVar`` in nested
  generic alias after ``TypeVarTuple``.

Build
-----

- gh-issue-69093: Fix ``Modules/Setup.stdlib.in`` rule for ``_sqlite3``
  extension.


What's New in Python 3.11.0 beta 2?
===================================

*Release date: 2022-05-30*

Core and Builtins
-----------------

- gh-issue-84694: The ``--experimental-isolated-subinterpreters`` configure
  option and ``EXPERIMENTAL_ISOLATED_SUBINTERPRETERS`` macro have been
  removed.

- gh-issue-91924: Fix ``__lltrace__`` debug feature if the stdout encoding
  is not UTF-8. Patch by Victor Stinner.

- gh-issue-93061: Backward jumps after ``async for`` loops are no longer
  given dubious line numbers.

- gh-issue-93065: Fix contextvars HAMT implementation to handle iteration
  over deep trees.

  The bug was discovered and fixed by Eli Libman. See
  `MagicStack/immutables#84
  <https://github.com/MagicStack/immutables/issues/84>`_ for more details.

- gh-issue-90473: Decrease default recursion limit on WASI to address
  limited call stack size.

- gh-issue-92804: Fix memory leak in ``memoryview`` iterator as it was not
  finalized at exit. Patch by Kumar Aditya.

- gh-issue-92236: Remove spurious "LINE" event when starting a generator or
  coroutine, visible tracing functions implemented in C.

- gh-issue-92619: Make the compiler duplicate an exit block only if none of
  its instructions have a lineno (previously only the first instruction in
  the block was checked, leading to unnecessarily duplicated blocks).

- gh-issue-92261: Fix hang when trying to iterate over a ``typing.Union``.

Library
-------

- gh-issue-93297: Make asyncio task groups prevent child tasks from being
  GCed

- gh-issue-90817: The :func:`locale.resetlocale` function is deprecated and
  will be removed in Python 3.13. Use ``locale.setlocale(locale.LC_ALL,
  "")`` instead. Patch by Victor Stinner.

- gh-issue-92728: The :func:`re.template` function and the corresponding
  :const:`re.TEMPLATE` and :const:`re.T` flags are restored after they were
  removed in 3.11.0b1, but they are now deprecated, so they might be removed
  from Python 3.13.

- gh-issue-93044: No longer convert the database argument of
  :func:`sqlite3.connect` to bytes before passing it to the factory.

- gh-issue-93010: In a very special case, the email package tried to append
  the nonexistent ``InvalidHeaderError`` to the defect list. It should have
  been ``InvalidHeaderDefect``.

- gh-issue-92675: Fix :func:`venv.ensure_directories` to accept
  :class:`pathlib.Path` arguments in addition to :class:`str` paths. Patch
  by David Foster.

- gh-issue-87901: Removed the ``encoding`` argument from :func:`os.popen`
  that was added in 3.11b1.

- gh-issue-91922: Fix function :func:`sqlite.connect` and the
  :class:`sqlite.Connection` constructor on non-UTF-8 locales. Also, they
  now support bytes paths non-decodable with the current FS encoding.

- gh-issue-92839: Fixed crash resulting from calling bisect.insort() or
  bisect.insort_left() with the key argument not equal to None.

- gh-issue-90473: :mod:`subprocess` now fails early on Emscripten and WASI
  platforms to work around missing :func:`os.pipe` on WASI.

- gh-issue-92671: Fixed :func:`ast.unparse` for empty tuples in the
  assignment target context.

- gh-issue-91581: :meth:`~datetime.datetime.utcfromtimestamp` no longer
  attempts to resolve ``fold`` in the pure Python implementation, since the
  fold is never 1 in UTC. In addition to being slightly faster in the common
  case, this also prevents some errors when the timestamp is close to
  :attr:`datetime.min <datetime.datetime.min>`.  Patch by Paul Ganssle.

- gh-issue-92550: Fix :meth:`pathlib.Path.rglob` for empty pattern.

- gh-issue-92530: Fix an issue that occurred after interrupting
  :func:`threading.Condition.notify`.

- gh-issue-92531: The statistics.median_grouped() function now always return
  a float. Formerly, it did not convert the input type when for sequences of
  length one.

- gh-issue-91810: :class:`~xml.etree.ElementTree.ElementTree` method
  :meth:`~xml.etree.ElementTree.ElementTree.write` and function
  :func:`~xml.etree.ElementTree.tostring` now use the text file's encoding
  ("UTF-8" if not available) instead of locale encoding in XML declaration
  when ``encoding="unicode"`` is specified.

- gh-issue-90622: Worker processes for
  :class:`concurrent.futures.ProcessPoolExecutor` are no longer spawned on
  demand (a feature added in 3.9) when the multiprocessing context start
  method is ``"fork"`` as that can lead to deadlocks in the child processes
  due to a fork happening while threads are running.

- gh-issue-91581: Remove an unhandled error case in the C implementation of
  calls to :meth:`datetime.fromtimestamp <datetime.datetime.fromtimestamp>`
  with no time zone (i.e. getting a local time from an epoch timestamp).
  This should have no user-facing effect other than giving a possibly more
  accurate error message when called with timestamps that fall on
  10000-01-01 in the local time. Patch by Paul Ganssle.

- bpo-39064: :class:`zipfile.ZipFile` now raises :exc:`zipfile.BadZipFile`
  instead of ``ValueError`` when reading a corrupt zip file in which the
  central directory offset is negative.

- bpo-45393: Fix the formatting for ``await x`` and ``not x`` in the
  operator precedence table when using the :func:`help` system.

- bpo-28249: Set :attr:`doctest.DocTest.lineno` to ``None`` when object does
  not have :attr:`__doc__`.

- bpo-45046: Add support of context managers in :mod:`unittest`: methods
  :meth:`~unittest.TestCase.enterContext` and
  :meth:`~unittest.TestCase.enterClassContext` of class
  :class:`~unittest.TestCase`, method
  :meth:`~unittest.IsolatedAsyncioTestCase.enterAsyncContext` of class
  :class:`~unittest.IsolatedAsyncioTestCase` and function
  :func:`unittest.enterModuleContext`.

- bpo-42627: Fix incorrect parsing of Windows registry proxy settings

Documentation
-------------

- gh-issue-86438: Clarify that :option:`-W` and :envvar:`PYTHONWARNINGS` are
  matched literally and case-insensitively, rather than as regular
  expressions, in :mod:`warnings`.

- gh-issue-92240: Added release dates for "What's New in Python 3.X" for
  3.0, 3.1, 3.2, 3.8 and 3.10

- bpo-40838: Document that :func:`inspect.getdoc`,
  :func:`inspect.getmodule`, and :func:`inspect.getsourcefile` might return
  ``None``.

- bpo-38056: Overhaul the :ref:`error-handlers` documentation in
  :mod:`codecs`.

- bpo-13553: Document tkinter.Tk args.

Tests
-----

- gh-issue-92670: Skip
  ``test_shutil.TestCopy.test_copyfile_nonexistent_dir`` test on AIX as