index.md
1> **Источник:** https://python-all.ru/3.12/deprecations/index.html2>3> «Документация Python на русском» – неофициальный перевод официальной документации Python: версии от 2.6 до 3.16, полнотекстовый поиск, английский оригинал рядом с переводом. Эта Markdown-версия страницы предназначена для работы с LLM: вставьте её в ChatGPT, Claude или Cursor.45---67# Устаревания89## Запланировано к удалению в Python 3.131011Модули (см. [**PEP 594**](https://python-all.ru/3.12/deprecations/index.html)):1213- [`aifc`](https://python-all.ru/3.12/library/aifc.html#module-aifc)14- [`audioop`](https://python-all.ru/3.12/library/audioop.html#module-audioop)15- [`cgi`](https://python-all.ru/3.12/library/cgi.html#module-cgi)16- [`cgitb`](https://python-all.ru/3.12/library/cgitb.html#module-cgitb)17- [`chunk`](https://python-all.ru/3.12/library/chunk.html#module-chunk)18- [`crypt`](https://python-all.ru/3.12/library/crypt.html#module-crypt)19- [`imghdr`](https://python-all.ru/3.12/library/imghdr.html#module-imghdr)20- [`mailcap`](https://python-all.ru/3.12/library/mailcap.html#module-mailcap)21- [`msilib`](https://python-all.ru/3.12/library/msilib.html#module-msilib)22- [`nis`](https://python-all.ru/3.12/library/nis.html#module-nis)23- [`nntplib`](https://python-all.ru/3.12/library/nntplib.html#module-nntplib)24- [`ossaudiodev`](https://python-all.ru/3.12/library/ossaudiodev.html#module-ossaudiodev)25- [`pipes`](https://python-all.ru/3.12/library/pipes.html#module-pipes)26- [`sndhdr`](https://python-all.ru/3.12/library/sndhdr.html#module-sndhdr)27- [`spwd`](https://python-all.ru/3.12/library/spwd.html#module-spwd)28- [`sunau`](https://python-all.ru/3.12/library/sunau.html#module-sunau)29- [`telnetlib`](https://python-all.ru/3.12/library/telnetlib.html#module-telnetlib)30- [`uu`](https://python-all.ru/3.12/library/uu.html#module-uu)31- [`xdrlib`](https://python-all.ru/3.12/library/xdrlib.html#module-xdrlib)3233Другие модули:3435- `lib2to3` и программа **2to3** ([gh-84540](https://python-all.ru/3.12/deprecations/index.html))3637API:3839- `configparser.LegacyInterpolation` ([gh-90765](https://python-all.ru/3.12/deprecations/index.html))40- `locale.resetlocale()` ([gh-90817](https://python-all.ru/3.12/deprecations/index.html))41- `turtle.RawTurtle.settiltangle()` ([gh-50096](https://python-all.ru/3.12/deprecations/index.html))42- `unittest.findTestCases()` ([gh-50096](https://python-all.ru/3.12/deprecations/index.html))43- `unittest.getTestCaseNames()` ([gh-50096](https://python-all.ru/3.12/deprecations/index.html))44- `unittest.makeSuite()` ([gh-50096](https://python-all.ru/3.12/deprecations/index.html))45- `unittest.TestProgram.usageExit()` ([gh-67048](https://python-all.ru/3.12/deprecations/index.html))46- `webbrowser.MacOSX` ([gh-86421](https://python-all.ru/3.12/deprecations/index.html))47- [`classmethod`](https://python-all.ru/3.12/library/functions.html#classmethod) цепочка дескрипторов ([gh-89519](https://python-all.ru/3.12/deprecations/index.html))48- [`importlib.resources`](https://python-all.ru/3.12/library/importlib.resources.html#module-importlib.resources) устаревшие методы:4950 - `contents()`51 - `is_resource()`52 - `open_binary()`53 - `open_text()`54 - `path()`55 - `read_binary()`56 - `read_text()`5758 Вместо этого используйте [`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))5960## Запланировано к удалению в Python 3.146162- [`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).)63- [`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:6465 - `ast.Num`66 - `ast.Str`67 - `ast.Bytes`68 - `ast.NameConstant`69 - `ast.Ellipsis`7071 Вместо этого используйте [`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).)72- [`asyncio`](https://python-all.ru/3.12/library/asyncio.html#module-asyncio):7374 - Классы наблюдателя дочерних процессов [`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).)75 - [`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).)76 - Метод [`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).)77- [`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).)78- [`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).)79- [`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)).80- [`importlib.abc`](https://python-all.ru/3.12/library/importlib.html#module-importlib.abc) устаревшие классы:8182 - `importlib.abc.ResourceReader`83 - `importlib.abc.Traversable`84 - `importlib.abc.TraversableResources`8586 Вместо них используйте классы [`importlib.resources.abc`](https://python-all.ru/3.12/library/importlib.resources.abc.html#module-importlib.resources.abc):8788 - [`importlib.resources.abc.Traversable`](https://python-all.ru/3.12/library/importlib.resources.abc.html#importlib.resources.abc.Traversable)89 - [`importlib.resources.abc.TraversableResources`](https://python-all.ru/3.12/library/importlib.resources.abc.html#importlib.resources.abc.TraversableResources)9091 (Авторы: Jason R. Coombs и Hugo van Kemenade в [gh-93963](https://python-all.ru/3.12/deprecations/index.html).)92- [`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).)93- [`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).94- [`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): передача дополнительных аргументов объявлена устаревшей.95- [`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).)96- [`pty`](https://python-all.ru/3.12/library/pty.html#module-pty):9798 - `master_open()`: используйте [`pty.openpty()`](https://python-all.ru/3.12/library/pty.html#pty.openpty).99 - `slave_open()`: используйте [`pty.openpty()`](https://python-all.ru/3.12/library/pty.html#pty.openpty).100- [`sqlite3`](https://python-all.ru/3.12/library/sqlite3.html#module-sqlite3):101102 - [`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).103 - [`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).104- [`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) при использовании.105- [`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).)106107## Запланировано к удалению в Python 3.15108109- [`http.server.CGIHTTPRequestHandler`](https://python-all.ru/3.12/library/http.server.html#http.server.CGIHTTPRequestHandler) будет удалён вместе со связанным флагом `--cgi` для `python -m http.server`. Он был устаревшим и редко использовался. Прямой замены не существует. *Что угодно* лучше, чем CGI, для взаимодействия веб-сервера с обработчиком запросов.110- [`importlib`](https://python-all.ru/3.12/library/importlib.html#module-importlib):111112 - Метод `load_module()`: вместо него используйте `exec_module()`.113- [`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).)114- [`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.115- [`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).)116- [`sysconfig`](https://python-all.ru/3.12/library/sysconfig.html#module-sysconfig):117118 - Аргумент *check\_home* функции [`sysconfig.is_python_build()`](https://python-all.ru/3.12/library/sysconfig.html#sysconfig.is_python_build) считается устаревшим начиная с Python 3.12.119- [`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).)120- [`typing.NamedTuple`](https://python-all.ru/3.12/library/typing.html#typing.NamedTuple):121122 - Не документированный синтаксис именованных аргументов для создания классов `NamedTuple` (`NT = NamedTuple("NT", x=int)`) устарел и будет запрещён в 3.15. Вместо этого используйте синтаксис на основе классов или функциональный синтаксис.123- [`types`](https://python-all.ru/3.12/library/types.html#module-types):124125 - [`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).)126- [`typing`](https://python-all.ru/3.12/library/typing.html#module-typing):127128 - При использовании функционального синтаксиса для создания класса `NamedTuple`, отсутствие значения у параметра *fields* (`NT = NamedTuple("NT")`) устарело. Передача `None` в параметр *fields* (`NT = NamedTuple("NT", None)`) также устарела. Оба варианта будут запрещены в Python 3.15. Чтобы создать класс `NamedTuple` с 0 полями, используйте `class NT(NamedTuple): pass` или `NT = NamedTuple("NT", [])`.129- [`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", {})`.130- [`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).)131132## Запланированное удаление в Python 3.16133134- Система импорта:135136 - Установка [`__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__` перестанет устанавливаться или учитываться системой импорта или стандартной библиотекой.137- [`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`).138- [`builtins`](https://python-all.ru/3.12/library/builtins.html#module-builtins): `~bool`, побитовая инверсия для bool.139- [`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).)140141## Запланировано к удалению в будущих версиях142143Следующие API будут удалены в будущем, хотя на данный момент нет запланированной даты их удаления.144145- [`argparse`](https://python-all.ru/3.12/library/argparse.html#module-argparse): Вложение групп аргументов и вложение взаимоисключающих групп устарело.146- Код формата `'u'` для [`array`](https://python-all.ru/3.12/library/array.html#module-array) ([gh-57281](https://python-all.ru/3.12/deprecations/index.html))147- [`builtins`](https://python-all.ru/3.12/library/builtins.html#module-builtins):148149 - `bool(NotImplemented)`.150 - Генераторы: сигнатура `throw(type, exc, tb)` и `athrow(type, exc, tb)` устарела: используйте `throw(exc)` и `athrow(exc)` вместо неё, сигнатуру с одним аргументом.151 - В настоящее время 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))152 - Поддержка методов `__index__()` и `__int__()`, возвращающих не-int тип: эти методы должны будут возвращать экземпляр строгого подкласса [`int`](https://python-all.ru/3.12/library/functions.html#int).153 - Поддержка метода `__float__()`, возвращающего строгий подкласс [`float`](https://python-all.ru/3.12/library/functions.html#float): эти методы должны будут возвращать экземпляр [`float`](https://python-all.ru/3.12/library/functions.html#float).154 - Поддержка метода `__complex__()`, возвращающего строгий подкласс [`complex`](https://python-all.ru/3.12/library/functions.html#complex): эти методы должны будут возвращать экземпляр [`complex`](https://python-all.ru/3.12/library/functions.html#complex).155 - Делегирование `int()` методу `__trunc__()`.156 - Передача комплексного числа в качестве аргумента *real* или *imag* в конструкторе [`complex()`](https://python-all.ru/3.12/library/functions.html#complex) теперь устарела; его следует передавать только как единственный позиционный аргумент. (Автор: Сергей Сторчака в [gh-109218](https://python-all.ru/3.12/deprecations/index.html).)157- [`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).)158- [`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) вместо этого.159- [`datetime`](https://python-all.ru/3.12/library/datetime.html#module-datetime):160161 - [`utcnow()`](https://python-all.ru/3.12/library/datetime.html#datetime.datetime.utcnow): используйте `datetime.datetime.now(tz=datetime.UTC)`.162 - [`utcfromtimestamp()`](https://python-all.ru/3.12/library/datetime.html#datetime.datetime.utcfromtimestamp): используйте `datetime.datetime.fromtimestamp(timestamp, tz=datetime.UTC)`.163- [`gettext`](https://python-all.ru/3.12/library/gettext.html#module-gettext): значение множественного числа должно быть целым числом.164- [`importlib`](https://python-all.ru/3.12/library/importlib.html#module-importlib):165166 - [`cache_from_source()`](https://python-all.ru/3.12/library/importlib.html#importlib.util.cache_from_source): параметр *debug\_override* устарел: используйте параметр *optimization* вместо него.167- [`importlib.metadata`](https://python-all.ru/3.12/library/importlib.metadata.html#module-importlib.metadata):168169 - `EntryPoints`: интерфейс кортежа.170 - Неявное `None` для возвращаемых значений.171- [`mailbox`](https://python-all.ru/3.12/library/mailbox.html#module-mailbox): использование StringIO в режиме ввода и текстовом режиме устарело, используйте BytesIO и двоичный режим.172- [`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) в многопоточном процессе.173- `pydoc.ErrorDuringImport`: кортежное значение для параметра *exc\_info* устарело, используйте экземпляр исключения.174- [`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).)175- Модули `sre_compile`, `sre_constants` и `sre_parse`.176- [`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* вместо него.177- [`ssl`](https://python-all.ru/3.12/library/ssl.html#module-ssl): опции и протоколы:178179 - [`ssl.SSLContext`](https://python-all.ru/3.12/library/ssl.html#ssl.SSLContext) без аргумента протокол устарело.180 - [`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 вместо них.181 - `ssl.OP_NO_SSL*`: опции182 - `ssl.OP_NO_TLS*`: опции183 - `ssl.PROTOCOL_SSLv3`184 - `ssl.PROTOCOL_TLS`185 - `ssl.PROTOCOL_TLSv1`186 - `ssl.PROTOCOL_TLSv1_1`187 - `ssl.PROTOCOL_TLSv1_2`188 - `ssl.TLSVersion.SSLv3`189 - `ssl.TLSVersion.TLSv1`190 - `ssl.TLSVersion.TLSv1_1`191- [`threading`](https://python-all.ru/3.12/library/threading.html#module-threading): методы192193 - `threading.Condition.notifyAll()`: используйте [`notify_all()`](https://python-all.ru/3.12/library/threading.html#threading.Condition.notify_all).194 - `threading.Event.isSet()`: используйте [`is_set()`](https://python-all.ru/3.12/library/threading.html#threading.Event.is_set).195 - `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).196 - `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).197 - `threading.currentThread()`: используйте [`threading.current_thread()`](https://python-all.ru/3.12/library/threading.html#threading.current_thread).198 - `threading.activeCount()`: используйте [`threading.active_count()`](https://python-all.ru/3.12/library/threading.html#threading.active_count).199- [`typing.Text`](https://python-all.ru/3.12/library/typing.html#typing.Text) ([gh-92332](https://python-all.ru/3.12/deprecations/index.html)).200- [`unittest.IsolatedAsyncioTestCase`](https://python-all.ru/3.12/library/unittest.html#unittest.IsolatedAsyncioTestCase): возврат значения, не являющегося `None`, из тестового примера устарел.201- [`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) вместо них.202203 - `splitattr()`204 - `splithost()`205 - `splitnport()`206 - `splitpasswd()`207 - `splitport()`208 - `splitquery()`209 - `splittag()`210 - `splittype()`211 - `splituser()`212 - `splitvalue()`213 - `to_bytes()`214- [`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).215- [`wsgiref`](https://python-all.ru/3.12/library/wsgiref.html#module-wsgiref): `SimpleHandler.stdout.write()` не должна выполнять частичную запись.216- [`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`.217- [`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) вместо него.218219## Устаревшие возможности C API220221### Запланировано к удалению в Python 3.14222223- Поле `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)).224- Создание [`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)).225- Функции для настройки инициализации Python, устаревшие в Python 3.11:226227 - `PySys_SetArgvEx()`: Вместо этого задайте [`PyConfig.argv`](https://python-all.ru/3.12/c-api/init_config.html#c.PyConfig.argv).228 - `PySys_SetArgv()`: Вместо этого задайте [`PyConfig.argv`](https://python-all.ru/3.12/c-api/init_config.html#c.PyConfig.argv).229 - `Py_SetProgramName()`: Вместо этого задайте [`PyConfig.program_name`](https://python-all.ru/3.12/c-api/init_config.html#c.PyConfig.program_name).230 - `Py_SetPythonHome()`: Вместо этого задайте [`PyConfig.home`](https://python-all.ru/3.12/c-api/init_config.html#c.PyConfig.home).231232 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) вместо этого.233- Глобальные переменные конфигурации:234235 - [`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).236 - [`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).237 - [`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).238 - [`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).239 - [`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).240 - [`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).241 - [`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).242 - [`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).243 - [`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).244 - [`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).245 - [`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).246 - [`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).247 - [`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).248 - [`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).249 - [`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).250 - [`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).251 - [`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).252 - `Py_FileSystemDefaultEncoding`: Вместо этого используйте [`PyConfig.filesystem_encoding`](https://python-all.ru/3.12/c-api/init_config.html#c.PyConfig.filesystem_encoding).253 - `Py_HasFileSystemDefaultEncoding`: Вместо этого используйте [`PyConfig.filesystem_encoding`](https://python-all.ru/3.12/c-api/init_config.html#c.PyConfig.filesystem_encoding).254 - `Py_FileSystemDefaultEncodeErrors`: Вместо этого используйте [`PyConfig.filesystem_errors`](https://python-all.ru/3.12/c-api/init_config.html#c.PyConfig.filesystem_errors).255 - `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))256257 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) вместо этого.258259### Запланировано к удалению в Python 3.15260261- Встроенная копия `libmpdecimal`.262- [`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).263- [`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()` вместо этого.264- Тип [`Py_UNICODE`](https://python-all.ru/3.12/c-api/unicode.html#c.Py_UNICODE) и макрос `Py_UNICODE_WIDE`: Вместо них используйте `wchar_t`.265- Функции инициализации Python:266267 - [`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`.268 - [`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).269 - [`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).270 - [`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).271 - [`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).272 - [`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).273 - [`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).274275### Запланировано к удалению в будущих версиях276277Следующие API устарели и будут удалены, хотя на данный момент дата их удаления не назначена.278279- [`Py_TPFLAGS_HAVE_FINALIZE`](https://python-all.ru/3.12/c-api/typeobj.html#c.Py_TPFLAGS_HAVE_FINALIZE): Не требуется начиная с Python 3.8.280- [`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).281- [`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).282- [`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).283- [`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).284- [`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).285- [`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).286- `PyUnicode_AsDecodedObject()`: Вместо этого используйте [`PyCodec_Decode()`](https://python-all.ru/3.12/c-api/codec.html#c.PyCodec_Decode).287- `PyUnicode_AsDecodedUnicode()`: Вместо этого используйте [`PyCodec_Decode()`](https://python-all.ru/3.12/c-api/codec.html#c.PyCodec_Decode).288- `PyUnicode_AsEncodedObject()`: Вместо этого используйте [`PyCodec_Encode()`](https://python-all.ru/3.12/c-api/codec.html#c.PyCodec_Encode).289- `PyUnicode_AsEncodedUnicode()`: Вместо этого используйте [`PyCodec_Encode()`](https://python-all.ru/3.12/c-api/codec.html#c.PyCodec_Encode).290- [`PyUnicode_READY()`](https://python-all.ru/3.12/c-api/unicode.html#c.PyUnicode_READY): Не требуется начиная с Python 3.12291- `PyErr_Display()`: Вместо этого используйте [`PyErr_DisplayException()`](https://python-all.ru/3.12/c-api/exceptions.html#c.PyErr_DisplayException).292- `_PyErr_ChainExceptions()`: Вместо этого используйте `_PyErr_ChainExceptions1()`.293- Элемент `PyBytesObject.ob_shash`: вместо этого вызывайте [`PyObject_Hash()`](https://python-all.ru/3.12/c-api/object.html#c.PyObject_Hash).294- Элемент `PyDictObject.ma_version_tag`.295- API локального хранилища потока (TLS):296297 - [`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).298 - [`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).299 - [`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).300 - [`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).301 - [`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).302 - [`PyThread_ReInitTLS()`](https://python-all.ru/3.12/c-api/init.html#c.PyThread_ReInitTLS): Не требуется с Python 3.7.303