计划在 Python 3.16 中移除

  • 导入系统:

    • 当设置 __spec__.loader 失败时在模块上设置 __loader__ 的做法已被弃用。在 Python 3.16 中,__loader__ 将不会再被设置或是被导入系统或标准库纳入考虑。

  • array:

    • 'u' 格式代码 (wchar_t) 自 Python 3.3 起已在文档中弃用并自 Python 3.13 起在运行时弃用。对于 Unicode 字符请改用 'w' 格式代码 (Py_UCS4)。

  • asyncio:

  • builtins:

    • 对布尔类型 ~True~False 执行按位取反的操作自 Python 3.12 起已被弃用,因为它会产生奇怪和不直观的结果 (-2-1)。请改用 not x 来对布尔值执行逻辑否操作。 对于需要对下层整数执行按位取反操作的少数场合,请显式地将其转换为 int (~int(x))。

  • functools:

    • 调用 functools.reduce() 的 Python 实现并传入 functionsequence 作为关键字参数的做法自 Python 3.14 起已被弃用。

  • logging:

    • 使用 strm 参数对自定义日志记录处理器提供支持的做法已被弃用并计划在 Python 3.16 中移除。改为使用 stream 参数定义处理器。 (由 Mariusz Felisiak 在 gh-115032 中贡献。)

  • mimetypes:

  • shutil:

    • ExecError 异常自 Python 3.14 起已被弃用。它自 Python 3.4 起就未被 shutil 中的任何函数所使用,现在是 RuntimeError 的一个别名。

  • symtable:

    • The symtable.Class.get_methods() method has been deprecated since Python 3.14.

  • sys:

    • The _enablelegacywindowsfsencoding() function has been deprecated since Python 3.13. Use the PYTHONLEGACYWINDOWSFSENCODING environment variable instead.

  • sysconfig:

    • 自 Python 3.14 起 sysconfig.expand_makefile_vars() 函数已被弃用。请使用 sysconfig.get_paths()vars 参数代替。

  • tarfile:

    • The undocumented and unused TarInfo.tarfile attribute has been deprecated since Python 3.13.