计划在 Python 3.14 中移除
argparse
:argparse.BooleanOptionalAction
的 type, choices 和 metavar 形参已被弃用并将在 3.14 中移除。 (由 Nikita Sobolev 在 gh-92248 [https://github.com/python/cpython/issues/92248] 中贡献。)ast
: 以下特性自 Python 3.8 起已在文档中声明弃用,现在当运行时如果它们被访问或使用时将发出DeprecationWarning
,并将在 Python 3.14 中移除:ast.Num
ast.Str
ast.Bytes
ast.NameConstant
ast.Ellipsis
请改用 ast.Constant
。 (由 Serhiy Storchaka 在 gh-90953 [https://github.com/python/cpython/issues/90953] 中贡献。)
-
子监视器类
MultiLoopChildWatcher
,FastChildWatcher
,AbstractChildWatcher
和SafeChildWatcher
已被弃用并将在 Python 3.14 中移除。 (由 Kumar Aditya 在 gh-94597 [https://github.com/python/cpython/issues/94597] 中贡献。)asyncio.set_child_watcher()
、asyncio.get_child_watcher()
、asyncio.AbstractEventLoopPolicy.set_child_watcher()
和asyncio.AbstractEventLoopPolicy.get_child_watcher()
已弃用,并将在 Python 3.14 中移除。(由 Kumar Aditya 在 gh-94597 [https://github.com/python/cpython/issues/94597] 中贡献。)现在默认事件循环策略的
get_event_loop()
方法在当前事件循环未设置并决定创建一个时将发出DeprecationWarning
。 (由 Serhiy Storchaka 和 Guido van Rossum 在 gh-100160 [https://github.com/python/cpython/issues/100160] 中贡献。)
collections.abc
: 已弃用ByteString
。 推荐改用Sequence
或Buffer
。 用于类型标注时,则推荐并集运算符,如bytes | bytearray
,或collections.abc.Buffer
。 (由 Shantanu Jain 在 gh-91896 [https://github.com/python/cpython/issues/91896] 中贡献。)email
: 已弃用email.utils.localtime()
中的 isdst 形参。 (由 Alan Williams 在 gh-72346 [https://github.com/python/cpython/issues/72346] 中贡献。)importlib.abc
中已弃用的类:importlib.abc.ResourceReader
importlib.abc.Traversable
importlib.abc.TraversableResources
使用 importlib.resources.abc
类代替:
(由 Jason R. Coombs 和 Hugo van Kemenade 在 gh-93963 [https://github.com/python/cpython/issues/93963] 中贡献。)
itertools
具有对 copy, deepcopy 和 pickle 等操作的未写入文档的、低效的、历史上充满问题的且不稳定的支持。 这将在 3.14 中移除以显著减少代码量和维护负担。 (由 Raymond Hettinger 在 gh-101588 [https://github.com/python/cpython/issues/101588] 中贡献。)multiprocessing
: 默认的启动方法在目前默认使用'fork'
的 Linux, BSD 和其他非 macOS POSIX 平台上将改为更安全的方法 (gh-84559 [https://github.com/python/cpython/issues/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 [https://github.com/python/cpython/issues/97850] 中贡献。)pty
:master_open()
: 使用pty.openpty()
。slave_open()
: 使用pty.openpty()
。
-
如果使用了 命名占位符 且 parameters 是一个序列而不是
dict
则选择execute()
和executemany()
。
typing
:ByteString
自 Python 3.9 起已被弃用,现在当被使用时将会发出DeprecationWarning
。urllib
:urllib.parse.Quoter
已被弃用:它不应被作为公有 API。 (由 Gregory P. Smith 在 gh-88168 [https://github.com/python/cpython/issues/88168] 中贡献。)