计划在 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 起已被弃用。
-
The obsolete and rarely used
CGIHTTPRequestHandlerhas been deprecated since Python 3.13. No direct replacement exists. Anything is better than CGI to interface a web server with a request handler.用于 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()has been deprecated since Python 3.13. Useos.path.isreserved()to detect reserved paths on Windows.
-
platform.java_ver()has been deprecated since Python 3.13. This function is only useful for Jython support, has a confusing API, and is largely untested.
-
sysconfig.is_python_build()的 check_home 参数自 Python 3.12 起已被弃用。
-
在 Python 3.15 中
RLock()将不再接受参数。 传入参数的做法自 Python 3.14 起已被弃用,因为 Python 版本不接受任何参数,而 C 版本允许任意数量的位置或关键字参数,但会忽略所有参数。
-
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。The
typing.no_type_check_decorator()decorator function has been deprecated since Python 3.13. After eight years in thetypingmodule, it has yet to be supported by any major type checker.
sre_compile,sre_constantsandsre_parsemodules.wave:The
getmark(),setmark()andgetmarkers()methods of theWave_readandWave_writeclasses have been deprecated since Python 3.13.
-
zipimport.zipimporter.load_module()has been deprecated since Python 3.10. Useexec_module()instead. (gh-125746.)