计划在 Python 3.15 中移除 — Python 3.14.5 文档
Description: 导入系统：- Setting__cached__ on a module while failing to set__spec__.cached is deprecated. In Python 3.15,__cached__ will cease to be set or take into consideration by the import system or standard li...

# 计划在 Python 3.15 中移除

- 导入系统：

  - Setting `__cached__` on a module while failing to set `__spec__.cached` is deprecated. In Python 3.15, `__cached__` will cease to be set or take into consideration by the import system or standard library. (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`:

  - The `getdefaultlocale()` function has been deprecated since Python 3.11. Its removal was originally planned for Python 3.13 (gh-90817), but has been postponed to Python 3.15. Use `getlocale()`, `setlocale()`, and `getencoding()` instead. (Contributed by Hugo van Kemenade in gh-111187.)

- `pathlib`:

  - `PurePath.is_reserved()` has been deprecated since Python 3.13. Use `os.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`:

  - `sysconfig.is_python_build()` 的 check_home 参数自 Python 3.12 起已被弃用。

- `threading`:

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

  - `types.CodeType`: Accessing `co_lnotab` was deprecated in PEP 626 since 3.10 and was planned to be removed in 3.12, but it only got a proper `DeprecationWarning` in 3.12. May be removed in 3.15. (Contributed by Nikita Sobolev in gh-101866.)

- `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): pass` 或 `TD = TypedDict("TD", {})` 来创建一个零字段的 TypedDict。

  - The `typing.no_type_check_decorator()` decorator function has been deprecated since Python 3.13. After eight years in the `typing` module, it has yet to be supported by any major type checker.

- `wave`:

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

- `zipimport`:

  - `load_module()` has been deprecated since Python 3.10. Use `exec_module()` instead. (Contributed by Jiahao Li in gh-125746.)