计划在 Python 3.15 中移除

  • 导入系统:

    • 当设置 __spec__.cached 失败时在模块上设置 __cached__ 的做法已被弃用。 在 Python 3.15 中,__cached__ 将不会再被导入系统或标准库纳入考虑。 (gh-97879)

    • 当设备 __spec__.parent 失败时在模块上设置 __package__ 的做法已被弃用。 在 Python 3.15 中,__package__ 将不会再被导入系统或标准库纳入考虑。 (gh-97879)

  • ctypes:

    • 未写入文档的 ctypes.SetPointerType() 函数自 Python 3.13 起已被弃用。

  • http.server:

    • The obsolete and rarely used CGIHTTPRequestHandler has 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 起已被弃用。

  • importlib:

    • load_module() 方法:改用 exec_module()

  • locale:

  • pathlib:

    • .PurePath.is_reserved() has been deprecated since Python 3.13. Use os.path.isreserved() to detect reserved paths on Windows.

  • platform:

    • 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:

  • threading:

    • 在 Python 3.15 中 RLock() 将不再接受参数。 传入参数的做法自 Python 3.14 起已被弃用,因为 Python 版本不接受任何参数,而 C 版本允许任意数量的位置或关键字参数,但会忽略所有参数。

  • types:

  • typing:

    • 未写入文档的用于创建 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): passTD = TypedDict("TD", {}) 来创建一个零字段的 TypedDict。

    • typing.no_type_check_decorator() 装饰器自 Python 3.13 起已被弃用。 存在于 typing 模块八年之后,它仍未被任何主要类型检查器所支持。

  • sre_compile, sre_constants and sre_parse modules.

  • wave:

    • The getmark(), setmark() and getmarkers() methods of the Wave_read and Wave_write classes have been deprecated since Python 3.13.

  • zipimport:

    • zipimport.zipimporter.load_module() has been deprecated since Python 3.10. Use exec_module() instead. (gh-125746.)