O que há de novo no Python 3.15
*******************************

Editor:
   Hugo van Kemenade

Esse artigo explica os novos recursos no Python 3.15, em comparação
com o 3.14.

Para detalhes completos, veja o changelog.

Nota:

  Os usuários de pré-lançamento devem estar cientes de que este
  documento está atualmente em forma de rascunho. Ele será atualizado
  substancialmente à medida que o Python 3.15 caminha para seu
  lançamento estável, portanto vale a pena conferir mesmo depois de
  ler as versões anteriores.


Resumo -- Destaques da versão
=============================

* **PEP 810**: Importações preguiçosas explícitas para tempos de
  inicialização mais rápidos

* **PEP 814**: Adiciona o tipo embutido frozendict

* **PEP 661**: Adiciona o tipo embutido sentinela

* **PEP 799**: Um pacote de perfilamento dedicado para organizar as
  ferramentas de perfilamento do Python

* **PEP 799**: Tachyon: Perfilador de amostragem estatística de alta
  frequência

* **PEP 831**: Ponteiros de quadro estão habilitados por padrão para
  melhorar a observabilidade em nível de sistema

* **PEP 798**: Desempacotamento em compreensões

* **PEP 686**: Python agora usa UTF-8 como codificação padrão

* **PEP 829**: Arquivos de configuração de inicialização de pacote

* **PEP 728**: TypedDict com itens extras tipados

* **PEP 747**: Anotando formulários de tipo com TypeForm

* **PEP 800**: Bases disjuntas no sistema de tipos

* **PEP 782**: Uma nova API C PyBytesWriter para criar um objeto bytes
  Python

* **PEP 803**, **820**, **793**: ABI estável para construções com
  threads livres e APIs C relacionadas

* **PEP 788**: Proteção contra finalização na API C

* O compilador JIT foi melhorado de forma significativa

* Os binários oficiais do Windows 64 bit agora usam um interpretador
  de chamada de cauda

* Mensagens de erro melhoradas

* Mais cores


Novas funcionalidades
=====================


**PEP 810**: Importações preguiçosas explícitas
-----------------------------------------------

Aplicações Python de grande porte frequentemente sofrem com tempos de
inicialização lentos. Um fator significativo que contribui para esse
problema é o sistema de importação: quando um módulo é importado, o
Python precisa localizar o arquivo, lê-lo do disco, compilá-lo para
bytecode e executar todo o código de nível superior. Para aplicações
com árvores de dependências complexas, esse processo pode levar
segundos, mesmo quando a maior parte do código importado nunca é
efetivamente utilizada durante uma execução específica.

Os desenvolvedores contornaram esse problema movendo as importações
para dentro de funções, usando "importlib" para carregar módulos sob
demanda ou reestruturando o código para evitar dependências
desnecessárias. Essas abordagens funcionam, mas tornam o código mais
difícil de ler e manter, espalham as instruções de importação por toda
a base de código e exigem disciplina para serem aplicadas de forma
consistente.

O Python agora oferece uma solução mais limpa por meio de importações
"lazy" explícitas, usando a nova palavra reservada contextual "lazy"
("preguiçosa"). Quando você marca uma importação como preguiçosa, o
Python adia o carregamento do módulo até que o nome importado seja
usado pela primeira vez. Isso oferece os benefícios de organização de
declarar todas as importações no início do arquivo, pagando o custo de
carregamento apenas pelos módulos que você realmente usa.

A palavra reservada "lazy" funciona tanto com instruções "import"
quanto com instruções "from ... import". Quando você escreve "lazy
import módulo_pesado", o Python não carrega o módulo imediatamente. Em
vez disso, ele cria um objeto intermediário leve. O carregamento real
do módulo ocorre de forma transparente quando você acessa o nome pela
primeira vez:

   lazy import json
   lazy from pathlib import Path

   print("Inicializando...")  # json e pathlib não carregados ainda

   data = json.loads('{"key": "value"}')  # json é carregado aqui
   p = Path(".")  # pathlib é carregado aqui

Esse mecanismo é particularmente útil para aplicações que importam
muitos módulos no nível superior, mas que podem usar apenas um
subconjunto deles em uma determinada execução. O carregamento diferido
reduz a latência de inicialização sem exigir reestruturação do código
ou importações condicionais espalhadas por toda a base de código.

Caso o carregamento de um módulo importado "preguiçosamente" falhe
(por exemplo, se o módulo não existir), o Python levanta a exceção no
momento do primeiro uso, e não no momento da importação. O traceback
associado inclui tanto o local onde o nome foi acessado quanto a
instrução de importação original, facilitando o diagnóstico e a
depuração da falha.

Para casos em que você deseja habilitar o carregamento preguiçoso
globalmente sem modificar o código-fonte, o Python fornece a opção de
linha de comando "-X lazy_imports" e a variável de ambiente
"PYTHON_LAZY_IMPORTS". Ambas aceitam três valores: "all" torna todas
as importações preguiçosas por padrão, "none" desabilita completamente
as importações preguiçosas (mesmo instruções "lazy" explícitas se
tornam imediatas) e "normal" (o padrão) respeita a palavra reservada
"lazy" no código-fonte. As funções "sys.set_lazy_imports()" e
"sys.get_lazy_imports()" permitem alterar e consultar esse modo em
tempo de execução.

Para um controle mais seletivo, "sys.set_lazy_imports_filter()" aceita
um chamável que determina se um módulo específico deve ser carregado
preguiçosamente. O filtro recebe três argumentos: o nome do módulo a
ser importado (ou "None"), o nome do módulo importado e a lista "from"
(ou "None" para importações regulares). Ele deve retornar "True" para
permitir que a importação seja preguiçosa ou "False" para forçar o
carregamento imediato. Isso permite padrões como fazer com que apenas
os módulos da sua própria aplicação sejam carregados preguiçosamente,
enquanto mantém as dependências de terceiros sendo carregadas
imediatamente.

   import sys

   def filtro_do_meuapp(importing, imported, fromlist):
       return imported.startswith("meuapp.")
   sys.set_lazy_imports_filter(filtro_do_meuapp)
   sys.set_lazy_imports("all")

   import meuapp.slow_module  # preguiçoso (corresponde ao filtro)
   import json               # imediato (não corresponde ao filtro)

O próprio tipo proxy está disponível como "types.LazyImportType" para
código que precisa detectar importações preguiçosas programaticamente.

Existem algumas restrições quanto ao uso da palavra reservada "lazy".
Importações preguiçosas são permitidas apenas no escopo do módulo;
usar "lazy" dentro de uma função, corpo da classe ou bloco
"try"/"except"/"finally" levanta "SyntaxError". Importações com
asterisco e importações de future não pode ser preguiçosas ("lazy from
module import *" e "lazy from __future__ import ..." levantam
"SyntaxError").

Para código que não pode usar a palavra reservada "lazy" diretamente
(por exemplo, ao dar suporte a versões do Python anteriores à 3.15,
mas ainda usar importações preguiçosas na versão 3.15 ou superior), um
módulo pode definir "__lazy_modules__" como um contêiner de strings
com nomes de módulos totalmente qualificados. As instruções "import"
regulares para esses módulos são então tratadas como preguiçosas, com
a mesma semântica da palavra reservada "lazy".

   __lazy_modules__ = ["json", "pathlib"]

   import json     # preguiçosa
   import os       # ainda imediato

Ver também: **PEP 810** para a especificação completa e justificativa.

(Contribuição de Pablo Galindo Salgado e Dino Viehland em gh-142349.)


**PEP 814**: Adiciona o tipo embutido frozendict
------------------------------------------------

Um novo tipo *imutável*, "frozendict", foi adicionado ao módulo
"builtins". Ele não permite modificações após a criação. Um
"frozendict" não é uma subclasse de "dict"; ele herda diretamente de
"object". Um "frozendict" é *hasheável* desde que todas as suas chaves
e valores sejam hasheáveis. Um "frozendict" preserva a ordem de
inserção, mas a comparação não leva a ordem em consideração.

Por exemplo:

   >>> a = frozendict(x=1, y=2)
   >>> a
   frozendict({'x': 1, 'y': 2})
   >>> a['z'] = 3
   Traceback (most recent call last):
     File "<python-input-2>", line 1, in <module>
       a['z'] = 3
       ~^^^^^
   TypeError: 'frozendict' object does not support item assignment
   >>> b = frozendict(y=2, x=1)
   >>> hash(a) == hash(b)
   True
   >>> a == b
   True

Os seguintes módulos da biblioteca padrão foram atualizados para
aceitar "frozendict": "copy", "decimal", "json", "marshal", "plistlib"
(somente para serialização), "pickle", "pprint" e
"xml.etree.ElementTree".

"eval()" e "exec()" aceitam "frozendict" para *globals*, e "type()" e
"str.maketrans()" aceitam "frozendict" para *dict*.

Verificação de código para o tipo "dict" usando "isinstance(arg,
dict)" pode ser atualizado para "isinstance(arg, (dict, frozendict))"
para aceitar também o tipo "frozendict", ou para "isinstance(arg,
collections.abc.Mapping)" aceitar também outros tipos de mapeamentos
como "MappingProxyType".

Ver também: **PEP 814** para a especificação completa e justificativa.

(Contribuição de Victor Stinner e Donghee Na em gh-141510.)


**PEP 661**: Adiciona o tipo embutido sentinela
-----------------------------------------------

Um novo tipo "sentinel" foi adicionado ao módulo "builtins" para criar
valores sentinela únicos com uma representação concisa. Objetos
sentinela preservam a identidade quando copiados, suportam uso em
expressões de tipo com o operador "|" e podem ser serializados com
pickle quando são importáveis ​​por módulo e nome.

(PEP por Tal Einat; contribuição de Jelle Zijlstra em gh-148829.)

Ver também: **PEP 661** para mais detalhes.


**PEP 799**: Um pacote de perfilamento dedicado
-----------------------------------------------

Um novo módulo "profiling" foi adicionado para organizar as
ferramentas embutidas do Python para perfilamento em um único espaço
de nomes coerente. Este módulo contém:

* "profiling.tracing": rastreamento determinístico de chamada de
  função (realocado de "cProfile").

* "profiling.sampling": um novo perfilador de amostragem estatística
  (chamado Tachyon).

O módulo "cProfile" permanece como um apelido para fins de
retrocompatibilidade. O módulo "profile" está descontinuado e será
removido no Python 3.17.

Ver também: **PEP 799** para mais detalhes.

(Contribuição de Pablo Galindo e László Kiss Kollár em gh-138122.)


Tachyon: Perfilador de amostragem estatística de alta frequência
----------------------------------------------------------------

[imagem: Logo do perfilador Tachyon][imagem]

Um novo perfilador de amostragem estatística (Tachyon) foi adicionado
como "profiling.sampling". Este perfilador permite a análise de
desempenho com baixa sobrecarga de processos Python em execução, sem
exigir modificação de código ou reinicialização do processo.

Ao contrário dos perfiladores determinísticos (como o
"profiling.tracing") que instrumentam cada chamada de função, o
perfilador de amostragem captura periodicamente os rastreamentos de
pilha dos processos em execução. Essa abordagem oferece sobrecarga
praticamente zero, ao mesmo tempo que atinge taxas de amostragem de
**até 1.000.000 Hz**, tornando-o o perfilador de amostragem mais
rápido disponível para Python (na época de sua contribuição) e ideal
para depurar problemas de desempenho em ambientes de produção. Essa
capacidade é particularmente valiosa para depurar problemas de
desempenho em sistemas de produção, onde as abordagens de perfilamento
tradicionais seriam muito intrusivas.

Recursos chave incluem:

* **Perfilamento de sobrecarga zero**: Conecte-se a qualquer processo
  Python em execução sem afetar seu desempenho. Ideal para depuração
  em produção, onde você não pode se dar ao luxo de reiniciar ou
  tornar sua aplicação mais lenta.

* **Nenhuma modificação de código necessária**: Crie perfis de
  aplicações existentes sem reiniciá-las. Basta apontar o perfilador
  para um processo em execução pelo PID e começar a coletar dados.

* **Modos de alvos flexíveis**:

  * Perfile processos em execução por PID ("attach") - anexar a
    aplicações já em execução

  * Execute e analise scripts diretamente ("run") - analise desde o
    início da execução.

  * Execute e perfile módulos ("run -m") - perfile pacotes executados
    como "python -m module"

  * Captura um snapshot único de um processo em execução ("dump") -
    imprime uma pilha no estilo traceback de cada thread (ou de todas
    as tarefas asyncio com "--async-aware"). Útil para investigar
    processos travados.

* **Múltiplos modos de perfilamento**: Escolha o que medir com base na
  sua investigação de desempenho:

  * **Tempo real** ("--mode wall", padrão): Mede o tempo real
    decorrido, incluindo E/S, esperas de rede e operações de bloqueio.
    Use isso para entender onde seu programa gasta tempo, inclusive
    quando está aguardando recursos externos.

  * **Tempo de CPU** ("--mode cpu"): Mede apenas o tempo de execução
    ativo da CPU, excluindo esperas de E/S e bloqueios. Use isso para
    identificar gargalos que consomem muita CPU e otimizar o trabalho
    computacional.

  * **Tempo de retenção da GIL** ("--mode gil"): Mede o tempo gasto
    mantendo a trava global do interpretador (Global Interpreter Lock
    - GIL) do Python em uso. Use isso para identificar quais threads
    dominam o uso da GIL em aplicações multithread.

  * **Tempo de tratamento de exceções** ("--mode exception"): Captura
    amostras apenas de threads com uma exceção ativa. Use isso para
    analisar a sobrecarga do tratamento de exceções.

* **Perfilamento consciente de threads**: Opção para criar perfil de
  todas as threads ("-a") ou apenas da thread principal, essencial
  para entender o comportamento de aplicações multithread.

* **Múltiplos formatos de saída**: Escolha a visualização que melhor
  se adapta ao seu fluxo de trabalho:

  * "--pstats": Estatísticas tabulares detalhadas compatíveis com
    "pstats". Mostra o tempo de execução em nível de função com
    amostras diretas e cumulativas. Ideal para análises detalhadas e
    integração com ferramentas de perfilamento Python existentes.

  * "--collapsed": Gera stack trace recolhidos (uma linha por pilha).
    Este formato foi especificamente projetado para a criação de flame
    graphs com ferramentas externas como os scripts FlameGraph de
    Brendan Gregg ou o SpeedScope.

  * "--flamegraph": Gera um flame graph HTML interativo e independente
    usando D3.js. Abre diretamente no seu navegador para análise
    visual imediata. Os flame graphs mostram a hierarquia de chamadas,
    onde a largura representa o tempo gasto, facilitando a
    identificação de gargalos rapidamente.

  * "--gecko": Gera um formato do Gecko Profiler compatível com o
    Firefox Profiler. Envie a saída para o Firefox Profiler para uma
    análise avançada baseada em linha do tempo com recursos como
    gráficos de pilha, marcadores e atividade de rede.

  * "--heatmap": Gera uma visualização interativa de mapa de calor em
    HTML com contagens de amostras em nível de linha. Cria um
    diretório com mapas de calor por arquivo, mostrando exatamente
    onde o tempo é gasto no nível do código-fonte.

* **Modo interativo ao vivo**: TUI de perfilador em tempo real com uma
  interface semelhante ao top ("--live"). Monitore o desempenho da sua
  aplicação enquanto ela está em execução, com classificação e
  filtragem interativas.

* **Perfilamento com reconhecimento de assincronismo**: Cria perfis de
  código assíncrono/await com reconstrução de pilha baseada em tarefas
  ("--async-aware"). Veja quais corrotinas estão consumindo tempo, com
  opções para mostrar apenas as tarefas em execução ou todas as
  tarefas, incluindo as que estão aguardando.

* **Perfilamento em nível de opcode**: Coleta informações de opcode de
  bytecode para perfilamento em nível de instrução ("--opcodes").
  Mostra quais instruções de bytecode estão sendo executadas,
  incluindo especializações do interpretador adaptativo.

Consulte "profiling.sampling" para obter a documentação completa,
incluindo todos os formatos de saída disponíveis, modos de criação de
perfil e opções de configuração.

(Contribuição de Pablo Galindo e László Kiss Kollár em gh-135953 e
gh-138122.)


**PEP 831**: Ponteiros de quadros habilitados por padrão
--------------------------------------------------------

O CPython agora é construído com ponteiros de quadro por padrão em
plataformas que os suportam. Isso utiliza os sinalizadores de
compilação "-fno-omit-frame-pointer" e "-mno-omit-leaf-frame-pointer",
tornando o desenrolamento da pilha nativa mais rápido e confiável para
perfiladores de sistema, depuradores, ferramentas de análise de falhas
e ferramentas de observabilidade baseadas em eBPF.

Os sinalizadores são expostas através do "sysconfig", portanto,
módulos de extensão criados por ferramentas que consomem a
configuração de compilação do Python herdam ponteiros de quadro por
padrão. Essa propagação é intencional: o perfilamento misto de
Python/nativo requer uma cadeia ininterrupta de ponteiros de quadro
através do interpretador, módulos de extensão, aplicações incorporadas
e bibliotecas nativas.

Importante:

  Backends de construção de terceiros e sistemas de construção nativos
  devem preservar esses sinalizadores ao consumirem os valores de
  "sysconfig" do Python. Sistemas de construção que compilam código C,
  C++, Rust ou outros códigos nativos sem herdar os sinalizadores do
  compilador Python devem habilitar sinalizadores equivalentes de
  ponteiro de quadro. Um único componente nativo compilado sem
  ponteiros de quadro pode interromper o desenrolamento da pilha para
  todo o processo Python.

(Contribuição de Pablo Galindo Salgado e Savannah Ostrowski em
gh-149201; PEP 831 escrita por Pablo Galindo Salgado, Ken Jin,
Savannah Ostrowski e Diego Russo.)

Ver também: **PEP 831** para mais detalhes.


**PEP 798**: Desempacotamento em compreensões
---------------------------------------------

List, set, and dictionary comprehensions, as well as generator
expressions, now support unpacking with "*" and "**".  This extends
the unpacking syntax from **PEP 448** to comprehensions, providing a
new syntax for combining an arbitrary number of iterables or
dictionaries into a single flat structure. This new syntax is a direct
alternative to nested comprehensions, "itertools.chain()", and
"itertools.chain.from_iterable()".  For example:

   >>> lists = [[1, 2], [3, 4], [5]]
   >>> [*L for L in lists]  # equivalent to [x for L in lists for x in L]
   [1, 2, 3, 4, 5]

   >>> sets = [{1, 2}, {2, 3}, {3, 4}]
   >>> {*s for s in sets}  # equivalent to {x for s in sets for x in s}
   {1, 2, 3, 4}

   >>> dicts = [{'a': 1}, {'b': 2}, {'a': 3}]
   >>> {**d for d in dicts}  # equivalent to {k: v for d in dicts for k,v in d.items()}
   {'a': 3, 'b': 2}

Generator expressions can similarly use unpacking to yield values from
multiple iterables:

   >>> gen = (*L for L in lists)  # equivalent to (x for L in lists for x in L)
   >>> list(gen)
   [1, 2, 3, 4, 5]

This change also extends to asynchronous generator expressions, such
that, for example, "(*a async for a in agen())" is equivalent to "(x
async for a in agen() for x in a)".

Ver também: **PEP 798** for further details.

(Contributed by Adam Hartz in gh-143055.)


**PEP 829**: Package startup configuration files
------------------------------------------------

Loaded by the "site" module when "-S" is not given, .pth files can
contain lines that both extend "sys.path" and execute arbitrary code
when the line starts with "import" (followed by a space or tab).  The
latter functionality can be problematic, since it is difficult to know
exactly what gets executed when Python starts up.

As a step towards improving the ability to audit pre-start executable
code, Python 3.15 introduces .start files which contain entry point
specifications of the form "pkg.mod:callable" where "pkg.mod" is the
import path to the given callable.  When Python starts up, the
callable is located and called with no arguments.

"import" lines in ".pth" files are silently deprecated.  When a
matching ".start" file is found, "import" lines in ".pth" files are
ignored.  There is no change to "sys.path" extension lines in ".pth"
files.

(Contributed by Barry Warsaw in gh-148641.)


**PEP 803** -- Stable ABI for free-threaded builds
--------------------------------------------------

C extensions that target the Stable ABI can now be compiled for the
new *Stable ABI for Free-Threaded Builds* (also known as "abi3t"),
which makes them compatible with *free-threaded builds* of CPython.
This usually requires some non-trivial changes to the source code;
specifically:

* Switching to API introduced in **PEP 697** (Python 3.12), such as
  negative "basicsize" and "PyObject_GetTypeData()", rather than
  making "PyObject" part of the instance struct; and

* Switching from a "PyInit_" function to a new export hook,
  "PyModExport_*", introduced for this purpose in **PEP 793**, with a
  new "PySlot" structure introduced in **PEP 820**.

The reference documentation for these features is complete, but
currently aimed at early adopters. A migration guide is planned for an
upcoming beta release.

Note that Stable ABI does not offer all the functionality that CPython
has to offer. Extensions that cannot switch to "abi3t" should continue
to build for the existing Stable ABI ("abi3") and the version-specific
ABI for free-threading ("cp315t") separately.

Stable ABI for Free-Threaded Builds should typically be selected in a
build tool (such as, for example, Setuptools, meson-python, scikit-
build-core, or Maturin). At the time of writing, these tools did
**not** support "abi3t". If this is the case for your tool, compile
for "cp315t" separately. If not using a build tool -- or when writing
such a tool -- you can select "abi3t" by setting the macro
"Py_TARGET_ABI3T" as discussed in Compiling for Stable ABI.

Ver também: **PEP 803** for further details.


**PEP 788**: Protecting the C API from interpreter finalization
---------------------------------------------------------------

In the C API, *interpreter finalization* can be problematic for many
extensions, because *attaching* a thread state will permanently hang
the thread, resulting in deadlocks and other spurious issues.
Additionally, it has historically been impossible to safely check
whether an interpreter is alive before using it, leading to crashes
when a thread concurrently deletes an interpreter while another thread
is trying to attach to it.

There are now several new suites of APIs to circumvent these problems:

* Interpreter guards, which prevent an interpreter from finalizing.

* Interpreter views, which allow thread-safe access to an interpreter
  that may be concurrently finalizing or deleted.

* New APIs to automatically attach and detach thread states that come
  with built-in protection against finalization.

In addition, APIs in the "PyGILState" family (most notably
"PyGILState_Ensure()" and "PyGILState_Release()") have been *soft
deprecated*. There is **no** plan to remove them, and existing code
will continue to work, but there will be no new "PyGILState" APIs in
future versions of Python.

Ver também: **PEP 788** for further details.

(Contributed by Peter Bierma in gh-149101.)


Mensagens de erro melhoradas
----------------------------

* The interpreter now provides more helpful suggestions in
  "AttributeError" exceptions when accessing an attribute on an object
  that does not exist, but a similar attribute is available through
  one of its members.

  For example, if the object has an attribute that itself exposes the
  requested name, the error message will suggest accessing it via that
  inner attribute:

     @dataclass
     class Circle:
        radius: float

        @property
        def area(self) -> float:
           return pi * self.radius**2

     class Container:
        def __init__(self, inner: Circle) -> None:
           self.inner = inner

     circle = Circle(radius=4.0)
     container = Container(circle)
     print(container.area)

  Running this code now produces a clearer suggestion:

     Traceback (most recent call last):
       File "/home/pablogsal/github/python/main/lel.py", line 42, in <module>
         print(container.area)
               ^^^^^^^^^^^^^^
     AttributeError: 'Container' object has no attribute 'area'. Did you mean '.inner.area' instead of '.area'?

* When an "AttributeError" on a builtin type has no close match via
  Levenshtein distance, the error message now checks a static table of
  common method names from other languages (JavaScript, Java, Ruby,
  C#) and suggests the Python equivalent:

     >>> [1, 2, 3].push(4)
     Traceback (most recent call last):
     ...
     AttributeError: 'list' object has no attribute 'push'. Did you mean '.append'?

     >>> 'hello'.toUpperCase()
     Traceback (most recent call last):
     ...
     AttributeError: 'str' object has no attribute 'toUpperCase'. Did you mean '.upper'?

  When the Python equivalent is a language construct rather than a
  method, the hint describes the construct directly:

     >>> {}.put("a", 1)
     Traceback (most recent call last):
     ...
     AttributeError: 'dict' object has no attribute 'put'. Use d[k] = v.

  When a mutable method is called on an immutable type, the hint
  suggests the mutable counterpart:

     >>> (1, 2, 3).append(4)
     Traceback (most recent call last):
     ...
     AttributeError: 'tuple' object has no attribute 'append'. Did you mean to use a 'list' object?

  These hints also work for subclasses of builtin types.

  (Contributed by Matt Van Horn in gh-146406.)

* The interpreter now tries to provide a suggestion when "delattr()"
  fails due to a missing attribute. When an attribute name that
  closely resembles an existing attribute is used, the interpreter
  will suggest the correct attribute name in the error message. For
  example:

     >>> class A:
     ...     pass
     >>> a = A()
     >>> a.abcde = 1
     >>> del a.abcdf
     Traceback (most recent call last):
     ...
     AttributeError: 'A' object has no attribute 'abcdf'. Did you mean: 'abcde'?

  (Contributed by Nikita Sobolev and Pranjal Prajapati in gh-136588.)

* Several error messages incorrectly using the term "argument" have
  been corrected. (Contributed by Stan Ulbrych in gh-133382.)


Outras mudanças na linguagem
============================

* Python now uses UTF-8 as the default encoding, independent of the
  system's environment. This means that I/O operations without an
  explicit encoding, for example, "open('flying-circus.txt')", will
  use UTF-8. UTF-8 is a widely-supported Unicode character encoding
  that has become a *de facto* standard for representing text,
  including nearly every webpage on the internet, many common file
  formats, programming languages, and more.

  This only applies when no "encoding" argument is given. For best
  compatibility between versions of Python, ensure that an explicit
  "encoding" argument is always provided. The opt-in encoding warning
  can be used to identify code that may be affected by this change.
  The special "encoding='locale'" argument uses the current locale
  encoding, and has been supported since Python 3.10.

  To retain the previous behaviour, Python's UTF-8 mode may be
  disabled with the "PYTHONUTF8=0" environment variable or the "-X
  utf8=0" command-line option.

  Ver também: **PEP 686** for further details.

  (Contributed by Adam Turner in gh-133711; PEP 686 written by Inada
  Naoki.)

* The interpreter help (such as "python --help") is now in color. This
  can be controlled by environment variables. (Contributed by Hugo van
  Kemenade in gh-148766.)

* Unraisable exceptions are now highlighted with color by default.
  This can be controlled by environment variables. (Contributed by
  Peter Bierma in gh-134170.)

* More color in argparse, ast, calendar, difflib, http.server,
  pickletools, PyREPL tab completion, python --help, sqlite3, timeit,
  tokenize, unraisable exceptions and *stdlib* (ast, compileall,
  doctest, gzip, inspect, json.tool, pdb, profiling.sampling, random,
  regrtest, sqlite3, timeit, tokenize, trace, unittest, uuid, zipapp,
  zipfile) CLI help.

* The "__repr__()" of "ImportError" and "ModuleNotFoundError" now
  shows "name" and "path" as "name=<name>" and "path=<path>" if they
  were given as keyword arguments at construction time. (Contributed
  by Serhiy Storchaka, Oleg Iarygin, and Yoav Nir in gh-74185.)

* The "__dict__" and "__weakref__" descriptors now use a single
  descriptor instance per interpreter, shared across all types that
  need them. This speeds up class creation, and helps avoid reference
  cycles. (Contributed by Petr Viktorin in gh-135228.)

* The "-W" option and the "PYTHONWARNINGS" environment variable can
  now specify regular expressions instead of literal strings to match
  the warning message and the module name, if the corresponding field
  starts and ends with a forward slash ("/"). (Contributed by Serhiy
  Storchaka in gh-134716.)

* Functions that take timestamp or timeout arguments now accept any
  real numbers (such as "Decimal" and "Fraction"), not only integers
  or floats, although this does not improve precision. (Contributed by
  Serhiy Storchaka in gh-67795.)

* Added "bytearray.take_bytes(n=None, /)" to take bytes out of a
  "bytearray" without copying. This enables optimizing code which must
  return "bytes" after working with a mutable buffer of bytes such as
  data buffering, network protocol parsing, encoding, decoding, and
  compression. Common code patterns which can be optimized with
  "take_bytes()" are listed below.


  Suggested optimizing refactors
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  +-----------------------------------+-----------------------------------+-----------------------------------+
  | Descrição                         | Old                               | New                               |
  |===================================|===================================|===================================|
  | Return "bytes" after working with | def read() -> bytes:     buffer = | def read() -> bytes:     buffer = |
  | "bytearray"                       | bytearray(1024)     ...           | bytearray(1024)     ...           |
  |                                   | return bytes(buffer)              | return buffer.take_bytes()        |
  +-----------------------------------+-----------------------------------+-----------------------------------+
  | Empty a buffer getting the bytes  | buffer = bytearray(1024) ... data | buffer = bytearray(1024) ... data |
  |                                   | = bytes(buffer) buffer.clear()    | = buffer.take_bytes()             |
  +-----------------------------------+-----------------------------------+-----------------------------------+
  | Split a buffer at a specific      | buffer = bytearray(b'abc\ndef') n | buffer = bytearray(b'abc\ndef') n |
  | separator                         | = buffer.find(b'\n') data =       | = buffer.find(b'\n') data =       |
  |                                   | bytes(buffer[:n + 1]) del         | buffer.take_bytes(n + 1)          |
  |                                   | buffer[:n + 1] assert data ==     |                                   |
  |                                   | b'abc\n' assert buffer ==         |                                   |
  |                                   | bytearray(b'def')                 |                                   |
  +-----------------------------------+-----------------------------------+-----------------------------------+
  | Split a buffer at a specific      | buffer = bytearray(b'abc\ndef') n | buffer = bytearray(b'abc\ndef') n |
  | separator; discard after the      | = buffer.find(b'\n') data =       | = buffer.find(b'\n')              |
  | separator                         | bytes(buffer[:n]) buffer.clear()  | buffer.resize(n) data =           |
  |                                   | assert data == b'abc' assert      | buffer.take_bytes()               |
  |                                   | len(buffer) == 0                  |                                   |
  +-----------------------------------+-----------------------------------+-----------------------------------+

  (Contributed by Cody Maloney in gh-139871.)

* Many functions related to compiling or parsing Python code, such as
  "compile()", "ast.parse()", "symtable.symtable()", and
  "importlib.abc.InspectLoader.source_to_code()", now allow the module
  name to be passed. It is needed to unambiguously filter syntax
  warnings by module name. (Contributed by Serhiy Storchaka in
  gh-135801.)

* Allowed defining the *__dict__* and *__weakref__* __slots__ for any
  class. (Contributed by Serhiy Storchaka in gh-41779.)

* Allowed defining any __slots__ for a class derived from "tuple"
  (including classes created by "collections.namedtuple()").
  (Contributed by Serhiy Storchaka in gh-41779.)

* The "slice" type now supports subscription, making it a *generic
  type*. (Contributed by James Hilton-Balfe in gh-128335.)

* The class "memoryview" now supports the float complex and double
  complex C types: formatting characters "'Zf'" and "'Zd'"
  respectively. (Contributed by Victor Stinner in gh-146151 and
  gh-148675.)

* Allow the *count* argument of "bytes.replace()" to be a keyword.
  (Contributed by Stan Ulbrych in gh-147856.)

* Unary plus is now accepted in "match" literal patterns, mirroring
  the existing support for unary minus. (Contributed by Bartosz
  Sławecki in gh-145239.)

* The import system now acquires per-module locks in hierarchical
  order (parent packages before their submodules). This fixes a long-
  standing deadlock where one thread importing "pkg.sub" and another
  importing "pkg.sub.mod" could each block the other when
  "pkg/sub/__init__.py" imports "pkg.sub.mod". (Contributed by Gregory
  P. Smith in gh-83065.)


Console interativo padrão
=========================

* Tab completions are now colored by object kind, based on
  fancycompleter. Set "PYTHON_BASIC_COMPLETER" to fall back to
  "rlcompleter". Color can also be controlled by environment
  variables. (Contributed by Antonio Cuni and Pablo Galindo in
  gh-130472.)


Novos módulos
=============


math.integer
------------

This module provides access to the mathematical functions for integer
arguments (**PEP 791**). (Contributed by Serhiy Storchaka in
gh-81313.)


Módulos melhorados
==================


argparse
--------

* The "BooleanOptionalAction" action now supports single-dash long
  options and alternate prefix characters. (Contributed by Serhiy
  Storchaka in gh-138525.)

* Changed the *suggest_on_error* parameter of
  "argparse.ArgumentParser" to default to "True". This enables
  suggestions for mistyped arguments by default. (Contributed by Jakob
  Schluse in gh-140450.)

* Added backtick markup support in "ArgumentParser" description and
  epilog text to highlight inline code when color output is enabled.
  (Contributed by Savannah Ostrowski in gh-142390.)

* Extended backtick markup to argument "help" text and added support
  for double backticks (RST inline-literal style). (Contributed by
  Hugo van Kemenade in gh-149375.)


array
-----

* Support the float complex and double complex C types: formatting
  characters "'Zf'" and "'Zd'" respectively. (Contributed by Victor
  Stinner in gh-146151 and gh-148675.)

* Support half-floats (16-bit IEEE 754 binary interchange format):
  formatting character "'e'". (Contributed by Sergey B Kirpichev in
  gh-146238.)

* The "array.typecodes" type changed from "str" to "tuple" to support
  type codes longer than 1 character ("Zf" and "Zd"). (Contributed by
  Victor Stinner in gh-148675.)


ast
---

* Add *color* parameter to "dump()". If "True", the returned string is
  syntax highlighted using ANSI escape sequences. If "False" (the
  default), colored output is always disabled. (Contributed by Stan
  Ulbrych in gh-148981.)

* The command-line output is now syntax highlighted by default. This
  can be controlled using environment variables. (Contributed by Stan
  Ulbrych in gh-148981.)


asyncio
-------

* Added "TaskGroup.cancel" to allow early termination of a task group,
  for instance, when the goal of the tasks has been achieved or their
  services are no longer needed. Previously this would involve
  unintuitive boilerplate such as an extra task raising a custom
  exception which is then suppressed as it exits the task group.
  (Contributed by John Belmonte in gh-127214.)


base64
------

* Added the *pad* parameter in "z85encode()". (Contributed by Hauke
  Dämpfling in gh-143103.)

* Added the *padded* parameter in "b32encode()", "b32decode()",
  "b32hexencode()", "b32hexdecode()", "b64encode()", "b64decode()",
  "urlsafe_b64encode()", and "urlsafe_b64decode()". (Contributed by
  Serhiy Storchaka in gh-73613.)

* Added the *wrapcol* parameter in "b16encode()", "b32encode()",
  "b32hexencode()", "b64encode()", "b85encode()", and "z85encode()".
  (Contributed by Serhiy Storchaka in gh-143214 and gh-146431.)

* Added the *ignorechars* parameter in "b16decode()", "b32decode()",
  "b32hexdecode()", "b64decode()", "b85decode()", and "z85decode()".
  (Contributed by Serhiy Storchaka in gh-144001 and gh-146431.)

* Added the *canonical* parameter in "b32decode()", "b32hexdecode()",
  "b64decode()", "urlsafe_b64decode()", "a85decode()", "b85decode()",
  and "z85decode()", to reject encodings with non-zero padding bits or
  other non-canonical forms. (Contributed by Gregory P. Smith in
  gh-146311.)


binascii
--------

* Added functions for Base32 encoding:

  * "b2a_base32()" and "a2b_base32()"

  (Contributed by James Seo in gh-146192.)

* Added functions for Ascii85, Base85, and Z85 encoding:

  * "b2a_ascii85()" and "a2b_ascii85()"

  * "b2a_base85()" and "a2b_base85()"

  (Contributed by James Seo and Serhiy Storchaka in gh-101178.)

* Added the *padded* parameter in "b2a_base32()", "a2b_base32()",
  "b2a_base64()", and "a2b_base64()". (Contributed by Serhiy Storchaka
  in gh-73613.)

* Added the *wrapcol* parameter in "b2a_base64()". (Contributed by
  Serhiy Storchaka in gh-143214.)

* Added the *alphabet* parameter in "b2a_base64()" and "a2b_base64()".
  (Contributed by Serhiy Storchaka in gh-145980.)

* Added the *ignorechars* parameter in "a2b_hex()", "unhexlify()", and
  "a2b_base64()". (Contributed by Serhiy Storchaka in gh-144001 and
  gh-146431.)

* Added the *canonical* parameter in "a2b_base64()", to reject
  encodings with non-zero padding bits. (Contributed by Gregory P.
  Smith in gh-146311.)


calendar
--------

* "calendar"'s command-line text output has more color. This can be
  controlled with environment variables. (Contributed by Hugo van
  Kemenade in gh-148352.)

* The "calendar"'s command-line HTML output now accepts the year-month
  option: "python -m calendar -t html 2009 06". (Contributed by Pål
  Grønås Drange in gh-140212.)

* Calendar pages generated by the "calendar.HTMLCalendar" class now
  support dark mode and have been migrated to the HTML5 standard for
  improved accessibility. (Contributed by Jiahao Li and Hugo van
  Kemenade in gh-137634.)


collections
-----------

* Added "collections.Counter.__xor__()" and
  "collections.Counter.__ixor__()" to compute the symmetric difference
  between "Counter" objects. (Contributed by Raymond Hettinger in
  gh-138682.)


concurrent.futures
------------------

* Improved error reporting when a child process in a
  "concurrent.futures.ProcessPoolExecutor" terminates abruptly. The
  resulting traceback will now tell you the PID and exit code of the
  terminated process. (Contributed by Jonathan Berg in gh-139486.)


contextlib
----------

* Added support for arbitrary descriptors "__enter__()", "__exit__()",
  "__aenter__()", and "__aexit__()" in "ExitStack" and
  "contextlib.AsyncExitStack", for consistency with the "with" and
  "async with" statements. (Contributed by Serhiy Storchaka in
  gh-144386.)

* "ContextDecorator" and "AsyncContextDecorator" (and therefore
  "contextmanager()" and "asynccontextmanager()" used as decorators)
  now detect generator functions, coroutine functions, and
  asynchronous generator functions and keep the context manager open
  across iteration or await.  Previously the context manager exited as
  soon as the generator or coroutine object was created. (Contributed
  by Alex Grönholm & Gregory P. Smith in gh-125862.)


dataclasses
-----------

* Annotations for generated "__init__" methods no longer include
  internal type names.


dbm
---

* Added new "reorganize()" methods to "dbm.dumb" and "dbm.sqlite3" to
  recover unused free space previously occupied by deleted entries.
  (Contributed by Andrea Oliveri in gh-134004.)


difflib
-------

* Introduced the optional *color* parameter to
  "difflib.unified_diff()", enabling color output similar to **git
  diff**. This can be controlled by environment variables.
  (Contributed by Douglas Thor in gh-133725.)

* Improved the styling of HTML diff pages generated by the
  "difflib.HtmlDiff" class, and migrated the output to the HTML5
  standard. (Contributed by Jiahao Li in gh-134580.)


email
-----

* Email generators now raise an error when an "EmailMessage" cannot be
  accurately flattened due to a non-ASCII email address (mailbox) in
  an address header. Options for supporting Email Address
  Internationalization (EAI) are discussed in "EmailPolicy.utf8".
  (Contributed by R David Murray and Mike Edmunds in gh-122540.)


faulthandler
------------

* Added the *max_threads* parameter in "faulthandler.enable()",
  "faulthandler.dump_traceback()",
  "faulthandler.dump_traceback_later()", and
  "faulthandler.register()". (Contributed by Eric Froemling in
  gh-149085.)


functools
---------

* "singledispatchmethod()" now supports non-*descriptor* callables.
  (Contributed by Serhiy Storchaka in gh-140873.)

* "singledispatchmethod()" now dispatches on the second argument if it
  wraps a regular method and is called as a class attribute.
  (Contributed by Bartosz Sławecki in gh-143535.)


gc
--

* Python 3.14.0-3.14.4 shipped with a new incremental garbage
  collector. However, due to a number of reports of significant memory
  pressure in production environments, it has been reverted back to
  the generational GC from 3.13. This is the GC now used in Python
  3.14.5 and later and Python 3.15.


hashlib
-------

* Ensure that hash functions guaranteed to be always *available* exist
  as attributes of "hashlib" even if they will not work at runtime due
  to missing backend implementations. For instance, "hashlib.md5" will
  no longer raise "AttributeError" if OpenSSL is not available and
  Python has been built without MD5 support. (Contributed by Bénédikt
  Tran in gh-136929.)


http.client
-----------

* A new *max_response_headers* keyword-only parameter has been added
  to "HTTPConnection" and "HTTPSConnection" constructors. This
  parameter overrides the default maximum number of allowed response
  headers. (Contributed by Alexander Enrique Urieles Nieto in
  gh-131724.)


http.server
-----------

* The logging of "BaseHTTPRequestHandler", as used by the command-line
  interface, is colored by default. This can be controlled with
  environment variables. (Contributed by Hugo van Kemenade in
  gh-146292.)

* Added "default_content_type" and the "--content-type" command-line
  option to allow customizing the default "Content-Type" header for
  files with unknown extensions. (Contributed by John Comeau and Hugo
  van Kemenade in gh-113471.)

* Add a new "extra_response_headers" keyword argument to
  "SimpleHTTPRequestHandler" to support custom headers in HTTP
  responses. (Contributed by Anton I. Sipos in gh-135057.)

* Add a "-H/--header" option to the **python -m http.server** command-
  line interface to support custom headers in HTTP responses.
  (Contributed by Anton I. Sipos in gh-135057.)


inspect
-------

* Add parameters *inherit_class_doc* and *fallback_to_class_doc* for
  "getdoc()". (Contributed by Serhiy Storchaka in gh-132686.)


json
----

* Add the *array_hook* parameter to "load()" and "loads()" functions:
  allow a callback for JSON literal array types to customize Python
  lists in the resulting decoded object. Passing combined "frozendict"
  to *object_pairs_hook* param and "tuple" to "array_hook" will yield
  a deeply nested immutable Python structure representing the JSON
  data. (Contributed by Joao S. O. Bueno in gh-146440.)


locale
------

* "setlocale()" now supports language codes with "@"-modifiers.
  "@"-modifiers are no longer silently removed in "getlocale()", but
  included in the language code. (Contributed by Serhiy Storchaka in
  gh-137729.)

* Undeprecate the "locale.getdefaultlocale()" function. (Contributed
  by Victor Stinner in gh-130796.)


math
----

* Add "math.isnormal()" and "math.issubnormal()" functions.
  (Contributed by Sergey B Kirpichev in gh-132908.)

* Add "math.fmax()", "math.fmin()" and "math.signbit()" functions.
  (Contributed by Bénédikt Tran in gh-135853.)


mimetypes
---------

* Add more MIME types. (Contributed by Benedikt Johannes, Charlie Lin,
  Foolbar, Gil Forcada and John Franey in gh-144217, gh-145720,
  gh-140937, gh-139959, gh-145698, gh-145718, gh-145918, and
  gh-144213.)

* Rename "application/x-texinfo" to "application/texinfo".
  (Contributed by Charlie Lin in gh-140165.)

* Changed the MIME type for ".ai" files to "application/pdf".
  (Contributed by Stan Ulbrych in gh-141239.)


mmap
----

* "mmap.mmap" now has a *trackfd* parameter on Windows; if it is
  "False", the file handle corresponding to *fileno* will not be
  duplicated. (Contributed by Serhiy Storchaka in gh-78502.)

* Added the "mmap.mmap.set_name()" method to annotate an anonymous
  memory mapping if Linux kernel supports *PR_SET_VMA_ANON_NAME*
  (Linux 5.17 or newer). (Contributed by Donghee Na in gh-142419.)


os
--

* Add "os.statx()" on Linux kernel versions 4.11 and later with glibc
  versions 2.28 and later. (Contributed by Jeffrey Bosboom and Victor
  Stinner in gh-83714.)

* "os.makedirs()" function now has a *parent_mode* parameter that
  allows specifying the mode for intermediate directories. This can be
  used to match the behavior from Python 3.6 and earlier by passing
  "parent_mode=mode". (Contributed by Zackery Spytz and Gregory P.
  Smith in gh-86533.)


os.path
-------

* Add support of the all-but-last mode in "realpath()". (Contributed
  by Serhiy Storchaka in gh-71189.)

* O parâmetro *strict* para "os.path.realpath()" aceita um novo valor,
  "os.path.ALLOW_MISSING". Se usado, erros diferentes de
  "FileNotFoundError" serão levantados novamente; o caminho resultante
  pode estar ausente, mas estará livre de links simbólicos.
  (Contribuição de Petr Viktorin para **CVE 2025-4517**.)


pdb
---

* Use the new interactive shell as the default input shell for "pdb".
  (Contributed by Tian Gao in gh-145379.)


pickle
------

* Add support for pickling private methods and nested classes.
  (Contributed by Zackery Spytz and Serhiy Storchaka in gh-77188.)


pickletools
-----------

* The output of the "pickletools" command-line interface is colored by
  default. This can be controlled with environment variables.
  (Contributed by Hugo van Kemenade in gh-149026.)


pprint
------

* "pprint" now uses modern defaults: "indent=4, width=88", and the
  default "compact=False" output is now formatted similar to pretty-
  printed "json.dumps()". (Contributed by Stefan Todoran, Semyon Moroz
  and Hugo van Kemenade in gh-112632 and gh-149189.)

* Add t-string support to "pprint". (Contributed by Loïc Simon and
  Hugo van Kemenade in gh-134551.)


re
--

* "re.prefixmatch()" and a corresponding "re.Pattern.prefixmatch()"
  have been added as alternate, more explicit names for the existing
  and now *soft deprecated* "re.match()" and "re.Pattern.match()"
  APIs. These are intended to be used to alleviate confusion around
  what *match* means by following the Zen of Python's *"Explicit is
  better than implicit"* mantra. Most other language regular
  expression libraries use an API named *match* to mean what Python
  has always called *search*. (Contributed by Gregory P. Smith in
  gh-86519.)


resource
--------

* Add new constants: "RLIMIT_NTHR", "RLIMIT_UMTXP", "RLIMIT_THREADS",
  "RLIM_SAVED_CUR", and "RLIM_SAVED_MAX". (Contributed by Serhiy
  Storchaka in gh-137512.)


shelve
------

* Added new "reorganize()" method to "shelve" used to recover unused
  free space previously occupied by deleted entries. (Contributed by
  Andrea Oliveri in gh-134004.)

* Add support for custom serialization and deserialization functions
  in the "shelve" module. (Contributed by Furkan Onder in gh-99631.)


socket
------

* Add constants for the ISO-TP CAN protocol. (Contributed by Patrick
  Menschel and Stefan Tatschner in gh-86819.)


sqlite3
-------

* The command-line interface has several new features:

  * SQL keyword completion on <tab>. (Contributed by Long Tan in
    gh-133393.)

  * Prompts, error messages, and help text are now colored. This is
    enabled by default, see Controlando cores for details.
    (Contributed by Stan Ulbrych and Łukasz Langa in gh-133461.)

  * Table, index, trigger, view, column, function, and schema
    completion on <tab>. (Contributed by Long Tan in gh-136101.)


ssl
---

* Indicate through "ssl.HAS_PSK_TLS13" whether the "ssl" module
  supports "External PSKs" in TLSv1.3, as described in **RFC 9258**.
  (Contributed by Will Childs-Klein in gh-133624.)

* Added new methods for managing groups used for SSL key agreement

  * "ssl.SSLContext.set_groups()" sets the groups allowed for doing
    key agreement, extending the previous
    "ssl.SSLContext.set_ecdh_curve()" method. This new API provides
    the ability to list multiple groups and supports fixed-field and
    post-quantum groups in addition to ECDH curves. This method can
    also be used to control what key shares are sent in the TLS
    handshake.

  * "ssl.SSLSocket.group()" returns the group selected for doing key
    agreement on the current connection after the TLS handshake
    completes. This call requires OpenSSL 3.2 or later.

  * "ssl.SSLContext.get_groups()" returns a list of all available key
    agreement groups compatible with the minimum and maximum TLS
    versions currently set in the context. This call requires OpenSSL
    3.5 or later.

  (Contributed by Ron Frederick in gh-136306.)

* Added a new method "ssl.SSLContext.set_ciphersuites()" for setting
  TLS 1.3 ciphers. For TLS 1.2 or earlier,
  "ssl.SSLContext.set_ciphers()" should continue to be used. Both
  calls can be made on the same context and the selected cipher suite
  will depend on the TLS version negotiated when a connection is made.
  (Contributed by Ron Frederick in gh-137197.)

* Added new methods for managing signature algorithms:

  * "ssl.get_sigalgs()" returns a list of all available TLS signature
    algorithms. This call requires OpenSSL 3.4 or later.

  * "ssl.SSLContext.set_client_sigalgs()" sets the signature
    algorithms allowed for certificate-based client authentication.

  * "ssl.SSLContext.set_server_sigalgs()" sets the signature
    algorithms allowed for the server to complete the TLS handshake.

  * "ssl.SSLSocket.client_sigalg()" returns the signature algorithm
    selected for client authentication on the current connection. This
    call requires OpenSSL 3.5 or later.

  * "ssl.SSLSocket.server_sigalg()" returns the signature algorithm
    selected for the server to complete the TLS handshake on the
    current connection. This call requires OpenSSL 3.5 or later.

  (Contributed by Ron Frederick in gh-138252.)


subprocess
----------

* "subprocess.Popen.wait()": when "timeout" is not "None" and the
  platform supports it, an efficient event-driven mechanism is used to
  wait for process termination:

  * Linux >= 5.3 uses "os.pidfd_open()" + "select.poll()".

  * macOS and other BSD variants use "select.kqueue()" +
    "KQ_FILTER_PROC" + "KQ_NOTE_EXIT".

  * Windows keeps using "WaitForSingleObject" (unchanged).

  If none of these mechanisms are available, the function falls back
  to the traditional busy loop (non-blocking call and short sleeps).
  (Contributed by Giampaolo Rodola in gh-83069.)


symtable
--------

* Add "symtable.Function.get_cells()" and "symtable.Symbol.is_cell()"
  methods. (Contributed by Yashp002 in gh-143504.)


sys
---

* Add "sys.abi_info" namespace to improve access to ABI information.
  (Contributed by Klaus Zimmermann in gh-137476.)


sys.monitoring
--------------

* The other events ("PY_THROW", "PY_UNWIND", "RAISE",
  "EXCEPTION_HANDLED", and "RERAISE") can now be turned on and
  disabled on a per code object basis. Returning "DISABLE" from a
  callback for one of these events disables the event for the entire
  code object (for the current tool), rather than raising "ValueError"
  as in prior versions. (Contributed by Gabriele N. Tornetta in
  gh-146182.)


tarfile
-------

* "data_filter()" agora normaliza alvos de links simbólicos para
  evitar ataques de travessia de caminho. (Contribuição de Petr
  Viktorin em gh-127987 e **CVE 2025-4138**.)

* "extractall()" agora ignora a correção de atributos de diretório
  quando um diretório é removido ou substituído por outro tipo de
  arquivo. (Contribuição de Petr Viktorin em gh-127987 e **CVE
  2024-12718**.)

* "extract()" e "extractall()" agora (re)aplicam o filtro de extração
  ao substituir um link (físico ou simbólico) por uma cópia de outro
  membro do arquivo e ao corrigir atributos de diretório. O primeiro
  levanta uma nova exceção, "LinkFallbackError". (Contribuição de Petr
  Viktorin para **CVE 2025-4330** e **CVE 2024-12718**.)

* "extract()" e "extractall()" não extraem mais membros rejeitados
  quando "errorlevel()" é zero. (Contribuição de Matt Prodani e Petr
  Viktorin em gh-112887 e **CVE 2025-4435**.)

* "extract()" and "extractall()" now replace slashes with backslashes
  in symlink targets on Windows to prevent creation of corrupted
  links. (Contributed by Christoph Walcher in gh-57911.)


threading
---------

* Added "serialize_iterator", "synchronized_iterator()", and
  "concurrent_tee()" to support concurrent access to generators and
  iterators. (Contributed by Raymond Hettinger in gh-124397.)


timeit
------

* The output of the "timeit" command-line interface is colored by
  default. This can be controlled with environment variables.
  (Contributed by Hugo van Kemenade in gh-146609.)

* The command-line interface now colorizes error tracebacks by
  default. This can be controlled with environment variables.
  (Contributed by Yi Hong in gh-139374.)

* Make the target time of "timeit.Timer.autorange()" configurable and
  add "--target-time" option to the command-line interface.
  (Contributed by Alessandro Cucci and Miikka Koskinen in gh-80642.)


tkinter
-------

* The "tkinter.Text.search()" method now supports two additional
  arguments: *nolinestop* which allows the search to continue across
  line boundaries; and *strictlimits* which restricts the search to
  within the specified range. (Contributed by Rihaan Meher in
  gh-130848.)

* A new method "tkinter.Text.search_all()" has been introduced. This
  method allows for searching for all matches of a pattern using Tcl's
  "-all" and "-overlap" options. (Contributed by Rihaan Meher in
  gh-130848.)

* Added new methods "pack_content()", "place_content()" and
  "grid_content()" which use Tk commands with new names (introduced in
  Tk 8.6) instead of "*_slaves()" methods which use Tk commands with
  outdated names. (Contributed by Serhiy Storchaka in gh-143754.)

* Added "Event" attributes "user_data" for Tk virtual events and
  "detail" for "Enter", "Leave", "FocusIn", "FocusOut", and
  "ConfigureRequest" events. (Contributed by Matthias Kievernagel and
  Serhiy Storchaka in gh-47655.)


tokenize
--------

* The output of the "tokenize" command-line interface is colored by
  default. This can be controlled with environment variables.
  (Contributed by Hugo van Kemenade in gh-148991.)


tomllib
-------

* The "tomllib" module now supports TOML 1.1.0. This is a backwards
  compatible update, meaning that all valid TOML 1.0.0 documents are
  parsed the same way.

  The changes, according to the official TOML changelog, are:

  * Allow newlines and trailing commas in inline tables.

    Previously an inline table had to be on a single line and couldn't
    end with a trailing comma. This is now relaxed so that the
    following is valid:

       tbl = {
          key      = "a string",
          moar-tbl =  {
             key = 1,
          },
       }

  * Add "\xHH" notation to basic strings for codepoints under 255, and
    the "\e" escape for the escape character:

       null = "null byte: \x00; letter a: \x61"
       csi = "\e["

  * Seconds in datetime and time values are now optional. The
    following are now valid:

       dt = 2010-02-03 14:15
       t  = 14:15

  (Contributed by Taneli Hukkinen in gh-142956.)


types
-----

* Expose the write-through "locals()" proxy type as
  "types.FrameLocalsProxyType". This represents the type of the
  "frame.f_locals" attribute, as described in **PEP 667**.


typing
------

* **PEP 747**: Add "TypeForm", a new special form for annotating
  values that are themselves type expressions. "TypeForm[T]" means "a
  type form object describing "T" (or a type assignable to "T")". At
  runtime, "TypeForm(x)" simply returns "x", which allows explicit
  annotation of type-form values without changing behavior.

  This helps libraries that accept user-provided type expressions (for
  example "int", "str | None", "TypedDict" classes, or "list[int]")
  expose precise signatures:

     from typing import Any, TypeForm

     def cast[T](typ: TypeForm[T], value: Any) -> T: ...

  (Contributed by Jelle Zijlstra in gh-145033.)

* **PEP 728**: Add support in "TypedDict" for the *closed* and
  *extra_items* class arguments. A closed "TypedDict" does not allow
  extra keys beyond those specified in the class body, while a
  "TypedDict" with "extra_items" allows arbitrary extra items where
  the values are of the specified type. (Contributed by Angela Liss in
  gh-137840.)

* Code like "class ExtraTypeVars(P1[S], Protocol[T, T2]): ..." now
  raises a "TypeError", because "S" is not listed in "Protocol"
  parameters. (Contributed by Nikita Sobolev in gh-137191.)

* Code like "class B2(A[T2], Protocol[T1, T2]): ..." now correctly
  handles type parameters order: it is "(T1, T2)", not "(T2, T1)" as
  it was incorrectly inferred at runtime before. (Contributed by
  Nikita Sobolev in gh-137191.)

* **PEP 800**: Add "@typing.disjoint_base", a new decorator marking a
  class as a disjoint base. This is an advanced feature primarily
  intended to allow type checkers to faithfully reflect the runtime
  semantics of types defined as builtins or in compiled extensions. If
  a class "C" is a disjoint base, then child classes of that class
  cannot inherit from other disjoint bases that are not parent or
  child classes of "C". (Contributed by Jelle Zijlstra in gh-148639.)

* "TypeVarTuple" now accepts "bound", "covariant", "contravariant",
  and "infer_variance" keyword arguments, matching the interface of
  "TypeVar" and "ParamSpec". "bound" semantics remain undefined in the
  specification.


unicodedata
-----------

* The Unicode database has been updated to Unicode 17.0.0.

* Add "unicodedata.isxidstart()" and "unicodedata.isxidcontinue()"
  functions to check whether a character can start or continue a
  Unicode Standard Annex #31 identifier. (Contributed by Stan Ulbrych
  in gh-129117.)

* Add the "iter_graphemes()" function to iterate over grapheme
  clusters according to rules defined in Unicode Standard Annex #29,
  "Unicode Text Segmentation". Add "grapheme_cluster_break()",
  "indic_conjunct_break()" and "extended_pictographic()" functions to
  get the properties of the character which are related to the above
  algorithm. (Contributed by Serhiy Storchaka and Guillaume Sanchez in
  gh-74902.)

* Add "block()" function to return the Unicode block assigned to a
  character. (Contributed by Stan Ulbrych in gh-66802.)


unittest
--------

* "unittest.TestCase.assertLogs()" will now accept a formatter to
  control how messages are formatted. (Contributed by Garry Cairns in
  gh-134567.)

* "unittest.TestCase.assertWarns()" and
  "unittest.TestCase.assertWarnsRegex()" no longer swallow warnings
  that do not match the specified category or regex. Nested context
  managers are now supported. (Contributed by Serhiy Storchaka in
  gh-143231.)


urllib.parse
------------

* Add the *missing_as_none* parameter to "urlsplit()", "urlparse()"
  and "urldefrag()" functions. Add the *keep_empty* parameter to
  "urlunsplit()" and "urlunparse()" functions. This allows
  distinguishing between empty and undefined URI components and
  preserving empty components. (Contributed by Serhiy Storchaka in
  gh-67041.)


venv
----

* On POSIX platforms, platlib directories will be created if needed
  when creating virtual environments, instead of using a "lib64 ->
  lib" symlink. This means purelib and platlib of virtual environments
  no longer share the same "lib" directory on platforms where
  "sys.platlibdir" is not equal to "lib". (Contributed by Rui Xi in
  gh-133951.)


avisos
------

* Improve filtering by module in "warnings.warn_explicit()" if no
  *module* argument is passed. It now tests the module regular
  expression in the warnings filter not only against the filename with
  ".py" stripped, but also against module names constructed starting
  from different parent directories of the filename (with
  "/__init__.py", ".py" and, on Windows, ".pyw" stripped).
  (Contributed by Serhiy Storchaka in gh-135801.)


wave
----

* Added support for IEEE floating-point WAVE audio
  ("WAVE_FORMAT_IEEE_FLOAT") in "wave".

* Added "wave.Wave_read.getformat()", "wave.Wave_write.getformat()",
  and "wave.Wave_write.setformat()" for explicit frame format
  handling.

* "wave.Wave_write.setparams()" accepts both 7-item tuples including
  "format" and 6-item tuples for backwards compatibility (defaulting
  to "WAVE_FORMAT_PCM").

* "WAVE_FORMAT_IEEE_FLOAT" output now includes a "fact" chunk, as
  required for non-PCM WAVE formats.

(Contributed by Lionel Koenig and Michiel W. Beijen in gh-60729.)


webbrowser
----------

* On macOS, the new "webbrowser.MacOS" class opens URLs via
  **/usr/bin/open** instead of constructing and executing AppleScript
  via **osascript**. The default browser is detected from the
  LaunchServices preferences file using "plistlib", with
  "com.apple.Safari" as the fallback on fresh installations. For non-
  HTTP(S) URLs, **open -b <bundle-id>** is used to route the URL
  through a browser rather than the OS file handler, preventing file
  injection attacks. (Contributed by Jeff Lyon in gh-137586.)


xml
---

* Add the "xml.is_valid_name()" function to check whether a string can
  be used as an element or attribute name in XML. (Contributed by
  Serhiy Storchaka in gh-139489.)

* Add the "xml.is_valid_text()" function, which allows to check
  whether a string can be used in the XML document. (Contributed by
  Serhiy Storchaka in gh-139489.)


xml.parsers.expat
-----------------

* Add "SetAllocTrackerActivationThreshold()" and
  "SetAllocTrackerMaximumAmplification()" to xmlparser objects to tune
  protections against disproportional amounts of dynamic memory usage
  from within an Expat parser. (Contributed by Bénédikt Tran in
  gh-90949.)

* Add "SetBillionLaughsAttackProtectionActivationThreshold()" and
  "SetBillionLaughsAttackProtectionMaximumAmplification()" to
  xmlparser objects to tune protections against billion laughs
  attacks. (Contributed by Bénédikt Tran in gh-90949.)


zlib
----

* Allow combining two Adler-32 checksums via "adler32_combine()".
  (Contributed by Callum Attryde and Bénédikt Tran in gh-134635.)

* Allow combining two CRC-32 checksums via "crc32_combine()".
  (Contributed by Bénédikt Tran in gh-134635.)


Otimizações
===========

* "mimalloc" is now used as the default allocator for raw memory
  allocations such as via "PyMem_RawMalloc()" for better performance
  on *free-threaded builds*. (Contributed by Kumar Aditya in
  gh-144914.)


base64 & binascii
-----------------

* CPython's underlying base64 implementation now encodes 2x faster and
  decodes 3x faster thanks to simple CPU pipelining optimizations.
  (Contributed by Gregory P. Smith and Serhiy Storchaka in gh-143262.)

* Implementation for Ascii85, Base85, and Z85 encoding has been
  rewritten in C. Encoding and decoding is now two orders of magnitude
  faster and consumes two orders of magnitude less memory.
  (Contributed by James Seo and Serhiy Storchaka in gh-101178.)

* Implementation for Base32 has been rewritten in C. Encoding and
  decoding is now two orders of magnitude faster. (Contributed by
  James Seo in gh-146192.)


csv
---

* "csv.Sniffer.sniff()" delimiter detection is now up to 1.6x faster.
  (Contributed by Maurycy Pawłowski-Wieroński in gh-137628.)


Upgraded JIT compiler
---------------------

Results from the pyperformance benchmark suite report 8-9% geometric
mean performance improvement for the JIT over the standard CPython
interpreter built with all optimizations enabled on x86-64 Linux. On
AArch64 macOS, the JIT has a 12-13% speedup over the tail calling
interpreter with all optimizations enabled. The speedups for JIT
builds versus no JIT builds range from roughly 15% slowdown to over
100% speedup (ignoring the "unpack_sequence" microbenchmark) on x86-64
Linux and AArch64 macOS systems.

Atenção:

  These results are not yet final.

The major upgrades to the JIT are:

* LLVM 21 build-time dependency

* New tracing frontend

* Basic register allocation in the JIT

* More JIT optimizations

* GDB and GNU "backtrace()" unwinding support

* Better machine code generation

-[ LLVM 21 build-time dependency ]-

The JIT compiler now uses LLVM 21 for build-time stencil generation.
As always, LLVM is only needed when building CPython with the JIT
enabled; end users running Python do not need LLVM installed.
Instructions for installing LLVM can be found in the JIT compiler
documentation for all supported platforms. (Contributed by Savannah
Ostrowski in gh-140973.)

-[ A new tracing frontend ]-

The JIT compiler now supports significantly more bytecode operations
and control flow than in Python 3.14, enabling speedups on a wider
variety of code. For example, simple Python object creation is now
understood by the 3.15 JIT compiler. Overloaded operations and
generators are also partially supported. This was made possible by an
overhauled JIT tracing frontend that records actual execution paths
through code, rather than estimating them as the previous
implementation did. (Contributed by Ken Jin in gh-139109. Support for
Windows added by Mark Shannon in gh-141703.)

-[ Basic register allocation in the JIT ]-

A basic form of register allocation has been added to the JIT
compiler's optimizer. This allows the JIT compiler to avoid certain
stack operations altogether and instead operate on registers. This
allows the JIT to produce more efficient traces by avoiding reads and
writes to memory. (Contributed by Mark Shannon in gh-135379.)

-[ More JIT optimizations ]-

More constant-propagation is now performed. This means when the JIT
compiler detects that certain user code results in constants, the code
can be simplified by the JIT. (Contributed by Ken Jin and Savannah
Ostrowski in gh-132732.)

*Reference count*s are avoided whenever it is safe to do so. This
generally reduces the cost of most operations in Python. (Contributed
by Ken Jin, Donghee Na, Zheao Li, Hai Zhu, Savannah Ostrowski, Reiden
Ong, Noam Cohen, Tomas Roun, PuQing, Cajetan Rodrigues, and Sacul in
gh-134584.)

By tracking unique references to objects, the JIT optimizer can now
eliminate reference count updates and perform in-place operations on
ints and floats. (Contributed by Reiden Ong, and Pieter Eendebak in
gh-143414 and gh-146306.)

The JIT optimizer now supports significantly more operations than in
3.14. (Contributed by Kumar Aditya, Ken Jin, Jiahao Li, and Sacul in
gh-131798.)

-[ GDB and GNU "backtrace()" unwinding support ]-

The JIT compiler now publishes unwind information for generated
machine code to the GDB interface on supported Linux ELF platforms.
When libgcc frame registration is available, the same unwind
information is also registered for GNU "backtrace()" stack walkers.
This allows native debuggers, crash handlers, and diagnostic tools
using these mechanisms to unwind through JIT frames instead of
stopping at generated code. (Contributed by Diego Russo and Pablo
Galindo Salgado in gh-146071 and gh-149104.)

-[ Better machine code generation ]-

The JIT compiler's machine code generator now produces better machine
code for x86-64 and AArch64 macOS and Linux targets. In general, users
should experience lower memory usage for generated machine code and
more efficient machine code versus 3.14. (Contributed by Brandt Bucher
in gh-136528 and gh-135905. Implementation for AArch64 contributed by
Mark Shannon in gh-139855. Additional optimizations for AArch64
contributed by Mark Shannon and Diego Russo in gh-140683 and
gh-142305.)

-[ Maintainability ]-

The JIT optimizer's operations have been simplified. This was made
possible by a refactoring of JIT data structures. (Contributed by
Zhongtian Zheng in gh-148211 and Hai Zhu in gh-143421.)


Removidos
=========


ast
---

* The constructors of AST nodes now raise a "TypeError" when a
  required argument is omitted or when a keyword argument that does
  not map to a field on the AST node is passed. These cases had
  previously raised a "DeprecationWarning" since Python 3.13.
  (Contributed by Brian Schubert and Jelle Zijlstra in gh-137600 and
  gh-105858.)


collections.abc
---------------

* "collections.abc.ByteString" has been removed from
  "collections.abc.__all__". "collections.abc.ByteString" has been
  deprecated since Python 3.12, and is scheduled for removal in Python
  3.17.


ctypes
------

* Removed the undocumented function "ctypes.SetPointerType()", which
  has been deprecated since Python 3.13. (Contributed by Bénédikt Tran
  in gh-133866.)

* Change the "_type_" of "c_float_complex", "c_double_complex" and
  "c_longdouble_complex" from "F", "D" and "G" to "Zf", "Zd" and "Zg"
  for compatibility with numpy. (Contributed by Victor Stinner in
  gh-148675.)


datetime
--------

* "strptime()" now raises "ValueError" when the format string contains
  "%d" (day of month) without a year directive. This has been
  deprecated since Python 3.13. (Contributed by Stan Ulbrych and
  Gregory P. Smith in gh-70647.)


glob
----

* Removed the undocumented "glob.glob0()" and "glob.glob1()"
  functions, which have been deprecated since Python 3.13. Use
  "glob.glob()" and pass a directory to its *root_dir* argument
  instead. (Contributed by Barney Gale in gh-137466.)


http.server
-----------

* Removed the "CGIHTTPRequestHandler" class and the "--cgi" flag from
  the **python -m http.server** command-line interface. They were
  deprecated in Python 3.13. (Contributed by Bénédikt Tran in
  gh-133810.)


importlib.resources
-------------------

* Removed deprecated "package" parameter from
  "importlib.resources.files()" function. (Contributed by Semyon Moroz
  in gh-138044.)


pathlib
-------

* "pathlib.Path.mkdir()" now has a *parent_mode* parameter that allows
  specifying the mode for intermediate directories when
  "parents=True". (Contributed by Gregory P. Smith in gh-86533.)

* Removed deprecated "pathlib.PurePath.is_reserved()". Use
  "os.path.isreserved()" to detect reserved paths on Windows.
  (Contributed by Nikita Sobolev in gh-133875.)


platform
--------

* Removed the "platform.java_ver()" function, which was deprecated
  since Python 3.13. (Contributed by Alexey Makridenko in gh-133604.)


sre_*
-----

* Removed "sre_compile", "sre_constants" and "sre_parse" modules.
  (Contributed by Stan Ulbrych in gh-135994.)


sysconfig
---------

* Removed the *check_home* parameter of "sysconfig.is_python_build()".
  (Contributed by Filipe Laíns in gh-92897.)


threading
---------

* Remove support for arbitrary positional or keyword arguments in the
  C implementation of "RLock" objects. This was deprecated in Python
  3.14. (Contributed by Bénédikt Tran in gh-134087.)


types
-----

* Removed deprecated in **PEP 626** since Python 3.12
  "codeobject.co_lnotab" from "types.CodeType". (Contributed by Nikita
  Sobolev in gh-134690.)


typing
------

* "typing.ByteString" has been removed from "typing.__all__".
  "typing.ByteString" has been deprecated since Python 3.9, and is
  scheduled for removal in Python 3.17.

* The undocumented keyword argument syntax for creating "NamedTuple"
  classes (for example, "Point = NamedTuple("Point", x=int, y=int)")
  is no longer supported. Use the class-based syntax or the functional
  syntax instead. (Contributed by Bénédikt Tran in gh-133817.)

* Using "TD = TypedDict("TD")" or "TD = TypedDict("TD", None)" to
  construct a "TypedDict" type with zero fields is no longer
  supported. Use "class TD(TypedDict): pass" or "TD = TypedDict("TD",
  {})" instead. (Contributed by Bénédikt Tran in gh-133823.)

* Deprecated "typing.no_type_check_decorator()" has been removed.
  (Contributed by Nikita Sobolev in gh-133601.)


wave
----

* Removed the "getmark()", "setmark()" and "getmarkers()" methods of
  the "Wave_read" and "Wave_write" classes, which were deprecated
  since Python 3.13. (Contributed by Bénédikt Tran in gh-133873.)


zipimport
---------

* Remove deprecated "zipimport.zipimporter.load_module()". Use
  "zipimport.zipimporter.exec_module()" instead. (Contributed by
  Jiahao Li in gh-133656.)


Descontinuados
==============


Novas descontinuações
---------------------

* "ast"

  * Creating instances of abstract AST nodes (such as "ast.AST" or
    "ast.expr") is deprecated and will raise an error in Python 3.20.

    (Contributed by Brian Schubert in gh-116021.)

* "base64":

  * Accepting the "+" and "/" characters with an alternative alphabet
    in "b64decode()" and "urlsafe_b64decode()" is now deprecated. In
    future Python versions they will be errors in the strict mode and
    discarded in the non-strict mode. (Contributed by Serhiy Storchaka
    in gh-125346.)

* CLI:

  * Deprecate "-b" and "-bb" command-line options and schedule them to
    become no-ops in Python 3.17. These were primarily helpers for the
    Python 2 -> 3 transition. Starting with Python 3.17, no
    "BytesWarning" will be raised for these cases; use a type checker
    instead.

    (Contributed by Nikita Sobolev in gh-136355.)

* "collections.abc"

  * The following statements now cause "DeprecationWarning"s to be
    emitted at runtime:

    * "from collections.abc import ByteString"

    * "import collections.abc; collections.abc.ByteString".

    "DeprecationWarning"s were already emitted if
    "collections.abc.ByteString" was subclassed or used as the second
    argument to "isinstance()" or "issubclass()", but warnings were
    not previously emitted if it was merely imported or accessed from
    the "collections.abc" module.

* "hashlib":

  * In hash function constructors such as "new()" or the direct hash-
    named constructors such as "md5()" and "sha256()", the optional
    initial data parameter could also be passed as a keyword argument
    named "data=" or "string=" in various "hashlib" implementations.

    Support for the "string" keyword argument name is now deprecated
    and is slated for removal in Python 3.19. Prefer passing the
    initial data as a positional argument for maximum backwards
    compatibility.

    (Contributed by Bénédikt Tran in gh-134978.)

* "http.cookies":

  * "Morsel.js_output" and "BaseCookie.js_output" are deprecated and
    will be removed in Python 3.19. Use "Morsel.output" or
    "BaseCookie.output" instead. (Contributed by kishorhange111 in
    gh-148849.)

* "imaplib":

  * Altering "IMAP4.file" is now deprecated and slated for removal in
    Python 3.19. This property is now unused and changing its value
    does *not* explicitly close the current file.

* "re":

  * "re.match()" and "re.Pattern.match()" are now *soft deprecated* in
    favor of the new "re.prefixmatch()" and "re.Pattern.prefixmatch()"
    APIs, which have been added as alternate, more explicit names.
    These are intended to be used to alleviate confusion around what
    *match* means by following the Zen of Python's *"Explicit is
    better than implicit"* mantra. Most other language regular
    expression libraries use an API named *match* to mean what Python
    has always called *search*.

    We **do not** plan to remove the older "match()" name, as it has
    been used in code for over 30 years. Code supporting older
    versions of Python should continue to use "match()", while new
    code should prefer "prefixmatch()". See prefixmatch() vs. match().

    (Contributed by Gregory P. Smith in gh-86519 and Hugo van Kemenade
    in gh-148100.)

* "struct":

  * Calling "Struct.__new__()" without a required argument is now
    deprecated and will be removed in Python 3.20.  Calling the
    "__init__()" method on an initialized "Struct" object is
    deprecated and will be removed in Python 3.20.

    (Contributed by Sergey B Kirpichev and Serhiy Storchaka in
    gh-143715.)

* "typing":

  * The following statements now cause "DeprecationWarning"s to be
    emitted at runtime:

    * "from typing import ByteString"

    * "import typing; typing.ByteString".

    "DeprecationWarning"s were already emitted if "typing.ByteString"
    was subclassed or used as the second argument to "isinstance()" or
    "issubclass()", but warnings were not previously emitted if it was
    merely imported or accessed from the "typing" module.

* "webbrowser":

  * "webbrowser.MacOSXOSAScript" is deprecated in favour of
    "webbrowser.MacOS" and scheduled for removal in Python 3.17.
    (Contributed by Jeff Lyon in gh-137586.)

* "__version__"

  * The "__version__", "version" and "VERSION" attributes have been
    deprecated in these standard library modules and will be removed
    in Python 3.20. Use "sys.version_info" instead.

    * "argparse"

    * "csv"

    * "ctypes"

    * "ctypes.macholib"

    * "decimal" (use "decimal.SPEC_VERSION" instead)

    * "http.server"

    * "imaplib"

    * "ipaddress"

    * "json"

    * "logging" ("__date__" also deprecated)

    * "optparse"

    * "pickle"

    * "platform"

    * "re"

    * "socketserver"

    * "tabnanny"

    * "tarfile"

    * "tkinter.font"

    * "tkinter.ttk"

    * "wsgiref.simple_server"

    * "xml.etree.ElementTree"

    * "xml.sax.expatreader"

    * "xml.sax.handler"

    * "zlib"

    (Contributed by Hugo van Kemenade and Stan Ulbrych in gh-76007.)


Remoção pendente no Python 3.16
-------------------------------

* O sistema de importação:

  * A definição de "__loader__" em um módulo enquanto falha na
    definição de "__spec__.loader" está descontinuado. No Python 3.16,
    "__loader__" deixará de ser definido ou levado em consideração
    pelo sistema de importação ou pela biblioteca padrão.

* "array":

  * O código de formato "'u'" ("wchar_t") foi descontinuado na
    documentação desde o Python 3.3 e em tempo de execução desde o
    Python 3.13. Use o código de formato "'w'" ("Py_UCS4") para
    caracteres Unicode.

* "asyncio":

  * "asyncio.iscoroutinefunction()" foi descontinuado e será removido
    no Python 3.16, use "inspect.iscoroutinefunction()" em vez disso.
    (Contribuição de Jiahao Li e Kumar Aditya em gh-122875.)

  * O sistema de políticas "asyncio" está descontinuado e será
    removido no Python 3.16. Em particular, as seguintes classes e
    funções estão descontinuadas:

    * "asyncio.AbstractEventLoopPolicy"

    * "asyncio.DefaultEventLoopPolicy"

    * "asyncio.WindowsSelectorEventLoopPolicy"

    * "asyncio.WindowsProactorEventLoopPolicy"

    * "asyncio.get_event_loop_policy()"

    * "asyncio.set_event_loop_policy()"

    Os usuários devem usar "asyncio.run()" ou "asyncio.Runner" com
    *loop_factory* para usar a implementação de loop de eventos
    desejada.

    por exemplo, para usar "asyncio.SelectorEventLoop" no Windows:

       import asyncio

       async def main():
           ...

       asyncio.run(main(), loop_factory=asyncio.SelectorEventLoop)

    (Contribuição de Kumar Aditya em gh-127949.)

* "builtins":

  * A inversão bit a bit em tipos booleanos, "~True" ou "~False" foi
    descontinuada desde o Python 3.12, pois produz resultados
    surpreendentes e não intuitivos ("-2" e "-1"). Use "not x" em vez
    disso para a negação lógica de um Booleano. No caso raro de você
    precisar da inversão bit a bit do inteiro subjacente, converta
    para "int" explicitamente ("~int(x)").

* "functools":

  * A chamada da implementação Python de "functools.reduce()" com
    *function* ou *sequence* como argumentos nomeados foi
    descontinuada desde o Python 3.14.

* "logging":

  * O suporte para manipuladores de registro personalizados com o
    argumento *strm* foi descontinuado e está programado para ser
    removido no Python 3.16. Em vez disso, defina manipuladores com o
    argumento *stream*. (Contribuição de Mariusz Felisiak em
    gh-115032.)

* "mimetypes":

  * Extensões válidas começam com um '.' ou estão vazias para
    "mimetypes.MimeTypes.add_type()". Extensões sem ponto estão
    descontinuadas e levantarão uma exceção "ValueError" no Python
    3.16. (Contribuição de Hugo van Kemenade em gh-75223.)

* "shutil":

  * A exceção "ExecError" foi descontinuada desde o Python 3.14. Ela
    não foi usada por nenhuma função em "shutil" desde o Python 3.4, e
    agora é um alias de "RuntimeError".

* "symtable":

  * The "symtable.Class.get_methods()" method has been deprecated
    since Python 3.14.

* "sys":

  * The "_enablelegacywindowsfsencoding()" function has been
    deprecated since Python 3.13. Use the
    "PYTHONLEGACYWINDOWSFSENCODING" environment variable instead.

* "sysconfig":

  * A função "sysconfig.expand_makefile_vars()" está descontinuada
    desde o Python 3.14. Em vez disso, use o argumento "vars" de
    "sysconfig.get_paths()".

* "tarfile":

  * The undocumented and unused "TarInfo.tarfile" attribute has been
    deprecated since Python 3.13.


Remoção pendente no Python 3.17
-------------------------------

* "datetime":

  * "strptime()" calls using a format string containing "%e" (day of
    month) without a year. This has been deprecated since Python 3.15.
    (Contributed by Stan Ulbrych in gh-70647.)

* "collections.abc":

  * "collections.abc.ByteString" está programado para remoção no
    Python 3.17.

    Use "isinstance(obj, collections.abc.Buffer)" para testar se "obj"
    implementa o protocolo de buffer em tempo de execução. Para uso em
    anotações de tipo, use "Buffer" ou uma união que especifique
    explicitamente os tipos suportados pelo seu código (por exemplo,
    "bytes | bytearray | memoryview").

    "ByteString" foi originalmente concebido para ser uma classe
    abstrata que serviria como um supertipo de "bytes" e "bytearray".
    No entanto, como o ABC nunca teve métodos, saber que um objeto era
    uma instância de "ByteString" nunca lhe dizia nada de útil sobre o
    objeto. Outros tipos comuns de buffer, como "memoryview", também
    nunca foram entendidos como subtipos de "ByteString" (seja em
    tempo de execução ou por verificadores de tipo estático).

    Veja **PEP 688** para mais detalhes. (Contribuição de Shantanu
    Jain em gh-91896.)

* "encodings":

  * Passing non-ascii *encoding* names to
    "encodings.normalize_encoding()" is deprecated and scheduled for
    removal in Python 3.17. (Contributed by Stan Ulbrych in
    gh-136702.)

* "webbrowser":

  * "webbrowser.MacOSXOSAScript" is deprecated in favour of
    "webbrowser.MacOS". (gh-137586)

* "typing":

  * Antes do Python 3.14, as uniões antigas eram implementadas usando
    a classe privada "typing._UnionGenericAlias". Essa classe não é
    mais necessária para a implementação, mas foi mantida para
    retrocompatibilidade, com remoção prevista para o Python 3.17. Os
    usuários devem usar auxiliares de introspecção documentados, como
    "typing.get_origin()" e "typing.get_args()", em vez de depender de
    detalhes de implementação privada.

  * "typing.ByteString", descontinuada desde o Python 3.9, está
    programada para ser removida no Python 3.17.

    Use "isinstance(obj, collections.abc.Buffer)" para testar se "obj"
    implementa o protocolo de buffer em tempo de execução. Para uso em
    anotações de tipo, use "Buffer" ou uma união que especifique
    explicitamente os tipos suportados pelo seu código (por exemplo,
    "bytes | bytearray | memoryview").

    "ByteString" foi originalmente concebido para ser uma classe
    abstrata que serviria como um supertipo de "bytes" e "bytearray".
    No entanto, como o ABC nunca teve métodos, saber que um objeto era
    uma instância de "ByteString" nunca lhe dizia nada de útil sobre o
    objeto. Outros tipos comuns de buffer, como "memoryview", também
    nunca foram entendidos como subtipos de "ByteString" (seja em
    tempo de execução ou por verificadores de tipo estático).

    Veja **PEP 688** para mais detalhes. (Contribuição de Shantanu
    Jain em gh-91896.)


Remoção pendente no Python 3.18
-------------------------------

* No longer accept a boolean value when a file descriptor is expected.
  (Contributed by Serhiy Storchaka in gh-82626.)

* "decimal":

  * O especificador de formato de "Decimal" não padrão e não
    documentado "'N'", que só é suportado na implementação C do módulo
    "decimal", foi descontinuada desde o Python 3.13. (Contribuição de
    Serhiy Storchaka em gh-89902.)

* Deprecations defined by **PEP 829**:

  * "import" lines in "*name*.pth" files are silently ignored.

  (Contributed by Barry Warsaw in gh-148641.)


Remoção pendente no Python 3.19
-------------------------------

* "ctypes":

  * Troca implícita para o layout de estrutura compatível com MSVC
    definindo "_pack_", mas não "_layout_" em plataformas não Windows.

* "hashlib":

  * In hash function constructors such as "new()" or the direct hash-
    named constructors such as "md5()" and "sha256()", their optional
    initial data parameter could also be passed a keyword argument
    named "data=" or "string=" in various "hashlib" implementations.

    Support for the "string" keyword argument name is now deprecated
    and slated for removal in Python 3.19.

    Before Python 3.13, the "string" keyword parameter was not
    correctly supported depending on the backend implementation of
    hash functions. Prefer passing the initial data as a positional
    argument for maximum backwards compatibility.

* "http.cookies":

  * "http.cookies.Morsel.js_output()" is deprecated and will be
    removed in Python 3.19.

  * "http.cookies.BaseCookie.js_output()" is deprecated and will be
    removed in Python 3.19.

* "imaplib":

  * Altering "IMAP4.file" is now deprecated and slated for removal in
    Python 3.19. This property is now unused and changing its value
    does not automatically close the current file.

    Before Python 3.14, this property was used to implement the
    corresponding "read()" and "readline()" methods for "IMAP4" but
    this is no longer the case since then.


Remoção pendente no Python 3.20
-------------------------------

* Calling the "__new__()" method of "struct.Struct" without the
  *format* argument is deprecated and will be removed in Python 3.20.
  Calling "__init__()" method on initialized "Struct" objects is
  deprecated and will be removed in Python 3.20.

  (Contributed by Sergey B Kirpichev and Serhiy Storchaka in
  gh-143715.)

* The "__version__", "version" and "VERSION" attributes have been
  deprecated in these standard library modules and will be removed in
  Python 3.20. Use "sys.version_info" instead.

  * "argparse"

  * "csv"

  * "ctypes"

  * "ctypes.macholib"

  * "decimal" (use "decimal.SPEC_VERSION" instead)

  * "http.server"

  * "imaplib"

  * "ipaddress"

  * "json"

  * "logging" ("__date__" also deprecated)

  * "optparse"

  * "pickle"

  * "platform"

  * "re"

  * "socketserver"

  * "tabnanny"

  * "tarfile"

  * "tkinter.font"

  * "tkinter.ttk"

  * "wsgiref.simple_server"

  * "xml.etree.ElementTree"

  * "xml.sax.expatreader"

  * "xml.sax.handler"

  * "zlib"

  (Contributed by Hugo van Kemenade and Stan Ulbrych in gh-76007.)

* Deprecations defined by **PEP 829**:

  * Warnings are produced for "import" lines found in "*name*.pth"
    files.

  * "*name*.pth" files are no longer decoded in the locale encoding by
    default.  They **MUST** be encoded in "utf-8-sig".

  (Contributed by Barry Warsaw in gh-148641.)

* "ast":

  * Creating instances of abstract AST nodes (such as "ast.AST" or
    "ast.expr") is deprecated and will raise an error in Python 3.20.


Remoção pendente em versões futuras
-----------------------------------

As APIs a seguir serão removidas no futuro, embora atualmente não haja
uma data agendada para sua remoção.

* "argparse":

  * O aninhamento de grupos de argumentos e o aninhamento de grupos
    mutuamente exclusivos estão descontinuado.

  * A passagem do argumento nomeado não documentado *prefix_chars*
    para "add_argument_group()" agora está descontinuado.

  * O conversor de tipo "argparse.FileType" está descontinuado.

* "builtins":

  * Geradores: a assinatura "throw(type, exc, tb)" e "athrow(type,
    exc, tb)" está descontinuada: use "throw(exc)" e "athrow(exc)", a
    assinatura do argumento único.

  * Atualmente Python aceita literais numéricos imediatamente seguidos
    por palavras reservadas como, por exemplo, "0in x", "1or x", "0if
    1else 2". Ele permite expressões confusas e ambíguas como "[0x1for
    x in y]" (que pode ser interpretada como "[0x1 for x in y]" ou
    "[0x1f or x in y]"). Um aviso de sintaxe é levantado se o literal
    numérico for imediatamente seguido por uma das palavras reservadas
    "and", "else", "for", "if", "in" , "is" e "or". Em uma versão
    futura, será alterado para um erro de sintaxe. (gh-87999)

  * Suporte para métodos "__index__()" e "__int__()" retornando tipo
    não-int: esses métodos serão necessários para retornar uma
    instância de uma subclasse estrita de "int".

  * Suporte para o método "__float__()" retornando uma subclasse
    estrita de "float": esses métodos serão necessários para retornar
    uma instância de "float".

  * Suporte para o método "__complex__()" retornando uma subclasse
    estrita de "complex": esses métodos serão necessários para
    retornar uma instância de "complex".

  * Passar um número complexo como argumento *real* ou *imag* no
    construtor "complex()" agora está descontinuado; deve ser passado
    apenas como um único argumento posicional. (Contribuição de Serhiy
    Storchaka em gh-109218.)

* "calendar": as constantes "calendar.January" e "calendar.February"
  foram descontinuadas e substituídas por "calendar.JANUARY" e
  "calendar.FEBRUARY". (Contribuição de Prince Roshan em gh-103636.)

* "codecs": use "open()" em vez de "codecs.open()". (gh-133038)

* "codeobject.co_lnotab": use the "codeobject.co_lines()" method
  instead.

* "datetime":

  * "utcnow()": use "datetime.datetime.now(tz=datetime.UTC)".

  * "utcfromtimestamp()": use
    "datetime.datetime.fromtimestamp(timestamp, tz=datetime.UTC)".

* "gettext": o valor de plural deve ser um número inteiro.

* "importlib":

  * O parâmetro *debug_override* de "cache_from_source()" foi
    descontinuado: em vez disso, use o parâmetro *optimization*.

* "importlib.metadata":

  * Interface de tupla "EntryPoints".

  * "None" implícito nos valores de retorno.

* "logging": o método "warn()" foi descontinuado desde o Python 3.3,
  use "warning()".

* "mailbox": o uso da entrada StringIO e do modo de texto foi
  descontinuado; em vez disso, use BytesIO e o modo binário.

* "os": Calling "os.register_at_fork()" in a multi-threaded process.

* "os.path": "os.path.commonprefix()" is deprecated, use
  "os.path.commonpath()" for path prefixes. The
  "os.path.commonprefix()" function is being deprecated due to having
  a misleading name and module. The function is not safe to use for
  path prefixes despite being included in a module about path
  manipulation, meaning it is easy to accidentally introduce path
  traversal vulnerabilities into Python programs by using this
  function.

* "pydoc.ErrorDuringImport": um valor de tupla para o parâmetro
  *exc_info* foi descontinuado, use uma instância de exceção.

* "re": regras mais rigorosas agora são aplicadas para referências
  numéricas de grupos e nomes de grupos em expressões regulares.
  Apenas a sequência de dígitos ASCII agora é aceita como referência
  numérica. O nome do grupo em padrões de bytes e strings de
  substituição agora pode conter apenas letras e dígitos ASCII e
  sublinhado. (Contribuição de Serhiy Storchaka em gh-91760.)

* "shutil": o parâmetro *onerror* de "rmtree()" foi descontinuado no
  Python 3.12; use o parâmetro *onexc*.

* Protocolos e opções de "ssl"

  * "ssl.SSLContext" sem argumento de protocolo foi descontinuado.

  * "ssl.SSLContext": "set_npn_protocols()" e
    "selected_npn_protocol()" foram descontinuados: use ALPN.

  * Opções de "ssl.OP_NO_SSL*"

  * Opções de "ssl.OP_NO_TLS*"

  * "ssl.PROTOCOL_SSLv3"

  * "ssl.PROTOCOL_TLS"

  * "ssl.PROTOCOL_TLSv1"

  * "ssl.PROTOCOL_TLSv1_1"

  * "ssl.PROTOCOL_TLSv1_2"

  * "ssl.TLSVersion.SSLv3"

  * "ssl.TLSVersion.TLSv1"

  * "ssl.TLSVersion.TLSv1_1"

* Métodos de "threading":

  * "threading.Condition.notifyAll()": use "notify_all()".

  * "threading.Event.isSet()": use "is_set()".

  * "threading.Thread.isDaemon()", "threading.Thread.setDaemon()": use
    o atributo "threading.Thread.daemon".

  * "threading.Thread.getName()", "threading.Thread.setName()": use o
    atributo "threading.Thread.name".

  * "threading.currentThread()": use "threading.current_thread()".

  * "threading.activeCount()": use "threading.active_count()".

* "typing.Text" (gh-92332).

* A classe interna "typing._UnionGenericAlias" não é mais usada para
  implementar "typing.Union". Para preservar a compatibilidade com
  usuários que utilizam esta classe privada, uma correção de
  compatibilidade será fornecida pelo menos até a versão 3.17 do
  Python. (Contribuição de Jelle Zijlstra em gh-105499.)

* "unittest.IsolatedAsyncioTestCase": foi descontinuado retornar um
  valor que não seja "None" de um caso de teste.

* Funções descontinuadas de "urllib.parse": use "urlparse()"

  * "splitattr()"

  * "splithost()"

  * "splitnport()"

  * "splitpasswd()"

  * "splitport()"

  * "splitquery()"

  * "splittag()"

  * "splittype()"

  * "splituser()"

  * "splitvalue()"

  * "to_bytes()"

* "wsgiref": "SimpleHandler.stdout.write()" não deve fazer gravações
  parciais.

* "xml.etree.ElementTree": testar o valor verdade de um "Element" está
  descontinuado. Em um lançamento futuro isso sempre retornará "True".
  Em vez disso, prefira os testes explícitos "len(elem)" ou "elem is
  not None".

* "sys._clear_type_cache()" está descontinuada: use
  "sys._clear_internal_caches()".


Soft deprecations
-----------------

There are no plans to remove *soft deprecated* APIs.

* "re.match()" and "re.Pattern.match()" are now *soft deprecated* in
  favor of the new "re.prefixmatch()" and "re.Pattern.prefixmatch()"
  APIs, which have been added as alternate, more explicit names. These
  are intended to be used to alleviate confusion around what *match*
  means by following the Zen of Python's *"Explicit is better than
  implicit"* mantra. Most other language regular expression libraries
  use an API named *match* to mean what Python has always called
  *search*.

  We **do not** plan to remove the older "match()" name, as it has
  been used in code for over 30 years. Code supporting older versions
  of Python should continue to use "match()", while new code should
  prefer "prefixmatch()". See prefixmatch() vs. match().

  (Contributed by Gregory P. Smith in gh-86519 and Hugo van Kemenade
  in gh-148100.)


Alterações na API C
===================


Novas funcionalidades
---------------------

* Add "PyArg_ParseArray()" and "PyArg_ParseArrayAndKeywords()"
  functions to parse arguments of functions using the "METH_FASTCALL"
  calling convention. (Contributed by Victor Stinner in gh-144175.)

* Add the following functions for the new "frozendict" type:

  * "PyAnyDict_Check()"

  * "PyAnyDict_CheckExact()"

  * "PyFrozenDict_Check()"

  * "PyFrozenDict_CheckExact()"

  * "PyFrozenDict_New()"

  (Contributed by Victor Stinner in gh-141510.)

* Add "PyObject_CallFinalizerFromDealloc()" function to the limited C
  API. (Contributed by Victor Stinner in gh-146063.)

* Add "PySys_GetAttr()", "PySys_GetAttrString()",
  "PySys_GetOptionalAttr()", and "PySys_GetOptionalAttrString()"
  functions as replacements for "PySys_GetObject()". (Contributed by
  Serhiy Storchaka in gh-108512.)

* Add "PyUnstable_Unicode_GET_CACHED_HASH" to get the cached hash of a
  string. See the documentation for caveats. (Contributed by Petr
  Viktorin in gh-131510.)

* Add API for checking an extension module's ABI compatibility:
  "Py_mod_abi", "PyABIInfo_Check()", and "PyABIInfo_VAR". (Contributed
  by Petr Viktorin in gh-137210.)

* Implement **PEP 782**, the PyBytesWriter API. Add functions:

  * "PyBytesWriter_Create()"

  * "PyBytesWriter_Discard()"

  * "PyBytesWriter_FinishWithPointer()"

  * "PyBytesWriter_FinishWithSize()"

  * "PyBytesWriter_Finish()"

  * "PyBytesWriter_Format()"

  * "PyBytesWriter_GetData()"

  * "PyBytesWriter_GetSize()"

  * "PyBytesWriter_GrowAndUpdatePointer()"

  * "PyBytesWriter_Grow()"

  * "PyBytesWriter_Resize()"

  * "PyBytesWriter_WriteBytes()"

  (Contributed by Victor Stinner in gh-129813.)

* "PyCriticalSection" and related functions are added to the Stable
  ABI.

  (Contributed in gh-149227.)

* Add a new "PyImport_CreateModuleFromInitfunc()" C-API for creating a
  module from a *spec* and *initfunc*. (Contributed by Itamar Oren in
  gh-116146.)

* Add "PyTuple_FromArray()" to create a "tuple" from an array.
  (Contributed by Victor Stinner in gh-111489.)

* Add a new module export hook, "PyModExport_*".

  (Contributed by Petr Viktorin in **PEP 793** and gh-140550.)

* Add functions that are guaranteed to be safe for use in
  "tp_traverse" handlers: "PyObject_GetTypeData_DuringGC()",
  "PyObject_GetItemData_DuringGC()",
  "PyType_GetModuleState_DuringGC()", "PyModule_GetState_DuringGC()",
  "PyModule_GetToken_DuringGC()", "PyType_GetBaseByToken_DuringGC()",
  "PyType_GetModule_DuringGC()", "PyType_GetModuleByToken_DuringGC()".
  (Contributed by Petr Viktorin in gh-145925.)

* Add "PyObject_Dump()" to dump an object to "stderr". It should only
  be used for debugging. (Contributed by Victor Stinner in gh-141070.)

* Implement **PEP 820**: "PySlot" -- Unified slot system for the C
  API. See Definition slots for documentation.

  This adds:

  * The "PySlot" struct;

  * the "PyType_FromSlots()" function;

  * new slot IDs: "Py_slot_end", "Py_slot_invalid";
    "Py_slot_subslots", "Py_tp_slots", "Py_mod_slots"; "Py_tp_name",
    "Py_tp_basicsize", "Py_tp_extra_basicsize", "Py_tp_itemsize",
    "Py_tp_flags", "Py_tp_metaclass", "Py_tp_module";

  * convenience macros: "PySlot_DATA", "PySlot_FUNC", "PySlot_SIZE",
    "PySlot_INT64", "PySlot_UINT64", "PySlot_STATIC_DATA",
    "PySlot_END", "PySlot_PTR", "PySlot_PTR_STATIC".

  The "PyModule_FromSlotsAndSpec()" function and "PyModExport" module
  export hook also use the new "PySlot" struct.

  These following functions are *soft deprecated*:

  * "PyType_FromSpec()"

  * "PyType_FromSpecWithBases()"

  * "PyType_FromModuleAndSpec()"

  * "PyType_FromMetaclass()"

  * "PyModule_FromDefAndSpec()"

  * "PyModule_FromDefAndSpec2()"

  * "PyModule_ExecDef()"

  (Contributed by Petr Viktorin in gh-149044.)

* Adicionadas as funções "PyUnstable_ThreadState_SetStackProtection()"
  e "PyUnstable_ThreadState_ResetStackProtection()" para definir o
  endereço base e o tamanho da proteção de pilha de um estado de
  thread Python. (Contribuição de Victor Stinner em gh-139653.)

* Add "PyUnstable_SetImmortal()" C-API function to mark objects as
  *immortal*. (Contributed by Kumar Aditya in gh-143300.)

* Restore private provisional "_Py_InitializeMain()" function removed
  in Python 3.14. (Contributed by Victor Stinner in gh-142417.)

* Add "PyUnstable_DumpTraceback()" and
  "PyUnstable_DumpTracebackThreads()" functions to output Python
  stacktraces. (Contributed by Alex Malyshev in gh-145559.)


Alterações na API C
-------------------

* If the "Py_TPFLAGS_MANAGED_DICT" or "Py_TPFLAGS_MANAGED_WEAKREF"
  flag is set then "Py_TPFLAGS_HAVE_GC" must be set too. (Contributed
  by Sergey Miryanov in gh-134786.)

* "PyDateTime_IMPORT" is now thread safe. Code that directly checks
  "PyDateTimeAPI" for "NULL" should be updated to call
  "PyDateTime_IMPORT" instead. (Contributed by Kumar Aditya in
  gh-141563.)


APIs C removidas
----------------

* Remove deprecated "PyUnicode" functions:

  * "PyUnicode_AsDecodedObject()": use "PyCodec_Decode()".

  * "PyUnicode_AsDecodedUnicode()": Use "PyCodec_Decode()" instead;
    note that some codecs (for example, "base64") may return a type
    other than "str", such as "bytes".

  * "PyUnicode_AsEncodedObject()": use "PyCodec_Encode()".

  * "PyUnicode_AsEncodedUnicode()": Use "PyCodec_Encode()" instead;
    note that some codecs (for example, "base64") may return a type
    other than "bytes", such as "str".

  (Contributed by Stan Ulbrych in gh-133612.)

* "PyImport_ImportModuleNoBlock()": deprecated alias of
  "PyImport_ImportModule()". (Contributed by Bénédikt Tran in
  gh-133644.)

* "PyWeakref_GetObject()" and "PyWeakref_GET_OBJECT": use
  "PyWeakref_GetRef()" instead. The pythoncapi-compat project can be
  used to get "PyWeakref_GetRef()" on Python 3.12 and older.
  (Contributed by Bénédikt Tran in gh-133644.)

* Remove deprecated "PySys_ResetWarnOptions()". Clear
  "sys.warnoptions" and "warnings.filters" instead.

  (Contributed by Nikita Sobolev in gh-138886.)

The following functions are removed in favor of "PyConfig_Get()". The
pythoncapi-compat project can be used to get "PyConfig_Get()" on
Python 3.13 and older.

* Funções de inicialização do Python

  * "Py_GetExecPrefix()": use "PyConfig_Get("base_exec_prefix")"
    ("sys.base_exec_prefix") instead. Use
    "PyConfig_Get("exec_prefix")" ("sys.exec_prefix") if virtual
    environments need to be handled.

  * "Py_GetPath()": use "PyConfig_Get("module_search_paths")"
    ("sys.path") instead.

  * "Py_GetPrefix()": use "PyConfig_Get("base_prefix")"
    ("sys.base_prefix") instead. Use "PyConfig_Get("prefix")"
    ("sys.prefix") if virtual environments need to be handled.

  * "Py_GetProgramFullPath()": use "PyConfig_Get("executable")"
    ("sys.executable") instead.

  * "Py_GetProgramName()": use "PyConfig_Get("executable")"
    ("sys.executable") instead.

  * "Py_GetPythonHome()": use "PyConfig_Get("home")" or the
    "PYTHONHOME" environment variable instead.

  (Contributed by Bénédikt Tran in gh-133644.)


APIs C descontinuadas
---------------------

* Deprecate **PEP 456** support for providing an external definition
  of the string hashing scheme. Removal is scheduled for Python 3.19.

  Previously, embedders could define "Py_HASH_ALGORITHM" to be
  "Py_HASH_EXTERNAL" to indicate that the hashing scheme was provided
  externally but this feature was undocumented, untested and most
  likely unused.

  (Contributed by Bénédikt Tran in gh-141226.)

* For unsigned integer formats in "PyArg_ParseTuple()", accepting
  Python integers with value that is larger than the maximal value for
  the C type or less than the minimal value for the corresponding
  signed integer type of the same size is now deprecated. (Contributed
  by Serhiy Storchaka in gh-132629.)

* "PyBytes_FromStringAndSize(NULL, len)" and "_PyBytes_Resize()" are
  *soft deprecated*, use the "PyBytesWriter" API instead. (Contributed
  by Victor Stinner in gh-129813.)

* "_PyObject_CallMethodId()", "_PyObject_GetAttrId()" e
  "_PyUnicode_FromId()" foram descontinuadas desde o 3.15 e serão
  removidas na versão 3.20. Em vez delas, use
  "PyUnicode_InternFromString()" and armazene em cache o resultado no
  estado do módulo e chame "PyObject_CallMethod()" ou
  "PyObject_GetAttr()". (Contribuição de Victor Stinner em gh-141049.)

* Deprecate "cval" field of the "PyComplexObject" type. Use
  "PyComplex_AsCComplex()" and "PyComplex_FromCComplex()" to convert a
  Python complex number to/from the C "Py_complex" representation.
  (Contributed by Sergey B Kirpichev in gh-128813.)

* Functions "_Py_c_sum()", "_Py_c_diff()", "_Py_c_neg()",
  "_Py_c_prod()", "_Py_c_quot()", "_Py_c_pow()" and "_Py_c_abs()" are
  *soft deprecated*. (Contributed by Sergey B Kirpichev in gh-128813.)

* "bytes_warning" is deprecated since 3.15 and will be removed in
  3.17. (Contributed by Nikita Sobolev in gh-136355.)

* "Py_INFINITY" macro is *soft deprecated*, use the C11 standard
  "<math.h>" "INFINITY" instead. (Contributed by Sergey B Kirpichev in
  gh-141004.)

* The following macros are *soft deprecated*:

  * "Py_ALIGNED": Prefer "alignas" instead.

  * "PY_FORMAT_SIZE_T": Use ""z"" directly.

  * "Py_LL" and "Py_ULL": Use standard suffixes, "LL" and "ULL".

  * "PY_LONG_LONG", "PY_LLONG_MIN", "PY_LLONG_MAX", "PY_ULLONG_MAX",
    "PY_INT32_T", "PY_UINT32_T", "PY_INT64_T", "PY_UINT64_T",
    "PY_SIZE_MAX": Use C99 types/limits.

  * "Py_UNICODE_SIZE": Use "sizeof(wchar_t)" directly.

  * "Py_VA_COPY": Use "va_copy" directly.

  The macro "Py_UNICODE_WIDE", which was scheduled for removal, is
  *soft deprecated* instead.

  (Contributed by Petr Viktorin in gh-146175.)

* "Py_MATH_El" and "Py_MATH_PIl" are deprecated since 3.15 and will be
  removed in 3.20. (Contributed by Sergey B Kirpichev in gh-141004.)


Alterações na construção
========================

* Removed implicit fallback to the bundled copy of the "libmpdec"
  library. Now this should be explicitly enabled with "--with-system-
  libmpdec" set to "no" or with "--without-system-libmpdec".
  (Contributed by Sergey B Kirpichev in gh-115119.)

* The new configure option "--with-missing-stdlib-config=FILE" allows
  distributors to pass a JSON configuration file containing custom
  error messages for *standard library* modules that are missing or
  packaged separately. (Contributed by Stan Ulbrych and Petr Viktorin
  in gh-139707.)

* The new configure option "--with-pymalloc-hugepages" enables huge
  page support for pymalloc arenas. When enabled, arena size increases
  to 2 MiB and allocation uses "MAP_HUGETLB" (Linux) or
  "MEM_LARGE_PAGES" (Windows) with automatic fallback to regular
  pages. On Windows, use "build.bat --pymalloc-hugepages". At runtime,
  huge pages must be explicitly enabled by setting the
  "PYTHON_PYMALLOC_HUGEPAGES" environment variable to "1".

* Annotating anonymous mmap usage is now supported if Linux kernel
  supports *PR_SET_VMA_ANON_NAME* (Linux 5.17 or newer). Annotations
  are visible in "/proc/<pid>/maps" if the kernel supports the feature
  and "-X dev" is passed to the Python or Python is built in debug
  mode. (Contributed by Donghee Na in gh-141770.)

* CPython is now built with frame pointers enabled by default (**PEP
  831**). Pass "--without-frame-pointers" to opt out.

  Authors of C extensions and native libraries built with custom build
  systems should ensure the unwind chain is intact. This is usually
  done by adding "-fno-omit-frame-pointer" and similar flags to
  "CFLAGS". See "--without-frame-pointers" documentation for the
  specific flags Python uses.

  (Contributed by Pablo Galindo Salgado and Savannah Ostrowski in
  gh-149201.)

* 64-bit builds using Visual Studio 2026 (MSVC 18) may now use the new
  tail-calling interpreter. Results on Visual Studio 18.1.1 report
  between 15-20% speedup on the geometric mean of pyperformance on
  Windows x86-64 over the switch-case interpreter on an AMD Ryzen 7
  5800X. We have observed speedups ranging from 14% for large pure-
  Python libraries to 40% for long-running small pure-Python scripts
  on Windows. This was made possible by a new feature introduced in
  MSVC 18, which the official Windows 64-bit binaries on python.org
  now use. (Contributed by Chris Eibl, Ken Jin, and Brandt Bucher in
  gh-143068. Special thanks to Steve Dower, and the MSVC team
  including Hulon Jenkins.)


Porting to Python 3.15
======================

Esta seção lista as alterações descritas anteriormente e outras
correções que podem exigir alterações no seu código.

* "sqlite3.Connection" APIs have been cleaned up.

  * All parameters of "sqlite3.connect()" except *database* are now
    keyword-only.

  * The first three parameters of methods "create_function()" and
    "create_aggregate()" are now positional-only.

  * The first parameter of methods "set_authorizer()",
    "set_progress_handler()" and "set_trace_callback()" is now
    positional-only.

  (Contributed by Serhiy Storchaka in gh-133595.)

* "resource.RLIM_INFINITY" is now always positive. Passing a negative
  integer value that corresponded to its old value (such as "-1" or
  "-3", depending on platform) to "resource.setrlimit()" and
  "resource.prlimit()" is now deprecated. (Contributed by Serhiy
  Storchaka in gh-137044.)

* "mmap.mmap.resize()" has been removed on platforms that don't
  support the underlying syscall, instead of raising a "SystemError".

* A resource warning is now emitted for an unclosed
  "xml.etree.ElementTree.iterparse()" iterator if it opened a file.
  Use its "close()" method or the "contextlib.closing()" context
  manager to close it. (Contributed by Osama Abdelkader and Serhiy
  Storchaka in gh-140601.)

* If a short option and a single-dash long option are passed to
  "argparse.ArgumentParser.add_argument()", *dest* is now inferred
  from the single-dash long option. For example, in
  "add_argument('-f', '-foo')", *dest* is now "'foo'" instead of
  "'f'". Pass an explicit *dest* argument to preserve the old
  behavior. (Contributed by Serhiy Storchaka in gh-138697.)

* Padding of input no longer required in "base64.urlsafe_b64decode()".
  Pass a new argument "padded=True" or use "base64.b64decode()" with
  argument "altchars=b'-_'" (this works with older Python versions) to
  make padding required. (Contributed by Serhiy Storchaka in
  gh-73613.)

* Since "unittest.TestCase.assertWarns()" and
  "unittest.TestCase.assertWarnsRegex()" no longer swallow warnings
  that do not match the specified category or regex, your tests may
  start leaking some warnings that were previously masked. Use warning
  filters to silence them or additional "assertWarns*()" to catch and
  check them. (Contributed by Serhiy Storchaka in gh-143231.)
