计划在 Python 3.14 中移除¶
argparse:argparse.BooleanOptionalAction的 type, choices 和 metavar 形参已被弃用并将在 3.14 中移除。 (由 Nikita Sobolev 在 gh-92248 中贡献。)ast: 以下特性自 Python 3.8 起已在文档中声明弃用,现在当运行时如果它们被访问或使用时将发出DeprecationWarning,并将在 Python 3.14 中移除:ast.Numast.Strast.Bytesast.NameConstantast.Ellipsis
请改用
ast.Constant。 (由 Serhiy Storchaka 在 gh-90953 中贡献。)-
The child watcher classes
asyncio.MultiLoopChildWatcher,asyncio.FastChildWatcher,asyncio.AbstractChildWatcherandasyncio.SafeChildWatcherare deprecated and will be removed in Python 3.14. (Contributed by Kumar Aditya in gh-94597.)asyncio.set_child_watcher(),asyncio.get_child_watcher(),asyncio.AbstractEventLoopPolicy.set_child_watcher()andasyncio.AbstractEventLoopPolicy.get_child_watcher()are deprecated and will be removed in Python 3.14. (Contributed by Kumar Aditya in gh-94597.)现在默认事件循环策略的
get_event_loop()方法在当前事件循环未设置并决定创建一个时将发出DeprecationWarning。 (由 Serhiy Storchaka 和 Guido van Rossum 在 gh-100160 中贡献。)
collections.abc: Deprecatedcollections.abc.ByteString. PreferSequenceorBuffer. For use in typing, prefer a union, likebytes | bytearray, orcollections.abc.Buffer. (Contributed by Shantanu Jain in gh-91896.)email: 已弃用email.utils.localtime()中的 isdst 形参。 (由 Alan Williams 在 gh-72346 中贡献。)importlib.abc中已弃用的类:importlib.abc.ResourceReaderimportlib.abc.Traversableimportlib.abc.TraversableResources
使用
importlib.resources.abc类代替:(由 Jason R. Coombs 和 Hugo van Kemenade 在 gh-93963 中贡献。)
itertools具有对 copy, deepcopy 和 pickle 等操作的未写入文档的、低效的、历史上充满问题的且不稳定的支持。 这将在 3.14 中移除以显著减少代码量和维护负担。 (由 Raymond Hettinger 在 gh-101588 中贡献。)multiprocessing: 默认的启动方法在目前默认使用'fork'的 Linux, BSD 和其他非 macOS POSIX 平台上将改为更安全的方法 (gh-84559)。 为此添加运行时警告将带来糟糕的体验因为大部分代码并不会关心这个问题。 当你的代码 需要'fork'时请使用get_context()或set_start_method()API 来显式地指明。 参见 上下文和启动方法。pathlib:is_relative_to()和relative_to(): 传入额外参数的做法已被弃用。pkgutil: 现在find_loader()和get_loader()将引发DeprecationWarning;请改用importlib.util.find_spec()。 (由 Nikita Sobolev 在 gh-97850 中贡献。)pty:master_open(): 使用pty.openpty()。slave_open(): 使用pty.openpty()。
-
versionandversion_info.如果使用了 命名占位符 且 parameters 是一个序列而不是
dict则选择execute()和executemany()。date 和 datetime 适配器,date 和 timestamp 转换器:请参阅
sqlite3文档了解推荐的替代方案。
types.CodeType: 访问co_lnotab的做法自 3.10 起已在 PEP 626 中被弃用并曾计划在 3.12 中移除,但实际上在 3.12 中仅设置了DeprecationWarning。 可能会在 3.14 中移除。 (由 Nikita Sobolev 在 gh-101866 中贡献。)typing:typing.ByteString, deprecated since Python 3.9, now causes aDeprecationWarningto be emitted when it is used.urllib:urllib.parse.Quoter已被弃用:它不应被作为公有 API。 (由 Gregory P. Smith 在 gh-88168 中贡献。)