Python 3.16 中待移除的項目

  • 引入系統 (import system):

    • 在模組上設定 __loader__ 而沒有設定 __spec__.loader 的做法將於 Python 3.16 被棄用。在 Python 3.16 中,引入系統或標準函式庫將不再設定或考慮 __loader__

  • array

    • 自 Python 3.3 起,'u' 格式碼 (wchar_t) 在文件中已被棄用,自 Python 3.13 起在 runtime 已被棄用。請使用 'w' 格式碼 (Py_UCS4) 來取代 Unicode 字元。

  • asyncio

  • builtins

    • 自 Python 3.12 起,布林型別的位元反轉 ~True~False 已被棄用,因為它會產生不預期且不直觀的結果(-2-1)。使用 not x 代替布林值的邏輯否定。在極少數情況下,你需要對底層的整數進行位元反轉,請明確轉換為 ~int(x) (~int(x))。

  • functools

    • 自 Python 3.14 起,使用 functionsequence 關鍵字引數呼叫 functools.reduce() 的 Python 實作已被棄用。

  • logging

    • 對具有 strm 引數的自訂日誌記錄處理函式的支援已被棄用,並計劃在 Python 3.16 中移除。請改用 stream 引數。(由 Mariusz Felisiak 於 gh-115032 貢獻。)

  • mimetypes

  • shutil

    • 自 Python 3.14 起,ExecError 例外已被棄用。自 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.