计划在 Python 3.15 中移除¶
导入系统:
当设置
__spec__.cached失败时在模块上设置__cached__的做法已被弃用。在 Python 3.15 中,__cached__将不会再被导入系统或标准库纳入考虑。 (gh-97879)当设置
__spec__.parent失败时在模块上设置__package__的做法已被弃用。在 Python 3.15 中,__package__将不会再被导入系统或标准库纳入考虑。 (gh-97879)
-
未写入文档的
ctypes.SetPointerType()函数自 Python 3.13 起已被弃用。
-
过时且很少被使用的
CGIHTTPRequestHandler自 Python 3.13 起已被弃用。 不存在直接的替代品。对于建立带有请求处理器的 Web 服务器接口的任务来说 任何东西 都比 CGI 要好。用于 python -m http.server 命令行界面的
--cgi旗标自 Python 3.13 起已被弃用。
-
load_module()方法:改用exec_module()。
-
getdefaultlocale()函数自 Python 3.11 起已被弃用。最初计划在 Python 3.13 中移除它 (gh-90817),但已被推迟至 Python 3.15。请改用getlocale(),setlocale()和getencoding()。 (由 Hugo van Kemenade 在 gh-111187 中贡献。)
-
PurePath.is_reserved()自 Python 3.13 起已被弃用。请使用os.path.isreserved()来检测 Windows 上的保留路径。
-
java_ver()自 Python 3.13 起已被弃用。此函数仅对 Jython 支持有用,具有令人困惑的 API,并且大部分未经测试。
-
sysconfig.is_python_build()的 check_home 参数自 Python 3.12 起已被弃用。
-
RLock()will take no arguments in Python 3.15. Passing any arguments has been deprecated since Python 3.14, as the Python version does not permit any arguments, but the C version allows any number of positional or keyword arguments, ignoring every argument.
-
types.CodeType: 访问co_lnotab的做法自 3.10 起已根据 PEP 626 被弃用并曾计划在 3.12 中移除,但在 3.12 中实际仅设置了DeprecationWarning。可能会在 3.15 中移除。 (由 Nikita Sobolev 在 gh-101866 中贡献。)
-
未写入文档的用于创建
NamedTuple类的关键字参数语法 (例如Point = NamedTuple("Point", x=int, y=int)) 自 Python 3.13 起已被弃用。请改用基于类的语法或函数式语法。当使用
TypedDict的函数式语法时,不向 fields 形参传递值 (TD = TypedDict("TD")) 或传递None(TD = TypedDict("TD", None)) 的做法自 Python 3.13 起已被弃用。请改用class TD(TypedDict): pass或TD = TypedDict("TD", {})来创建一个零字段的 TypedDict。typing.no_type_check_decorator()装饰器自 Python 3.13 起已被弃用。存在于typing模块八年之后,它仍未被任何主要类型检查器所支持。
wave:Wave_read和Wave_write类的getmark(),setmark()和getmarkers()方法自 Python 3.13 起已被弃用。
-
load_module()自 Python 3.10 起已被弃用。请改用exec_module()。 (由李佳昊在 gh-125746 中贡献。)