> **Источник:** https://python-all.ru/3.12/deprecations/index.html
>
> «Документация Python на русском» – неофициальный перевод официальной документации Python: версии от 2.6 до 3.16, полнотекстовый поиск, английский оригинал рядом с переводом. Эта Markdown-версия страницы предназначена для работы с LLM: вставьте её в ChatGPT, Claude или Cursor.

---

# Устаревания

## Запланировано к удалению в Python 3.13

Модули (см. [**PEP 594**](https://python-all.ru/3.12/deprecations/index.html)):

- [`aifc`](https://python-all.ru/3.12/library/aifc.html#module-aifc)
- [`audioop`](https://python-all.ru/3.12/library/audioop.html#module-audioop)
- [`cgi`](https://python-all.ru/3.12/library/cgi.html#module-cgi)
- [`cgitb`](https://python-all.ru/3.12/library/cgitb.html#module-cgitb)
- [`chunk`](https://python-all.ru/3.12/library/chunk.html#module-chunk)
- [`crypt`](https://python-all.ru/3.12/library/crypt.html#module-crypt)
- [`imghdr`](https://python-all.ru/3.12/library/imghdr.html#module-imghdr)
- [`mailcap`](https://python-all.ru/3.12/library/mailcap.html#module-mailcap)
- [`msilib`](https://python-all.ru/3.12/library/msilib.html#module-msilib)
- [`nis`](https://python-all.ru/3.12/library/nis.html#module-nis)
- [`nntplib`](https://python-all.ru/3.12/library/nntplib.html#module-nntplib)
- [`ossaudiodev`](https://python-all.ru/3.12/library/ossaudiodev.html#module-ossaudiodev)
- [`pipes`](https://python-all.ru/3.12/library/pipes.html#module-pipes)
- [`sndhdr`](https://python-all.ru/3.12/library/sndhdr.html#module-sndhdr)
- [`spwd`](https://python-all.ru/3.12/library/spwd.html#module-spwd)
- [`sunau`](https://python-all.ru/3.12/library/sunau.html#module-sunau)
- [`telnetlib`](https://python-all.ru/3.12/library/telnetlib.html#module-telnetlib)
- [`uu`](https://python-all.ru/3.12/library/uu.html#module-uu)
- [`xdrlib`](https://python-all.ru/3.12/library/xdrlib.html#module-xdrlib)

Другие модули:

- `lib2to3` и программа **2to3** ([gh-84540](https://python-all.ru/3.12/deprecations/index.html))

API:

- `configparser.LegacyInterpolation` ([gh-90765](https://python-all.ru/3.12/deprecations/index.html))
- `locale.resetlocale()` ([gh-90817](https://python-all.ru/3.12/deprecations/index.html))
- `turtle.RawTurtle.settiltangle()` ([gh-50096](https://python-all.ru/3.12/deprecations/index.html))
- `unittest.findTestCases()` ([gh-50096](https://python-all.ru/3.12/deprecations/index.html))
- `unittest.getTestCaseNames()` ([gh-50096](https://python-all.ru/3.12/deprecations/index.html))
- `unittest.makeSuite()` ([gh-50096](https://python-all.ru/3.12/deprecations/index.html))
- `unittest.TestProgram.usageExit()` ([gh-67048](https://python-all.ru/3.12/deprecations/index.html))
- `webbrowser.MacOSX` ([gh-86421](https://python-all.ru/3.12/deprecations/index.html))
- [`classmethod`](https://python-all.ru/3.12/library/functions.html#classmethod) цепочка дескрипторов ([gh-89519](https://python-all.ru/3.12/deprecations/index.html))
- [`importlib.resources`](https://python-all.ru/3.12/library/importlib.resources.html#module-importlib.resources) устаревшие методы:

  - `contents()`
  - `is_resource()`
  - `open_binary()`
  - `open_text()`
  - `path()`
  - `read_binary()`
  - `read_text()`

  Вместо этого используйте [`importlib.resources.files()`](https://python-all.ru/3.12/library/importlib.resources.html#importlib.resources.files). См. [importlib-resources: Migrating from Legacy](https://python-all.ru/3.12/deprecations/index.html) ([gh-106531](https://python-all.ru/3.12/deprecations/index.html))

## Запланировано к удалению в Python 3.14

- [`argparse`](https://python-all.ru/3.12/library/argparse.html#module-argparse): Параметры *type*, *choices* и *metavar* функции `argparse.BooleanOptionalAction` устарели и будут удалены в версии 3.14. (Автор: Nikita Sobolev в [gh-92248](https://python-all.ru/3.12/deprecations/index.html).)
- [`ast`](https://python-all.ru/3.12/library/ast.html#module-ast): Следующие возможности были объявлены устаревшими в документации начиная с Python 3.8, теперь при обращении к ним или их использовании во время выполнения вызывается [`DeprecationWarning`](https://python-all.ru/3.12/library/exceptions.html#DeprecationWarning), и они будут удалены в Python 3.14:

  - `ast.Num`
  - `ast.Str`
  - `ast.Bytes`
  - `ast.NameConstant`
  - `ast.Ellipsis`

  Вместо этого используйте [`ast.Constant`](https://python-all.ru/3.12/library/ast.html#ast.Constant). (Автор: Serhiy Storchaka в [gh-90953](https://python-all.ru/3.12/deprecations/index.html).)
- [`asyncio`](https://python-all.ru/3.12/library/asyncio.html#module-asyncio):

  - Классы наблюдателя дочерних процессов [`MultiLoopChildWatcher`](https://python-all.ru/3.12/library/asyncio-policy.html#asyncio.MultiLoopChildWatcher), [`FastChildWatcher`](https://python-all.ru/3.12/library/asyncio-policy.html#asyncio.FastChildWatcher), [`AbstractChildWatcher`](https://python-all.ru/3.12/library/asyncio-policy.html#asyncio.AbstractChildWatcher) и [`SafeChildWatcher`](https://python-all.ru/3.12/library/asyncio-policy.html#asyncio.SafeChildWatcher) устарели и будут удалены в Python 3.14. (Автор: Kumar Aditya в [gh-94597](https://python-all.ru/3.12/deprecations/index.html).)
  - [`asyncio.set_child_watcher()`](https://python-all.ru/3.12/library/asyncio-policy.html#asyncio.set_child_watcher), [`asyncio.get_child_watcher()`](https://python-all.ru/3.12/library/asyncio-policy.html#asyncio.get_child_watcher), [`asyncio.AbstractEventLoopPolicy.set_child_watcher()`](https://python-all.ru/3.12/library/asyncio-policy.html#asyncio.AbstractEventLoopPolicy.set_child_watcher) и [`asyncio.AbstractEventLoopPolicy.get_child_watcher()`](https://python-all.ru/3.12/library/asyncio-policy.html#asyncio.AbstractEventLoopPolicy.get_child_watcher) объявлены устаревшими и будут удалены в Python 3.14. (Автор: Kumar Aditya, [gh-94597](https://python-all.ru/3.12/deprecations/index.html).)
  - Метод [`get_event_loop()`](https://python-all.ru/3.12/library/asyncio-eventloop.html#asyncio.get_event_loop) политики цикла событий по умолчанию теперь генерирует [`DeprecationWarning`](https://python-all.ru/3.12/library/exceptions.html#DeprecationWarning), если текущий цикл событий не установлен и он решает создать новый. (Авторы: Serhiy Storchaka и Guido van Rossum, [gh-100160](https://python-all.ru/3.12/deprecations/index.html).)
- [`collections.abc`](https://python-all.ru/3.12/library/collections.abc.html#module-collections.abc): Устарел [`ByteString`](https://python-all.ru/3.12/library/collections.abc.html#collections.abc.ByteString). Рекомендуется `Sequence` или [`Buffer`](https://python-all.ru/3.12/library/collections.abc.html#collections.abc.Buffer). Для использования в typing предпочтите объединение, например `bytes | bytearray`, или [`collections.abc.Buffer`](https://python-all.ru/3.12/library/collections.abc.html#collections.abc.Buffer). (Автор: Shantanu Jain, [gh-91896](https://python-all.ru/3.12/deprecations/index.html).)
- [`email`](https://python-all.ru/3.12/library/email.html#module-email): объявлен устаревшим параметр *isdst* в [`email.utils.localtime()`](https://python-all.ru/3.12/library/email.utils.html#email.utils.localtime). (Автор: Alan Williams, [gh-72346](https://python-all.ru/3.12/deprecations/index.html).)
- [`importlib`](https://python-all.ru/3.12/library/importlib.html#module-importlib): `__package__` и `__cached__` больше не будут устанавливаться или учитываться системой импорта ([gh-97879](https://python-all.ru/3.12/deprecations/index.html)).
- [`importlib.abc`](https://python-all.ru/3.12/library/importlib.html#module-importlib.abc) устаревшие классы:

  - `importlib.abc.ResourceReader`
  - `importlib.abc.Traversable`
  - `importlib.abc.TraversableResources`

  Вместо них используйте классы [`importlib.resources.abc`](https://python-all.ru/3.12/library/importlib.resources.abc.html#module-importlib.resources.abc):

  - [`importlib.resources.abc.Traversable`](https://python-all.ru/3.12/library/importlib.resources.abc.html#importlib.resources.abc.Traversable)
  - [`importlib.resources.abc.TraversableResources`](https://python-all.ru/3.12/library/importlib.resources.abc.html#importlib.resources.abc.TraversableResources)

  (Авторы: Jason R. Coombs и Hugo van Kemenade в [gh-93963](https://python-all.ru/3.12/deprecations/index.html).)
- [`itertools`](https://python-all.ru/3.12/library/itertools.html#module-itertools) имел недокументированную, неэффективную, исторически ошибочную и непоследовательную поддержку операций copy, deepcopy и pickle. Это будет удалено в версии 3.14 для значительного сокращения объёма кода и нагрузки по сопровождению. (Автор: Raymond Hettinger, [gh-101588](https://python-all.ru/3.12/deprecations/index.html).)
- [`multiprocessing`](https://python-all.ru/3.12/library/multiprocessing.html#module-multiprocessing): метод запуска по умолчанию изменится на более безопасный на Linux, BSD и других POSIX-платформах (кроме macOS), где в настоящее время по умолчанию используется `'fork'` ([gh-84559](https://python-all.ru/3.12/deprecations/index.html)). Добавление предупреждения во время выполнения было сочтено слишком деструктивным, так как большинству кода это не важно. Используйте API [`get_context()`](https://python-all.ru/3.12/library/multiprocessing.html#multiprocessing.get_context) или [`set_start_method()`](https://python-all.ru/3.12/library/multiprocessing.html#multiprocessing.set_start_method), чтобы явно указать, когда код *требует* `'fork'`. См. [Контексты и методы запуска](https://python-all.ru/3.12/library/multiprocessing.html#multiprocessing-start-methods).
- [`pathlib`](https://python-all.ru/3.12/library/pathlib.html#module-pathlib): [`is_relative_to()`](https://python-all.ru/3.12/library/pathlib.html#pathlib.PurePath.is_relative_to) и [`relative_to()`](https://python-all.ru/3.12/library/pathlib.html#pathlib.PurePath.relative_to): передача дополнительных аргументов объявлена устаревшей.
- [`pkgutil`](https://python-all.ru/3.12/library/pkgutil.html#module-pkgutil): [`find_loader()`](https://python-all.ru/3.12/library/pkgutil.html#pkgutil.find_loader) и [`get_loader()`](https://python-all.ru/3.12/library/pkgutil.html#pkgutil.get_loader) теперь вызывают [`DeprecationWarning`](https://python-all.ru/3.12/library/exceptions.html#DeprecationWarning); используйте [`importlib.util.find_spec()`](https://python-all.ru/3.12/library/importlib.html#importlib.util.find_spec) вместо этого. (Автор: Nikita Sobolev, [gh-97850](https://python-all.ru/3.12/deprecations/index.html).)
- [`pty`](https://python-all.ru/3.12/library/pty.html#module-pty):

  - `master_open()`: используйте [`pty.openpty()`](https://python-all.ru/3.12/library/pty.html#pty.openpty).
  - `slave_open()`: используйте [`pty.openpty()`](https://python-all.ru/3.12/library/pty.html#pty.openpty).
- [`sqlite3`](https://python-all.ru/3.12/library/sqlite3.html#module-sqlite3):

  - [`version`](https://python-all.ru/3.12/library/sqlite3.html#sqlite3.version) и [`version_info`](https://python-all.ru/3.12/library/sqlite3.html#sqlite3.version_info).
  - [`execute()`](https://python-all.ru/3.12/library/sqlite3.html#sqlite3.Cursor.execute) и [`executemany()`](https://python-all.ru/3.12/library/sqlite3.html#sqlite3.Cursor.executemany), если используются [именованные заполнители](https://python-all.ru/3.12/library/sqlite3.html#sqlite3-placeholders) и *параметры* являются последовательностью, а не [`dict`](https://python-all.ru/3.12/library/stdtypes.html#dict).
- [`typing`](https://python-all.ru/3.12/library/typing.html#module-typing): [`ByteString`](https://python-all.ru/3.12/library/typing.html#typing.ByteString), устаревший начиная с Python 3.9, теперь вызывает [`DeprecationWarning`](https://python-all.ru/3.12/library/exceptions.html#DeprecationWarning) при использовании.
- [`urllib`](https://python-all.ru/3.12/library/urllib.html#module-urllib): `urllib.parse.Quoter` объявлен устаревшим: он не был задуман как публичный API. (Автор: Gregory P. Smith, [gh-88168](https://python-all.ru/3.12/deprecations/index.html).)

## Запланировано к удалению в Python 3.15

- [`http.server.CGIHTTPRequestHandler`](https://python-all.ru/3.12/library/http.server.html#http.server.CGIHTTPRequestHandler) будет удалён вместе со связанным флагом `--cgi` для `python -m http.server`. Он был устаревшим и редко использовался. Прямой замены не существует. *Что угодно* лучше, чем CGI, для взаимодействия веб-сервера с обработчиком запросов.
- [`importlib`](https://python-all.ru/3.12/library/importlib.html#module-importlib):

  - Метод `load_module()`: вместо него используйте `exec_module()`.
- [`locale`](https://python-all.ru/3.12/library/locale.html#module-locale): [`locale.getdefaultlocale()`](https://python-all.ru/3.12/library/locale.html#locale.getdefaultlocale) был устаревшим в Python 3.11 и изначально планировался к удалению в Python 3.13 ([gh-90817](https://python-all.ru/3.12/deprecations/index.html)), но удаление было отложено до Python 3.15. Вместо этого используйте [`locale.setlocale()`](https://python-all.ru/3.12/library/locale.html#locale.setlocale), [`locale.getencoding()`](https://python-all.ru/3.12/library/locale.html#locale.getencoding) и [`locale.getlocale()`](https://python-all.ru/3.12/library/locale.html#locale.getlocale). (Автор: Hugo van Kemenade, [gh-111187](https://python-all.ru/3.12/deprecations/index.html).)
- [`pathlib`](https://python-all.ru/3.12/library/pathlib.html#module-pathlib): [`pathlib.PurePath.is_reserved()`](https://python-all.ru/3.12/library/pathlib.html#pathlib.PurePath.is_reserved) устарел и запланирован к удалению в Python 3.15. Начиная с Python 3.13, используйте `os.path.isreserved` для обнаружения зарезервированных путей в Windows.
- [`platform`](https://python-all.ru/3.12/library/platform.html#module-platform): [`java_ver()`](https://python-all.ru/3.12/library/platform.html#platform.java_ver) устарел и будет удалён в 3.15. Он был в основном не протестирован, имел запутанный API и был полезен только для поддержки Jython. (Автор: Nikita Sobolev, [gh-116349](https://python-all.ru/3.12/deprecations/index.html).)
- [`sysconfig`](https://python-all.ru/3.12/library/sysconfig.html#module-sysconfig):

  - Аргумент *check\_home* функции [`sysconfig.is_python_build()`](https://python-all.ru/3.12/library/sysconfig.html#sysconfig.is_python_build) считается устаревшим начиная с Python 3.12.
- [`threading`](https://python-all.ru/3.12/library/threading.html#module-threading): Передача любых аргументов в [`threading.RLock()`](https://python-all.ru/3.12/library/threading.html#threading.RLock) теперь устарела. Версия на C допускает любое количество args и kwargs, но они просто игнорируются. Версия на Python не допускает никаких аргументов. Все аргументы будут удалены из [`threading.RLock()`](https://python-all.ru/3.12/library/threading.html#threading.RLock) в Python 3.15. (Автор: Nikita Sobolev, [gh-102029](https://python-all.ru/3.12/deprecations/index.html).)
- [`typing.NamedTuple`](https://python-all.ru/3.12/library/typing.html#typing.NamedTuple):

  - Не документированный синтаксис именованных аргументов для создания классов `NamedTuple` (`NT = NamedTuple("NT", x=int)`) устарел и будет запрещён в 3.15. Вместо этого используйте синтаксис на основе классов или функциональный синтаксис.
- [`types`](https://python-all.ru/3.12/library/types.html#module-types):

  - [`types.CodeType`](https://python-all.ru/3.12/library/types.html#types.CodeType): доступ к [`co_lnotab`](https://python-all.ru/3.12/reference/datamodel.html#codeobject.co_lnotab) был объявлен устаревшим в [**PEP 626**](https://python-all.ru/3.12/deprecations/index.html) начиная с версии 3.10 и планировался к удалению в 3.12, но получил надлежащий [`DeprecationWarning`](https://python-all.ru/3.12/library/exceptions.html#DeprecationWarning) только в 3.12. Может быть удалён в 3.15. (Предложено Никитой Соболевым в [gh-101866](https://python-all.ru/3.12/deprecations/index.html).)
- [`typing`](https://python-all.ru/3.12/library/typing.html#module-typing):

  - При использовании функционального синтаксиса для создания класса `NamedTuple`, отсутствие значения у параметра *fields* (`NT = NamedTuple("NT")`) устарело. Передача `None` в параметр *fields* (`NT = NamedTuple("NT", None)`) также устарела. Оба варианта будут запрещены в Python 3.15. Чтобы создать класс `NamedTuple` с 0 полями, используйте `class NT(NamedTuple): pass` или `NT = NamedTuple("NT", [])`.
- [`typing.TypedDict`](https://python-all.ru/3.12/library/typing.html#typing.TypedDict): При использовании функционального синтаксиса для создания класса `TypedDict`, отсутствие значения у параметра *fields* (`TD = TypedDict("TD")`) устарело. Передача `None` в параметр *fields* (`TD = TypedDict("TD", None)`) также устарела. Оба варианта будут запрещены в Python 3.15. Чтобы создать класс `TypedDict` с 0 полями, используйте `class TD(TypedDict): pass` или `TD = TypedDict("TD", {})`.
- [`wave`](https://python-all.ru/3.12/library/wave.html#module-wave): Устарели методы `getmark()`, `setmark()` и `getmarkers()` классов [`wave.Wave_read`](https://python-all.ru/3.12/library/wave.html#wave.Wave_read) и [`wave.Wave_write`](https://python-all.ru/3.12/library/wave.html#wave.Wave_write). Они будут удалены в Python 3.15. (Автор: Victor Stinner, [gh-105096](https://python-all.ru/3.12/deprecations/index.html).)

## Запланированное удаление в Python 3.16

- Система импорта:

  - Установка [`__loader__`](https://python-all.ru/3.12/reference/datamodel.html#module.__loader__) в модуле при отсутствии [`__spec__.loader`](https://python-all.ru/3.12/library/importlib.html#importlib.machinery.ModuleSpec.loader) устарела. В Python 3.16 `__loader__` перестанет устанавливаться или учитываться системой импорта или стандартной библиотекой.
- [`array`](https://python-all.ru/3.12/library/array.html#module-array): [`array.array`](https://python-all.ru/3.12/library/array.html#array.array) тип `'u'` (`wchar_t`): используйте тип `'w'` вместо него (`Py_UCS4`).
- [`builtins`](https://python-all.ru/3.12/library/builtins.html#module-builtins): `~bool`, побитовая инверсия для bool.
- [`symtable`](https://python-all.ru/3.12/library/symtable.html#module-symtable): Устарел [`symtable.Class.get_methods()`](https://python-all.ru/3.12/library/symtable.html#symtable.Class.get_methods) из-за отсутствия интереса. (Автор: Bénédikt Tran, [gh-119698](https://python-all.ru/3.12/deprecations/index.html).)

## Запланировано к удалению в будущих версиях

Следующие API будут удалены в будущем, хотя на данный момент нет запланированной даты их удаления.

- [`argparse`](https://python-all.ru/3.12/library/argparse.html#module-argparse): Вложение групп аргументов и вложение взаимоисключающих групп устарело.
- Код формата `'u'` для [`array`](https://python-all.ru/3.12/library/array.html#module-array) ([gh-57281](https://python-all.ru/3.12/deprecations/index.html))
- [`builtins`](https://python-all.ru/3.12/library/builtins.html#module-builtins):

  - `bool(NotImplemented)`.
  - Генераторы: сигнатура `throw(type, exc, tb)` и `athrow(type, exc, tb)` устарела: используйте `throw(exc)` и `athrow(exc)` вместо неё, сигнатуру с одним аргументом.
  - В настоящее время Python принимает числовые литералы, за которыми сразу следуют ключевые слова, например `0in x`, `1or x`, `0if 1else 2`. Это допускает запутанные и неоднозначные выражения вроде `[0x1for x in y]` (которое может быть интерпретировано как `[0x1 for x in y]` или `[0x1f or x in y]`). Выдаётся предупреждение синтаксиса, если за числовым литералом сразу следует одно из ключевых слов [`and`](https://python-all.ru/3.12/reference/expressions.html#and), [`else`](https://python-all.ru/3.12/reference/compound_stmts.html#else), [`for`](https://python-all.ru/3.12/reference/compound_stmts.html#for), [`if`](https://python-all.ru/3.12/reference/compound_stmts.html#if), [`in`](https://python-all.ru/3.12/reference/expressions.html#in), [`is`](https://python-all.ru/3.12/reference/expressions.html#is) и [`or`](https://python-all.ru/3.12/reference/expressions.html#or). В будущем выпуске это будет изменено на синтаксическую ошибку. ([gh-87999](https://python-all.ru/3.12/deprecations/index.html))
  - Поддержка методов `__index__()` и `__int__()`, возвращающих не-int тип: эти методы должны будут возвращать экземпляр строгого подкласса [`int`](https://python-all.ru/3.12/library/functions.html#int).
  - Поддержка метода `__float__()`, возвращающего строгий подкласс [`float`](https://python-all.ru/3.12/library/functions.html#float): эти методы должны будут возвращать экземпляр [`float`](https://python-all.ru/3.12/library/functions.html#float).
  - Поддержка метода `__complex__()`, возвращающего строгий подкласс [`complex`](https://python-all.ru/3.12/library/functions.html#complex): эти методы должны будут возвращать экземпляр [`complex`](https://python-all.ru/3.12/library/functions.html#complex).
  - Делегирование `int()` методу `__trunc__()`.
  - Передача комплексного числа в качестве аргумента *real* или *imag* в конструкторе [`complex()`](https://python-all.ru/3.12/library/functions.html#complex) теперь устарела; его следует передавать только как единственный позиционный аргумент. (Автор: Сергей Сторчака в [gh-109218](https://python-all.ru/3.12/deprecations/index.html).)
- [`calendar`](https://python-all.ru/3.12/library/calendar.html#module-calendar): константы `calendar.January` и `calendar.February` устарели и заменены на [`calendar.JANUARY`](https://python-all.ru/3.12/library/calendar.html#calendar.JANUARY) и [`calendar.FEBRUARY`](https://python-all.ru/3.12/library/calendar.html#calendar.FEBRUARY). (Автор: Prince Roshan в [gh-103636](https://python-all.ru/3.12/deprecations/index.html).)
- [`codeobject.co_lnotab`](https://python-all.ru/3.12/reference/datamodel.html#codeobject.co_lnotab): используйте метод [`codeobject.co_lines()`](https://python-all.ru/3.12/reference/datamodel.html#codeobject.co_lines) вместо этого.
- [`datetime`](https://python-all.ru/3.12/library/datetime.html#module-datetime):

  - [`utcnow()`](https://python-all.ru/3.12/library/datetime.html#datetime.datetime.utcnow): используйте `datetime.datetime.now(tz=datetime.UTC)`.
  - [`utcfromtimestamp()`](https://python-all.ru/3.12/library/datetime.html#datetime.datetime.utcfromtimestamp): используйте `datetime.datetime.fromtimestamp(timestamp, tz=datetime.UTC)`.
- [`gettext`](https://python-all.ru/3.12/library/gettext.html#module-gettext): значение множественного числа должно быть целым числом.
- [`importlib`](https://python-all.ru/3.12/library/importlib.html#module-importlib):

  - [`cache_from_source()`](https://python-all.ru/3.12/library/importlib.html#importlib.util.cache_from_source): параметр *debug\_override* устарел: используйте параметр *optimization* вместо него.
- [`importlib.metadata`](https://python-all.ru/3.12/library/importlib.metadata.html#module-importlib.metadata):

  - `EntryPoints`: интерфейс кортежа.
  - Неявное `None` для возвращаемых значений.
- [`mailbox`](https://python-all.ru/3.12/library/mailbox.html#module-mailbox): использование StringIO в режиме ввода и текстовом режиме устарело, используйте BytesIO и двоичный режим.
- [`os`](https://python-all.ru/3.12/library/os.html#module-os): вызов [`os.register_at_fork()`](https://python-all.ru/3.12/library/os.html#os.register_at_fork) в многопоточном процессе.
- `pydoc.ErrorDuringImport`: кортежное значение для параметра *exc\_info* устарело, используйте экземпляр исключения.
- [`re`](https://python-all.ru/3.12/library/re.html#module-re): теперь применяются более строгие правила для числовых ссылок на группы и имён групп в регулярных выражениях. В качестве числовой ссылки теперь принимается только последовательность цифр ASCII. Имя группы в байтовых шаблонах и строках замены теперь может содержать только буквы ASCII, цифры и знак подчёркивания. (Автор: Сергей Сторчака в [gh-91760](https://python-all.ru/3.12/deprecations/index.html).)
- Модули `sre_compile`, `sre_constants` и `sre_parse`.
- [`shutil`](https://python-all.ru/3.12/library/shutil.html#module-shutil): параметр *onerror* метода [`rmtree()`](https://python-all.ru/3.12/library/shutil.html#shutil.rmtree) устарел в Python 3.12; используйте параметр *onexc* вместо него.
- [`ssl`](https://python-all.ru/3.12/library/ssl.html#module-ssl): опции и протоколы:

  - [`ssl.SSLContext`](https://python-all.ru/3.12/library/ssl.html#ssl.SSLContext) без аргумента протокол устарело.
  - [`ssl.SSLContext`](https://python-all.ru/3.12/library/ssl.html#ssl.SSLContext): [`set_npn_protocols()`](https://python-all.ru/3.12/library/ssl.html#ssl.SSLContext.set_npn_protocols) и `selected_npn_protocol()` устарели: используйте ALPN вместо них.
  - `ssl.OP_NO_SSL*`: опции
  - `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`
- [`threading`](https://python-all.ru/3.12/library/threading.html#module-threading): методы

  - `threading.Condition.notifyAll()`: используйте [`notify_all()`](https://python-all.ru/3.12/library/threading.html#threading.Condition.notify_all).
  - `threading.Event.isSet()`: используйте [`is_set()`](https://python-all.ru/3.12/library/threading.html#threading.Event.is_set).
  - `threading.Thread.isDaemon()`, [`threading.Thread.setDaemon()`](https://python-all.ru/3.12/library/threading.html#threading.Thread.setDaemon): используйте атрибут [`threading.Thread.daemon`](https://python-all.ru/3.12/library/threading.html#threading.Thread.daemon).
  - `threading.Thread.getName()`, [`threading.Thread.setName()`](https://python-all.ru/3.12/library/threading.html#threading.Thread.setName): используйте атрибут [`threading.Thread.name`](https://python-all.ru/3.12/library/threading.html#threading.Thread.name).
  - `threading.currentThread()`: используйте [`threading.current_thread()`](https://python-all.ru/3.12/library/threading.html#threading.current_thread).
  - `threading.activeCount()`: используйте [`threading.active_count()`](https://python-all.ru/3.12/library/threading.html#threading.active_count).
- [`typing.Text`](https://python-all.ru/3.12/library/typing.html#typing.Text) ([gh-92332](https://python-all.ru/3.12/deprecations/index.html)).
- [`unittest.IsolatedAsyncioTestCase`](https://python-all.ru/3.12/library/unittest.html#unittest.IsolatedAsyncioTestCase): возврат значения, не являющегося `None`, из тестового примера устарел.
- [`urllib.parse`](https://python-all.ru/3.12/library/urllib.parse.html#module-urllib.parse) устаревшие функции: используйте [`urlparse()`](https://python-all.ru/3.12/library/urllib.parse.html#urllib.parse.urlparse) вместо них.

  - `splitattr()`
  - `splithost()`
  - `splitnport()`
  - `splitpasswd()`
  - `splitport()`
  - `splitquery()`
  - `splittag()`
  - `splittype()`
  - `splituser()`
  - `splitvalue()`
  - `to_bytes()`
- [`urllib.request`](https://python-all.ru/3.12/library/urllib.request.html#module-urllib.request): Стиль вызова запросов [`URLopener`](https://python-all.ru/3.12/library/urllib.request.html#urllib.request.URLopener) и [`FancyURLopener`](https://python-all.ru/3.12/library/urllib.request.html#urllib.request.FancyURLopener) устарел. Используйте более новые функции и методы [`urlopen()`](https://python-all.ru/3.12/library/urllib.request.html#urllib.request.urlopen).
- [`wsgiref`](https://python-all.ru/3.12/library/wsgiref.html#module-wsgiref): `SimpleHandler.stdout.write()` не должна выполнять частичную запись.
- [`xml.etree.ElementTree`](https://python-all.ru/3.12/library/xml.etree.elementtree.html#module-xml.etree.ElementTree): проверка истинностного значения [`Element`](https://python-all.ru/3.12/library/xml.etree.elementtree.html#xml.etree.ElementTree.Element) устарела. В будущем выпуске она всегда будет возвращать `True`. Вместо этого используйте явные проверки `len(elem)` или `elem is not None`.
- [`zipimport.zipimporter.load_module()`](https://python-all.ru/3.12/library/zipimport.html#zipimport.zipimporter.load_module) устарело: используйте [`exec_module()`](https://python-all.ru/3.12/library/zipimport.html#zipimport.zipimporter.exec_module) вместо него.

## Устаревшие возможности C API

### Запланировано к удалению в Python 3.14

- Поле `ma_version_tag` в [`PyDictObject`](https://python-all.ru/3.12/c-api/dict.html#c.PyDictObject) для модулей расширения ([**PEP 699**](https://python-all.ru/3.12/deprecations/index.html); [gh-101193](https://python-all.ru/3.12/deprecations/index.html)).
- Создание [`immutable types`](https://python-all.ru/3.12/c-api/typeobj.html#c.Py_TPFLAGS_IMMUTABLETYPE) с изменяемыми базовыми классами ([gh-95388](https://python-all.ru/3.12/deprecations/index.html)).
- Функции для настройки инициализации Python, устаревшие в Python 3.11:

  - `PySys_SetArgvEx()`: Вместо этого задайте [`PyConfig.argv`](https://python-all.ru/3.12/c-api/init_config.html#c.PyConfig.argv).
  - `PySys_SetArgv()`: Вместо этого задайте [`PyConfig.argv`](https://python-all.ru/3.12/c-api/init_config.html#c.PyConfig.argv).
  - `Py_SetProgramName()`: Вместо этого задайте [`PyConfig.program_name`](https://python-all.ru/3.12/c-api/init_config.html#c.PyConfig.program_name).
  - `Py_SetPythonHome()`: Вместо этого задайте [`PyConfig.home`](https://python-all.ru/3.12/c-api/init_config.html#c.PyConfig.home).

  API [`Py_InitializeFromConfig()`](https://python-all.ru/3.12/c-api/init_config.html#c.Py_InitializeFromConfig) следует использовать с [`PyConfig`](https://python-all.ru/3.12/c-api/init_config.html#c.PyConfig) вместо этого.
- Глобальные переменные конфигурации:

  - [`Py_DebugFlag`](https://python-all.ru/3.12/c-api/init.html#c.Py_DebugFlag): Вместо этого используйте [`PyConfig.parser_debug`](https://python-all.ru/3.12/c-api/init_config.html#c.PyConfig.parser_debug).
  - [`Py_VerboseFlag`](https://python-all.ru/3.12/c-api/init.html#c.Py_VerboseFlag): Вместо этого используйте [`PyConfig.verbose`](https://python-all.ru/3.12/c-api/init_config.html#c.PyConfig.verbose).
  - [`Py_QuietFlag`](https://python-all.ru/3.12/c-api/init.html#c.Py_QuietFlag): Вместо этого используйте [`PyConfig.quiet`](https://python-all.ru/3.12/c-api/init_config.html#c.PyConfig.quiet).
  - [`Py_InteractiveFlag`](https://python-all.ru/3.12/c-api/init.html#c.Py_InteractiveFlag): Вместо этого используйте [`PyConfig.interactive`](https://python-all.ru/3.12/c-api/init_config.html#c.PyConfig.interactive).
  - [`Py_InspectFlag`](https://python-all.ru/3.12/c-api/init.html#c.Py_InspectFlag): Вместо этого используйте [`PyConfig.inspect`](https://python-all.ru/3.12/c-api/init_config.html#c.PyConfig.inspect).
  - [`Py_OptimizeFlag`](https://python-all.ru/3.12/c-api/init.html#c.Py_OptimizeFlag): Вместо этого используйте [`PyConfig.optimization_level`](https://python-all.ru/3.12/c-api/init_config.html#c.PyConfig.optimization_level).
  - [`Py_NoSiteFlag`](https://python-all.ru/3.12/c-api/init.html#c.Py_NoSiteFlag): Вместо этого используйте [`PyConfig.site_import`](https://python-all.ru/3.12/c-api/init_config.html#c.PyConfig.site_import).
  - [`Py_BytesWarningFlag`](https://python-all.ru/3.12/c-api/init.html#c.Py_BytesWarningFlag): Вместо этого используйте [`PyConfig.bytes_warning`](https://python-all.ru/3.12/c-api/init_config.html#c.PyConfig.bytes_warning).
  - [`Py_FrozenFlag`](https://python-all.ru/3.12/c-api/init.html#c.Py_FrozenFlag): Вместо этого используйте [`PyConfig.pathconfig_warnings`](https://python-all.ru/3.12/c-api/init_config.html#c.PyConfig.pathconfig_warnings).
  - [`Py_IgnoreEnvironmentFlag`](https://python-all.ru/3.12/c-api/init.html#c.Py_IgnoreEnvironmentFlag): Вместо этого используйте [`PyConfig.use_environment`](https://python-all.ru/3.12/c-api/init_config.html#c.PyConfig.use_environment).
  - [`Py_DontWriteBytecodeFlag`](https://python-all.ru/3.12/c-api/init.html#c.Py_DontWriteBytecodeFlag): Вместо этого используйте [`PyConfig.write_bytecode`](https://python-all.ru/3.12/c-api/init_config.html#c.PyConfig.write_bytecode).
  - [`Py_NoUserSiteDirectory`](https://python-all.ru/3.12/c-api/init.html#c.Py_NoUserSiteDirectory): Вместо этого используйте [`PyConfig.user_site_directory`](https://python-all.ru/3.12/c-api/init_config.html#c.PyConfig.user_site_directory).
  - [`Py_UnbufferedStdioFlag`](https://python-all.ru/3.12/c-api/init.html#c.Py_UnbufferedStdioFlag): Вместо этого используйте [`PyConfig.buffered_stdio`](https://python-all.ru/3.12/c-api/init_config.html#c.PyConfig.buffered_stdio).
  - [`Py_HashRandomizationFlag`](https://python-all.ru/3.12/c-api/init.html#c.Py_HashRandomizationFlag): Используйте [`PyConfig.use_hash_seed`](https://python-all.ru/3.12/c-api/init_config.html#c.PyConfig.use_hash_seed) и [`PyConfig.hash_seed`](https://python-all.ru/3.12/c-api/init_config.html#c.PyConfig.hash_seed).
  - [`Py_IsolatedFlag`](https://python-all.ru/3.12/c-api/init.html#c.Py_IsolatedFlag): Вместо этого используйте [`PyConfig.isolated`](https://python-all.ru/3.12/c-api/init_config.html#c.PyConfig.isolated).
  - [`Py_LegacyWindowsFSEncodingFlag`](https://python-all.ru/3.12/c-api/init.html#c.Py_LegacyWindowsFSEncodingFlag): Вместо этого используйте [`PyPreConfig.legacy_windows_fs_encoding`](https://python-all.ru/3.12/c-api/init_config.html#c.PyPreConfig.legacy_windows_fs_encoding).
  - [`Py_LegacyWindowsStdioFlag`](https://python-all.ru/3.12/c-api/init.html#c.Py_LegacyWindowsStdioFlag): Вместо этого используйте [`PyConfig.legacy_windows_stdio`](https://python-all.ru/3.12/c-api/init_config.html#c.PyConfig.legacy_windows_stdio).
  - `Py_FileSystemDefaultEncoding`: Вместо этого используйте [`PyConfig.filesystem_encoding`](https://python-all.ru/3.12/c-api/init_config.html#c.PyConfig.filesystem_encoding).
  - `Py_HasFileSystemDefaultEncoding`: Вместо этого используйте [`PyConfig.filesystem_encoding`](https://python-all.ru/3.12/c-api/init_config.html#c.PyConfig.filesystem_encoding).
  - `Py_FileSystemDefaultEncodeErrors`: Вместо этого используйте [`PyConfig.filesystem_errors`](https://python-all.ru/3.12/c-api/init_config.html#c.PyConfig.filesystem_errors).
  - `Py_UTF8Mode`: Используйте [`PyPreConfig.utf8_mode`](https://python-all.ru/3.12/c-api/init_config.html#c.PyPreConfig.utf8_mode) вместо этого. (см. [`Py_PreInitialize()`](https://python-all.ru/3.12/c-api/init_config.html#c.Py_PreInitialize))

  API [`Py_InitializeFromConfig()`](https://python-all.ru/3.12/c-api/init_config.html#c.Py_InitializeFromConfig) следует использовать с [`PyConfig`](https://python-all.ru/3.12/c-api/init_config.html#c.PyConfig) вместо этого.

### Запланировано к удалению в Python 3.15

- Встроенная копия `libmpdecimal`.
- [`PyImport_ImportModuleNoBlock()`](https://python-all.ru/3.12/c-api/import.html#c.PyImport_ImportModuleNoBlock): Вместо этого используйте [`PyImport_ImportModule()`](https://python-all.ru/3.12/c-api/import.html#c.PyImport_ImportModule).
- [`PyWeakref_GetObject()`](https://python-all.ru/3.12/c-api/weakref.html#c.PyWeakref_GetObject) и [`PyWeakref_GET_OBJECT()`](https://python-all.ru/3.12/c-api/weakref.html#c.PyWeakref_GET_OBJECT): Используйте `PyWeakref_GetRef()` вместо этого.
- Тип [`Py_UNICODE`](https://python-all.ru/3.12/c-api/unicode.html#c.Py_UNICODE) и макрос `Py_UNICODE_WIDE`: Вместо них используйте `wchar_t`.
- Функции инициализации Python:

  - [`PySys_ResetWarnOptions()`](https://python-all.ru/3.12/c-api/sys.html#c.PySys_ResetWarnOptions): Вместо этого очистите [`sys.warnoptions`](https://python-all.ru/3.12/library/sys.html#sys.warnoptions) и `warnings.filters`.
  - [`Py_GetExecPrefix()`](https://python-all.ru/3.12/c-api/init.html#c.Py_GetExecPrefix): Вместо этого используйте [`sys.exec_prefix`](https://python-all.ru/3.12/library/sys.html#sys.exec_prefix).
  - [`Py_GetPath()`](https://python-all.ru/3.12/c-api/init.html#c.Py_GetPath): Вместо этого используйте [`sys.path`](https://python-all.ru/3.12/library/sys.html#sys.path).
  - [`Py_GetPrefix()`](https://python-all.ru/3.12/c-api/init.html#c.Py_GetPrefix): Вместо этого используйте [`sys.prefix`](https://python-all.ru/3.12/library/sys.html#sys.prefix).
  - [`Py_GetProgramFullPath()`](https://python-all.ru/3.12/c-api/init.html#c.Py_GetProgramFullPath): Вместо этого используйте [`sys.executable`](https://python-all.ru/3.12/library/sys.html#sys.executable).
  - [`Py_GetProgramName()`](https://python-all.ru/3.12/c-api/init.html#c.Py_GetProgramName): Вместо этого используйте [`sys.executable`](https://python-all.ru/3.12/library/sys.html#sys.executable).
  - [`Py_GetPythonHome()`](https://python-all.ru/3.12/c-api/init.html#c.Py_GetPythonHome): Вместо этого используйте [`PyConfig.home`](https://python-all.ru/3.12/c-api/init_config.html#c.PyConfig.home) или переменную окружения [`PYTHONHOME`](https://python-all.ru/3.12/using/cmdline.html#envvar-PYTHONHOME).

### Запланировано к удалению в будущих версиях

Следующие API устарели и будут удалены, хотя на данный момент дата их удаления не назначена.

- [`Py_TPFLAGS_HAVE_FINALIZE`](https://python-all.ru/3.12/c-api/typeobj.html#c.Py_TPFLAGS_HAVE_FINALIZE): Не требуется начиная с Python 3.8.
- [`PyErr_Fetch()`](https://python-all.ru/3.12/c-api/exceptions.html#c.PyErr_Fetch): Вместо этого используйте [`PyErr_GetRaisedException()`](https://python-all.ru/3.12/c-api/exceptions.html#c.PyErr_GetRaisedException).
- [`PyErr_NormalizeException()`](https://python-all.ru/3.12/c-api/exceptions.html#c.PyErr_NormalizeException): Вместо этого используйте [`PyErr_GetRaisedException()`](https://python-all.ru/3.12/c-api/exceptions.html#c.PyErr_GetRaisedException).
- [`PyErr_Restore()`](https://python-all.ru/3.12/c-api/exceptions.html#c.PyErr_Restore): Вместо этого используйте [`PyErr_SetRaisedException()`](https://python-all.ru/3.12/c-api/exceptions.html#c.PyErr_SetRaisedException).
- [`PyModule_GetFilename()`](https://python-all.ru/3.12/c-api/module.html#c.PyModule_GetFilename): Вместо этого используйте [`PyModule_GetFilenameObject()`](https://python-all.ru/3.12/c-api/module.html#c.PyModule_GetFilenameObject).
- [`PyOS_AfterFork()`](https://python-all.ru/3.12/c-api/sys.html#c.PyOS_AfterFork): Вместо этого используйте [`PyOS_AfterFork_Child()`](https://python-all.ru/3.12/c-api/sys.html#c.PyOS_AfterFork_Child).
- [`PySlice_GetIndicesEx()`](https://python-all.ru/3.12/c-api/slice.html#c.PySlice_GetIndicesEx): Вместо этого используйте [`PySlice_Unpack()`](https://python-all.ru/3.12/c-api/slice.html#c.PySlice_Unpack) и [`PySlice_AdjustIndices()`](https://python-all.ru/3.12/c-api/slice.html#c.PySlice_AdjustIndices).
- `PyUnicode_AsDecodedObject()`: Вместо этого используйте [`PyCodec_Decode()`](https://python-all.ru/3.12/c-api/codec.html#c.PyCodec_Decode).
- `PyUnicode_AsDecodedUnicode()`: Вместо этого используйте [`PyCodec_Decode()`](https://python-all.ru/3.12/c-api/codec.html#c.PyCodec_Decode).
- `PyUnicode_AsEncodedObject()`: Вместо этого используйте [`PyCodec_Encode()`](https://python-all.ru/3.12/c-api/codec.html#c.PyCodec_Encode).
- `PyUnicode_AsEncodedUnicode()`: Вместо этого используйте [`PyCodec_Encode()`](https://python-all.ru/3.12/c-api/codec.html#c.PyCodec_Encode).
- [`PyUnicode_READY()`](https://python-all.ru/3.12/c-api/unicode.html#c.PyUnicode_READY): Не требуется начиная с Python 3.12
- `PyErr_Display()`: Вместо этого используйте [`PyErr_DisplayException()`](https://python-all.ru/3.12/c-api/exceptions.html#c.PyErr_DisplayException).
- `_PyErr_ChainExceptions()`: Вместо этого используйте `_PyErr_ChainExceptions1()`.
- Элемент `PyBytesObject.ob_shash`: вместо этого вызывайте [`PyObject_Hash()`](https://python-all.ru/3.12/c-api/object.html#c.PyObject_Hash).
- Элемент `PyDictObject.ma_version_tag`.
- API локального хранилища потока (TLS):

  - [`PyThread_create_key()`](https://python-all.ru/3.12/c-api/init.html#c.PyThread_create_key): Вместо этого используйте [`PyThread_tss_alloc()`](https://python-all.ru/3.12/c-api/init.html#c.PyThread_tss_alloc).
  - [`PyThread_delete_key()`](https://python-all.ru/3.12/c-api/init.html#c.PyThread_delete_key): Вместо этого используйте [`PyThread_tss_free()`](https://python-all.ru/3.12/c-api/init.html#c.PyThread_tss_free).
  - [`PyThread_set_key_value()`](https://python-all.ru/3.12/c-api/init.html#c.PyThread_set_key_value): Вместо этого используйте [`PyThread_tss_set()`](https://python-all.ru/3.12/c-api/init.html#c.PyThread_tss_set).
  - [`PyThread_get_key_value()`](https://python-all.ru/3.12/c-api/init.html#c.PyThread_get_key_value): Вместо этого используйте [`PyThread_tss_get()`](https://python-all.ru/3.12/c-api/init.html#c.PyThread_tss_get).
  - [`PyThread_delete_key_value()`](https://python-all.ru/3.12/c-api/init.html#c.PyThread_delete_key_value): Вместо этого используйте [`PyThread_tss_delete()`](https://python-all.ru/3.12/c-api/init.html#c.PyThread_tss_delete).
  - [`PyThread_ReInitTLS()`](https://python-all.ru/3.12/c-api/init.html#c.PyThread_ReInitTLS): Не требуется с Python 3.7.
